OSDN Git Service

t#32046:
[pettanr/pettanr.git] / spec / controllers / authors_controller_spec.rb
index d13828e..29773ca 100644 (file)
@@ -4,15 +4,19 @@ require 'spec_helper'
 
 describe AuthorsController do
   before do
-    FactoryGirl.create :admin
+    SpeechBalloonTemplate.delete_all
+    @admin =FactoryGirl.create :admin
     @sp = FactoryGirl.create :system_picture
     @lg = FactoryGirl.create :license_group
     @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+    @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc",  "system_picture_id" => @sp.id, "settings" => '{}'
+    @writing_format = FactoryGirl.create :writing_format
     @user = FactoryGirl.create( :user_yas)
-    @author = @user.author
+    @author = FactoryGirl.create :author, :user_id => @user.id
     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
   end
 
+if MagicNumber['run_mode'] == 1
   describe '一覧表示に於いて' do
     before do
       Author.stub(:list).and_return([@author, @author, @author])
@@ -58,6 +62,10 @@ describe AuthorsController do
         assigns(:authors).should have_at_least(3).items
       end
       context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :index
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
         it 'indexテンプレートを描画する' do
           get :index
           response.should render_template("index")
@@ -85,7 +93,7 @@ describe AuthorsController do
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -110,6 +118,25 @@ describe AuthorsController do
         end
       end
     end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+    end
   end
   
   describe '閲覧に於いて' do
@@ -149,12 +176,12 @@ describe AuthorsController do
         it 'データがアレになっている' do
           get :show, :id => @author.id, :format => :json
           json = JSON.parse response.body
-          json["name"].should match(/name/)
+          json["name"].should match(/test/)
           json["user_id"].should eq @author.user_id
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -179,6 +206,25 @@ describe AuthorsController do
         end
       end
     end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @author.id
+        response.should be_success 
+      end
+    end
 =begin
     context '対象作家がないとき' do
       context 'html形式' do
@@ -199,197 +245,2086 @@ describe AuthorsController do
 =end
   end
   
-  describe '作家数取得に於いて' do
+  describe '対象作家のコミック一覧表示に於いて' do
     before do
-      Author.should_receive(:visible_count).and_return(3)
-#      sign_in @user
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
+      Author.stub(:show).and_return(@other_author)
+      Scroll.stub(:himlist).and_return([@scroll, @scroll, @scroll])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :scrolls, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :scrolls, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :scrolls, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :scrolls, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_scroll_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :scrolls, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.scroll_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :scrolls, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_scroll_page_size
+      end
     end
     context 'つつがなく終わるとき' do
       it 'ステータスコード200 OKを返す' do
-        get :count, :format => :json
+        get :scrolls, :id => @other_author.id
         response.should be_success 
       end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :scrolls, :id => @other_author.id
+      end
+      it 'コミックモデルに一覧を問い合わせている' do
+        Scroll.should_receive(:himlist).exactly(1)
+        get :scrolls, :id => @other_author.id
+      end
+      it '@scrollsにリストを取得している' do
+        get :scrolls, :id => @other_author.id
+        assigns(:scrolls).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :scrolls, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'scrollsテンプレートを描画する' do
+          get :scrolls, :id => @other_author.id
+          response.should render_template("scrolls")
+        end
+      end
       context 'json形式' do
         it 'jsonデータを返す' do
-          get :count, :format => :json
+          get :scrolls, :id => @other_author.id, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'データがHash構造になっていて作家数が3である' do
-          get :count, :format => :json
+        it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
+          Scroll.should_receive(:list_json_opt).exactly(1)
+          get :scrolls, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :scrolls, :id => @other_author.id, :format => :json
           json = JSON.parse response.body
-          json["count"].should == 3
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
+          get :scrolls, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("title").should be_true
+          json.first.has_key?("visible").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :scrolls, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :scrolls, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :scrolls, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :scrolls, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
         end
       end
     end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :scrolls, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :scrolls, :id => @other_author.id
+        response.should be_success 
+      end
+    end
   end
   
-  describe '編集フォーム表示に於いて' do\r
-    before do\r
-      sign_in @user\r
-      Author.stub(:edit).and_return(@author)\r
-    end\r
-    context 'つつがなく終わるとき' do\r
-      it 'ステータスコード200 OKを返す' do\r
-        get :edit, :id => @author.id\r
-        response.should be_success \r
-      end\r
-      it '作家モデルに編集取得を問い合わせている' do\r
-        Author.should_receive(:edit).exactly(1)\r
-        get :edit, :id => @author.id\r
-      end\r
-      #@authorだとログイン中のアカウントと干渉してしまう。
-      it '@auにデータを用意している' do\r
-        get :edit, :id => @author.id\r
-        assigns(:au).should eq @author\r
-      end\r
-      context 'html形式' do\r
-        it 'editテンプレートを描画する' do\r
-          get :edit, :id => @author.id\r
-          response.should render_template("edit")\r
-        end\r
-      end\r
-      context 'js形式' do\r
-        it 'edit.jsテンプレートを描画する' do\r
-          get :edit, :id => @author.id, :format => :js\r
-          response.should render_template("edit")\r
-        end\r
-      end\r
-    end\r
-    context '作家権限がないとき' do\r
-      before do\r
-        sign_out @user\r
-      end\r
-      context 'html形式' do\r
-        it 'ステータスコード302 Foundを返す' do\r
-          get :edit, :id => @author.id\r
-          response.status.should eq 302\r
-        end\r
-        it 'サインインページへ遷移する' do\r
-          get :edit, :id => @author.id\r
-          response.body.should redirect_to '/users/sign_in'\r
-        end\r
-      end\r
-      context 'js形式' do\r
-        it 'ステータスコード401 Unauthorizedを返す' do\r
-          get :edit, :id => @author.id, :format => :js\r
-          response.status.should eq 401\r
-        end\r
-        it '応答メッセージにUnauthorizedを返す' do\r
-          get :edit, :id => @author.id, :format => :js\r
-          response.message.should match(/Unauthorized/)\r
-        end\r
-      end\r
-    end\r
-  end\r
-\r
-  describe '更新に於いて' do\r
-    before do\r
-      @attr = @author.attributes
-      @attr['name'] = 'ryu'\r
-      sign_in @user\r
-    end\r
-    context '事前チェックしておく' do\r
-      it '作家モデルに編集取得を問い合わせている' do\r
-        Author.stub(:edit).with(any_args()).and_return @author\r
-        Author.should_receive(:edit).exactly(1)\r
-        put :update, :id => @author.id, :author => @attr\r
-      end\r
-      it 'モデルにpostデータ転送を依頼する' do\r
-        Author.any_instance.stub(:attributes=).with(any_args)\r
-        Author.any_instance.should_receive(:attributes=).exactly(1)\r
-        put :update, :id => @author.id, :author => @attr\r
-      end\r
-      it 'モデルに上書き補充を依頼する' do\r
-        Author.any_instance.stub(:overwrite).with(any_args)\r
-        Author.any_instance.should_receive(:overwrite).exactly(1)\r
-        put :update, :id => @author.id, :author => @attr\r
-      end\r
-      it 'モデルに更新を依頼する' do\r
-        Author.any_instance.stub(:save).with(any_args).and_return true\r
-        Author.any_instance.should_receive(:save).exactly(1)\r
-        put :update, :id => @author.id, :author => @attr\r
-      end\r
-      it '@auにアレを取得している' do\r
-        put :update, :id => @author.id, :author => @attr\r
-        assigns(:au).should eq @author\r
-      end\r
-    end\r
-    context 'つつがなく終わるとき' do\r
-      it '更新される' do\r
-        put :update, :id => @author.id, :author => @attr\r
-        Author.find(@author.id).name.should eq 'ryu'\r
-      end\r
-      context 'html形式' do\r
-        it 'ステータスコード302 Foundを返す' do\r
-          Author.any_instance.stub(:save).with(any_args()).and_return(true)\r
-          put :update, :id => @author.id, :author => @attr\r
-          response.status.should eq 302\r
-        end\r
-        it '更新された作家の表示ページへ遷移する' do\r
-          put :update, :id => @author.id, :author => @attr\r
-          response.should redirect_to(@author)\r
-        end\r
-      end\r
-      context 'json形式' do\r
-        it 'ステータスコード200 OKを返す' do\r
-          Author.any_instance.stub(:save).with(any_args()).and_return(true)\r
-          put :update, :id => @author.id, :author => @attr, :format => :json\r
-          response.should be_success \r
-        end\r
-        it 'ページ本体は特に返さない' do\r
-          Author.any_instance.stub(:save).with(any_args()).and_return(true)\r
-          put :update, :id => @author.id, :author => @attr, :format => :json\r
-          response.body.should match /./\r
-        end\r
-      end\r
-    end\r
-    context '作家権限がないとき' do\r
-      before do\r
-        sign_out @user\r
-      end\r
-      it 'ステータスコード302 Foundを返す' do\r
-        put :update, :id => @author.id, :author => @attr\r
-        response.status.should eq 302\r
-      end\r
-      context 'html形式' do\r
-        it 'サインインページへ遷移する' do\r
-          put :update, :id => @author.id, :author => @attr\r
-          response.body.should redirect_to '/users/sign_in'\r
-        end\r
-      end\r
-      context 'json形式' do\r
-        it '応答メッセージにUnauthorizedを返す' do\r
-          put :update, :id => @author.id, :author => @attr, :format => :json\r
-          response.message.should match(/Unauthorized/)\r
-        end\r
-      end\r
-    end\r
-    context '検証、保存に失敗したとき' do\r
-      before do\r
-        Author.any_instance.stub(:save).and_return(false)\r
-      end\r
-      context 'html形式' do\r
-        it 'ステータスコード200 Okを返す' do\r
-          put :update, :id => @author.id, :author => @attr\r
-          response.status.should eq 200\r
-        end\r
-        it '編集ページを描画する' do\r
-          put :update, :id => @author.id, :author => @attr\r
-          response.should render_template("edit")\r
-        end\r
-      end\r
-      context 'json形式' do\r
-        it 'ステータスコード422 unprocessable_entity を返す' do\r
-          Author.any_instance.stub(:save).and_return(false)\r
-          put :update, :id => @author.id, :author => @attr, :format => :json\r
-          response.status.should eq 422\r
-        end\r
-        it '応答メッセージUnprocessable Entityを返す' do\r
-          put :update, :id => @author.id, :author => @attr, :format => :json\r
-          response.message.should match(/Unprocessable/)\r
-        end\r
-      end\r
-    end\r
-  end\r
-
+  describe '対象作家のストーリー一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
+      @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_user.author.id
+      Author.stub(:show).and_return(@other_author)
+      ScrollPanel.stub(:himlist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :scroll_panels, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :scroll_panels, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :scroll_panels, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :scroll_panels, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_scroll_panel_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :scroll_panels, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.scroll_panel_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :scroll_panels, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_scroll_panel_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :scroll_panels, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :scroll_panels, :id => @other_author.id
+      end
+      it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
+        ScrollPanel.should_receive(:himlist).exactly(1)
+        get :scroll_panels, :id => @other_author.id
+      end
+      it '@scroll_panelsにリストを取得している' do
+        get :scroll_panels, :id => @other_author.id
+        assigns(:scroll_panels).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :scroll_panels, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'scroll_panelsテンプレートを描画する' do
+          get :scroll_panels, :id => @other_author.id
+          response.should render_template("scroll_panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
+          ScrollPanel.should_receive(:list_json_opt).exactly(1)
+          get :scroll_panels, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("panel_id").should be_true
+          json.first.has_key?("scroll_id").should be_true
+          json.first.has_key?("t").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :scroll_panels, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :scroll_panels, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :scroll_panels, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :scroll_panels, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '対象作家のコマ一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @panel = FactoryGirl.create :panel, :author_id => @other_author.id
+      Author.stub(:show).and_return(@other_author)
+      Panel.stub(:himlist).and_return([@panel, @panel, @panel])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :panels, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :panels, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :panels, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :panels, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_panel_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :panels, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.panel_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :panels, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_panel_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :panels, :id => @other_author.id
+      end
+      it 'コマモデルに他作家のコマ一覧を問い合わせている' do
+        Panel.should_receive(:himlist).exactly(1)
+        get :panels, :id => @other_author.id
+      end
+      it '@panelsにリストを取得している' do
+        get :panels, :id => @other_author.id
+        assigns(:panels).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :panels, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'panelsテンプレートを描画する' do
+          get :panels, :id => @other_author.id
+          response.should render_template("panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'コマモデルにコマリストのjson出力を問い合わせている' do
+          Panel.should_receive(:list_as_json_text).exactly(1)
+          get :panels, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :panels, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはコマっぽいものであって欲しい' do
+          get :panels, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("z").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :panels, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :panels, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '対象作家のコマ絵一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
+      Author.stub(:show).and_return(@other_author)
+      PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :panel_pictures, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :panel_pictures, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :panel_pictures, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :panel_pictures, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_panel_picture_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :panel_pictures, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.panel_picture_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :panel_pictures, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_panel_picture_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :panel_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :panel_pictures, :id => @other_author.id
+      end
+      it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
+        PanelPicture.should_receive(:himlist).exactly(1)
+        get :panel_pictures, :id => @other_author.id
+      end
+      it '@panel_picturesにリストを取得している' do
+        get :panel_pictures, :id => @other_author.id
+        assigns(:panel_pictures).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :panel_pictures, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'panel_picturesテンプレートを描画する' do
+          get :panel_pictures, :id => @other_author.id
+          response.should render_template("panel_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
+          PanelPicture.should_receive(:list_json_opt).exactly(1)
+          get :panel_pictures, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("link").should be_true
+          json.first.has_key?("x").should be_true
+          json.first.has_key?("y").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :panel_pictures, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :panel_pictures, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panel_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panel_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '対象作家のフキダシ一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @panel = FactoryGirl.create :panel, :author_id => @other_author.id
+      @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+      @speech = @sb.build_speech(
+        FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+      )
+      @balloon = @sb.build_balloon(
+        FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+      )
+      @sb.boost
+      @sb.save!
+      Author.stub(:show).and_return(@other_author)
+      SpeechBalloon.stub(:himlist).and_return([@sb, @sb, @sb])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :speech_balloons, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :speech_balloons, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :speech_balloons, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :speech_balloons, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_speech_balloon_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :speech_balloons, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.speech_balloon_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :speech_balloons, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_speech_balloon_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :speech_balloons, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :speech_balloons, :id => @other_author.id
+      end
+      it 'フキダシモデルに他作家のフキダシ一覧を問い合わせている' do
+        SpeechBalloon.should_receive(:himlist).exactly(1)
+        get :speech_balloons, :id => @other_author.id
+      end
+      it '@speech_balloonsにリストを取得している' do
+        get :speech_balloons, :id => @other_author.id
+        assigns(:speech_balloons).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :speech_balloons, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'speech_balloonsテンプレートを描画する' do
+          get :speech_balloons, :id => @other_author.id
+          response.should render_template("speech_balloons")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :speech_balloons, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
+          SpeechBalloon.should_receive(:list_json_opt).exactly(1)
+          get :speech_balloons, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :speech_balloons, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
+          get :speech_balloons, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("speech_balloon_template_id").should be_true
+          json.first.has_key?("z").should be_true
+          json.first.has_key?("t").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :speech_balloons, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :speech_balloons, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :speech_balloons, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :speech_balloons, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :speech_balloons, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :speech_balloons, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '対象作家の絵地一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+      Author.stub(:show).and_return(@other_author)
+      GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :ground_pictures, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :ground_pictures, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :ground_pictures, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :ground_pictures, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_ground_picture_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :ground_pictures, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.ground_picture_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :ground_pictures, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.default_ground_picture_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :ground_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :ground_pictures, :id => @other_author.id
+      end
+      it '絵地モデルに他作家の絵地一覧を問い合わせている' do
+        GroundPicture.should_receive(:himlist).exactly(1)
+        get :ground_pictures, :id => @other_author.id
+      end
+      it '@ground_picturesにリストを取得している' do
+        get :ground_pictures, :id => @other_author.id
+        assigns(:ground_pictures).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :ground_pictures, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'ground_picturesテンプレートを描画する' do
+          get :ground_pictures, :id => @other_author.id
+          response.should render_template("ground_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it '絵地モデルにjson一覧出力オプションを問い合わせている' do
+          GroundPicture.should_receive(:list_json_opt).exactly(1)
+          get :ground_pictures, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("panel_id").should be_true
+          json.first.has_key?("picture_id").should be_true
+          json.first.has_key?("z").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :ground_pictures, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :ground_pictures, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :ground_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :ground_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '対象作家の色地一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @gc = FactoryGirl.create :ground_color
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      Author.stub(:show).and_return(@other_author)
+      GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
+      sign_in @user
+    end
+    context 'パラメータpageについて' do
+      it '@pageに値が入る' do
+        get :ground_colors, :id => @other_author.id, :page => 5
+        assigns(:page).should eq 5
+      end
+      it '省略されると@pageに1値が入る' do
+        get :ground_colors, :id => @other_author.id
+        assigns(:page).should eq 1
+      end
+      it '与えられたpage_sizeがセットされている' do
+        get :ground_colors, :id => @other_author.id, :page_size => 15
+        assigns(:page_size).should eq 15
+      end
+      it '省略されると@page_sizeにデフォルト値が入る' do
+        get :ground_colors, :id => @other_author.id
+        assigns(:page_size).should eq Author.default_ground_color_page_size
+      end
+      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+        get :ground_colors, :id => @other_author.id, :page_size => 1500
+        assigns(:page_size).should eq Author.ground_color_max_page_size
+      end
+      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+        get :ground_colors, :id => @other_author.id, :page_size => 0
+        assigns(:page_size).should eq Author.ground_color_page_size
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :ground_colors, :id => @other_author.id
+        response.should be_success 
+      end
+      it '作家モデルに単体取得を問い合わせている' do
+        Author.should_receive(:show).exactly(1)
+        get :ground_colors, :id => @other_author.id
+      end
+      it '色地モデルに他作家の色地一覧を問い合わせている' do
+        GroundColor.should_receive(:himlist).exactly(1)
+        get :ground_colors, :id => @other_author.id
+      end
+      it '@ground_colorsにリストを取得している' do
+        get :ground_colors, :id => @other_author.id
+        assigns(:ground_colors).should have_at_least(3).items
+      end
+      context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :ground_colors, :id => @other_author.id
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
+        it 'ground_colorsテンプレートを描画する' do
+          get :ground_colors, :id => @other_author.id
+          response.should render_template("ground_colors")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it '色地モデルにjson一覧出力オプションを問い合わせている' do
+          GroundColor.should_receive(:list_json_opt).exactly(1)
+          get :ground_colors, :id => @other_author.id, :format => :json
+        end
+        it 'データがリスト構造になっている' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.should have_at_least(3).items
+        end
+        it 'リストの先頭くらいは色地っぽいものであって欲しい' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          json = JSON.parse response.body
+          json.first.has_key?("panel_id").should be_true
+          json.first.has_key?("code").should be_true
+          json.first.has_key?("z").should be_true
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :ground_colors, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :ground_colors, :id => @other_author.id
+          response.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :ground_colors, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :ground_colors, :id => @other_author.id
+        response.should be_success 
+      end
+    end
+  end
+  
+  describe '作家数取得に於いて' do
+    before do
+      Author.should_receive(:visible_count).and_return(3)
+#      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :count, :format => :json
+        response.should be_success 
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :count, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it 'データがHash構造になっていて作家数が3である' do
+          get :count, :format => :json
+          json = JSON.parse response.body
+          json["count"].should == 3
+        end
+      end
+    end
+  end
+  
+  describe '新規作成フォーム表示に於いて' do
+    before do
+      @new_user = FactoryGirl.create( :user_yas)
+      sign_in @new_user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :new
+        response.should be_success 
+      end
+      it '@auに新規データを用意している' do
+        get :new
+        assigns(:au).should be_a_new(Author)
+      end
+      it '作家モデルにデフォルト値補充を依頼している' do
+        Author.any_instance.should_receive(:supply_default).exactly(1)
+        get :new
+      end
+      context 'html形式' do
+        it 'newテンプレートを描画する' do
+          get :new
+          response.should render_template("new")
+        end
+      end
+      context 'js形式' do
+        it 'new.jsテンプレートを描画する' do
+          get :new, :format => :js
+          response.should render_template("new")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :new, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it '作家モデルにjson単体出力オプションを問い合わせている' do
+          Author.should_receive(:show_json_opt).exactly(1)
+          get :new, :format => :json
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @new_user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :new
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :new
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :new, :format => :js
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :new, :format => :js
+          response.message.should match(/Unauthorized/)
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :new, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :new, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :new
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :new
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+          get :new
+        response.should be_success 
+      end
+    end
+  end
+
+  describe '新規作成に於いて' do
+    before do
+      @new_user = FactoryGirl.create( :user_yas)
+      sign_in @new_user
+      @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
+    end
+    context '事前チェックしておく' do
+      it '作家モデルにデフォルト値補充を依頼している' do
+        Author.any_instance.should_receive(:supply_default).exactly(1)
+        post :create, :author => @attr
+      end
+      it '作家モデルにカラム値復元を依頼している' do
+        Author.any_instance.should_receive(:attributes=).exactly(1)
+        post :create, :author => @attr
+      end
+      it '作家モデルに上書き補充を依頼している' do
+        Author.any_instance.should_receive(:overwrite).exactly(1)
+        post :create, :author => @attr
+      end
+      it 'モデルに保存依頼する' do
+        Author.any_instance.should_receive(:save).exactly(1)
+        post :create, :author => @attr
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it "@auに作成された作家を保持していて、それがDBにある" do
+        post :create, :author => @attr
+        assigns(:au).should be_a(Author)
+        assigns(:au).should be_persisted
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          Author.any_instance.stub(:save).and_return(true)
+          post :create, :author => @attr
+          response.status.should eq 302
+        end
+        it 'トップページへ遷移する' do
+#          Author.any_instance.stub(:save).and_return(true)
+          post :create, :author => @attr
+          response.should redirect_to(root_path)
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+#          Author.any_instance.stub(:save).and_return(true)
+          post :create, :author => @attr, :format => :json
+          response.should be_success 
+        end
+        it '作成された作家をjsonデータで返す' do
+          post :create, :author => @attr, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+        it '作家モデルにjson単体出力オプションを問い合わせている' do
+          Author.should_receive(:show_json_opt).exactly(1)
+          post :create, :author => @attr, :format => :json
+        end
+        it 'データがアレになっている' do
+          post :create, :author => @attr, :format => :json
+          json = JSON.parse response.body
+          json["name"].should match(/ken/)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @new_user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          post :create, :author => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          post :create, :author => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          post :create, :author => @attr, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          post :create, :author => @attr, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          post :create, :author => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          post :create, :author => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context '検証、保存に失敗した' do
+      before do
+        Author.any_instance.stub(:save).and_return(false)
+      end
+      it "未保存の作家を保持している" do
+        post :create, :author => @attr
+        assigns(:au).should be_a_new(Author)
+      end
+      context 'html形式' do
+        it 'ステータスコード200 OKを返す' do
+          post :create, :author => @attr
+          response.status.should eq 200
+        end
+        it '新規ページを描画する' do
+          post :create, :author => @attr
+          response.should render_template("new")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード422 unprocessable_entity を返す' do
+          post :create, :author => @attr, :format => :json
+          response.status.should eq 422
+        end
+        it '応答メッセージUnprocessable Entityを返す' do
+          post :create, :author => @attr, :format => :json
+          response.message.should match(/Unprocessable/)
+        end
+      end
+    end
+  end
+
+  describe '編集フォーム表示に於いて' do
+    before do
+      sign_in @user
+      Author.stub(:edit).and_return(@author)
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :edit, :id => @author.id
+        response.should be_success 
+      end
+      it '作家モデルに編集取得を問い合わせている' do
+        Author.should_receive(:edit).exactly(1)
+        get :edit, :id => @author.id
+      end
+      #@authorだとログイン中のアカウントと干渉してしまう。
+      it '@auにデータを用意している' do
+        get :edit, :id => @author.id
+        assigns(:au).should eq @author
+      end
+      context 'html形式' do
+        it 'editテンプレートを描画する' do
+          get :edit, :id => @author.id
+          response.should render_template("edit")
+        end
+      end
+      context 'js形式' do
+        it 'edit.jsテンプレートを描画する' do
+          get :edit, :id => @author.id, :format => :js
+          response.should render_template("edit")
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :edit, :id => @author.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :edit, :id => @author.id, :format => :js
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :edit, :id => @author.id, :format => :js
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :edit, :id => @author.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @other_user = FactoryGirl.create( :user_yas)
+        @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          get :edit, :id => @other_author.id
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+  end
+
+  describe '更新に於いて' do
+    before do
+      @attr = @author.attributes
+      @attr['name'] = 'ryu'
+      sign_in @user
+    end
+    context '事前チェックしておく' do
+      it '作家モデルに編集取得を問い合わせている' do
+        Author.stub(:edit).with(any_args()).and_return @author
+        Author.should_receive(:edit).exactly(1)
+        put :update, :id => @author.id, :author => @attr
+      end
+      it 'モデルにpostデータ転送を依頼する' do
+        Author.any_instance.stub(:attributes=).with(any_args)
+        Author.any_instance.should_receive(:attributes=).exactly(1)
+        put :update, :id => @author.id, :author => @attr
+      end
+      it 'モデルに上書き補充を依頼する' do
+        Author.any_instance.stub(:overwrite).with(any_args)
+        Author.any_instance.should_receive(:overwrite).exactly(1)
+        put :update, :id => @author.id, :author => @attr
+      end
+      it 'モデルに更新を依頼する' do
+        Author.any_instance.stub(:save).with(any_args).and_return true
+        Author.any_instance.should_receive(:save).exactly(1)
+        put :update, :id => @author.id, :author => @attr
+      end
+      it '@auにアレを取得している' do
+        put :update, :id => @author.id, :author => @attr
+        assigns(:au).should eq @author
+      end
+    end
+    context 'つつがなく終わるとき' do
+      it '更新される' do
+        put :update, :id => @author.id, :author => @attr
+        Author.find(@author.id).name.should eq 'ryu'
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          Author.any_instance.stub(:save).with(any_args()).and_return(true)
+          put :update, :id => @author.id, :author => @attr
+          response.status.should eq 302
+        end
+        it '設定ページへ遷移する' do
+          put :update, :id => @author.id, :author => @attr
+          response.should redirect_to('/home/configure')
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          Author.any_instance.stub(:save).with(any_args()).and_return(true)
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.should be_success 
+        end
+        it 'ページ本体は特に返さない' do
+          Author.any_instance.stub(:save).with(any_args()).and_return(true)
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.body.should match /./
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          put :update, :id => @author.id, :author => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          put :update, :id => @author.id, :author => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it '応答メッセージにUnauthorizedを返す' do
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          put :update, :id => @author.id, :author => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          put :update, :id => @author.id, :author => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @other_user = FactoryGirl.create( :user_yas)
+        @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+        @author.destroy
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :update, :id => @other_author.id
+          response.status.should eq 302
+        end
+        it '作家登録ページへ遷移する' do
+          get :update, :id => @other_author.id
+          response.body.should redirect_to new_author_path
+        end
+      end
+    end
+    context '検証、保存に失敗したとき' do
+      before do
+        Author.any_instance.stub(:save).and_return(false)
+      end
+      context 'html形式' do
+        it 'ステータスコード200 Okを返す' do
+          put :update, :id => @author.id, :author => @attr
+          response.status.should eq 200
+        end
+        it '編集ページを描画する' do
+          put :update, :id => @author.id, :author => @attr
+          response.should render_template("edit")
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード422 unprocessable_entity を返す' do
+          Author.any_instance.stub(:save).and_return(false)
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.status.should eq 422
+        end
+        it '応答メッセージUnprocessable Entityを返す' do
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.message.should match(/Unprocessable/)
+        end
+      end
+    end
+  end
+
+else
+  describe '一覧表示に於いて' do
+    before do
+      Author.stub(:list).and_return([@author, @author, @author])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'indexテンプレートを描画する' do
+          get :index
+          response.should render_template("index")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :index, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'indexテンプレートを描画する' do
+          get :index
+          response.should render_template("index")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :index, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '閲覧に於いて' do
+    before do
+      Author.stub(:show).and_return(@author)
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @author.id
+        response.should be_success
+      end
+      context 'html形式' do
+        it 'showテンプレートを描画する' do
+          get :show, :id => @author.id
+          response.should render_template("show")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :show, :id => @author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @author.id
+        response.should be_success
+      end
+      context 'html形式' do
+        it 'showテンプレートを描画する' do
+          get :show, :id => @author.id
+          response.should render_template("show")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :show, :id => @author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '対象作家のコミック一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
+      Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :scrolls, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'scrollテンプレートを描画する' do
+          get :scrolls, :id => @other_author.id
+          response.should render_template("scroll")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :scrolls, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :scrolls, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'scrollsテンプレートを描画する' do
+          get :scrolls, :id => @other_author.id
+          response.should render_template("scrolls")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :scrolls, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '対象作家のストーリー一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
+      @panel = FactoryGirl.create :panel, :author_id => @other_author.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id
+      ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :scroll_panels, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'scroll_panelsテンプレートを描画する' do
+          get :scroll_panels, :id => @other_author.id
+          response.should render_template("scroll_panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :scroll_panels, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'scroll_panelsテンプレートを描画する' do
+          get :scroll_panels, :id => @other_author.id
+          response.should render_template("scroll_panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :scroll_panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '対象作家のコマ一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @panel = FactoryGirl.create :panel, :author_id => @other_author.id
+      Panel.stub(:mylist).and_return([@panel, @panel, @panel])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'panelsテンプレートを描画する' do
+          get :panels, :id => @other_author.id
+          response.should render_template("panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panels, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'panelsテンプレートを描画する' do
+          get :panels, :id => @other_author.id
+          response.should render_template("panels")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panels, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '対象作家のコマ絵一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
+      PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :panel_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'panel_picturesテンプレートを描画する' do
+          get :panel_pictures, :id => @other_author.id
+          response.should render_template("panel_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :panel_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'panel_picturesテンプレートを描画する' do
+          get :panel_pictures, :id => @other_author.id
+          response.should render_template("panel_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :panel_pictures, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '対象作家の絵地一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+      GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :ground_pictures, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'ground_picturesテンプレートを描画する' do
+          get :ground_pictures, :id => @other_author.id
+          response.should render_template("ground_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ground_picturesテンプレートを描画する' do
+          get :ground_pictures, :id => @other_author.id
+          response.should render_template("ground_pictures")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :ground_pictures, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '対象作家の色地一覧表示に於いて' do
+    before do
+      @other_user = FactoryGirl.create( :user_yas)
+      @other_author = FactoryGirl.create :author, :user_id => @other_user.id
+      @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
+      @gc = FactoryGirl.create :ground_color
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :ground_colors, :id => @other_author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'ground_colorsテンプレートを描画する' do
+          get :ground_colors, :id => @other_author.id
+          response.should render_template("ground_colors")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ground_colorsテンプレートを描画する' do
+          get :ground_colors, :id => @other_author.id
+          response.should render_template("ground_colors")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :ground_colors, :id => @other_author.id, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '作家数取得に於いて' do
+    before do
+      Author.should_receive(:visible_count).and_return(3)
+#      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :count, :format => :json
+        response.should be_success 
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :count, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+  end
+  
+  describe '新規作成フォーム表示に於いて' do
+    before do
+      @new_user = FactoryGirl.create( :user_yas)
+      sign_in @new_user
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :new
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'newテンプレートを描画する' do
+          get :new
+          response.should render_template("new")
+        end
+      end
+      context 'js形式' do
+        it 'new.jsテンプレートを描画する' do
+          get :new, :format => :js
+          response.should render_template("new")
+        end
+      end
+      context 'json形式' do
+        it 'jsonデータを返す' do
+          get :new, :format => :json
+          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @new_user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :new
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :new
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :new, :format => :js
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :new, :format => :js
+          response.message.should match(/Unauthorized/)
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :new, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :new, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+  end
+
+  describe '新規作成に於いて' do
+    before do
+      @new_user = FactoryGirl.create( :user_yas)
+      sign_in @new_user
+      @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
+    end
+    context 'つつがなく終わるとき' do
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          Author.any_instance.stub(:save).and_return(true)
+          post :create, :author => @attr
+          response.status.should eq 302
+        end
+        it 'トップページへ遷移する' do
+#          Author.any_instance.stub(:save).and_return(true)
+          post :create, :author => @attr
+          response.should redirect_to(root_path)
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+#          Author.any_instance.stub(:save).and_return(true)
+          post :create, :author => @attr, :format => :json
+          response.should be_success 
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @new_user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          post :create, :author => @attr
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          post :create, :author => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          post :create, :author => @attr, :format => :json
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          post :create, :author => @attr, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+  end
+
+  describe '編集フォーム表示に於いて' do
+    before do
+      sign_in @user
+      Author.stub(:edit).and_return(@author)
+    end
+    context 'つつがなく終わるとき' do
+      it 'ステータスコード200 OKを返す' do
+        get :edit, :id => @author.id
+        response.should be_success 
+      end
+      context 'html形式' do
+        it 'editテンプレートを描画する' do
+          get :edit, :id => @author.id
+          response.should render_template("edit")
+        end
+      end
+      context 'js形式' do
+        it 'edit.jsテンプレートを描画する' do
+          get :edit, :id => @author.id, :format => :js
+          response.should render_template("edit")
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          get :edit, :id => @author.id
+          response.status.should eq 302
+        end
+        it 'サインインページへ遷移する' do
+          get :edit, :id => @author.id
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'js形式' do
+        it 'ステータスコード401 Unauthorizedを返す' do
+          get :edit, :id => @author.id, :format => :js
+          response.status.should eq 401
+        end
+        it '応答メッセージにUnauthorizedを返す' do
+          get :edit, :id => @author.id, :format => :js
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+  end
+
+  describe '更新に於いて' do
+    before do
+      @attr = @author.attributes
+      @attr['name'] = 'ryu'
+      sign_in @user
+    end
+    context 'つつがなく終わるとき' do
+      it '更新される' do
+        put :update, :id => @author.id, :author => @attr
+        Author.find(@author.id).name.should eq 'ryu'
+      end
+      context 'html形式' do
+        it 'ステータスコード302 Foundを返す' do
+          Author.any_instance.stub(:save).with(any_args()).and_return(true)
+          put :update, :id => @author.id, :author => @attr
+          response.status.should eq 302
+        end
+        it '設定ページへ遷移する' do
+          put :update, :id => @author.id, :author => @attr
+          response.should redirect_to('/home/configure')
+        end
+      end
+      context 'json形式' do
+        it 'ステータスコード200 OKを返す' do
+          Author.any_instance.stub(:save).with(any_args()).and_return(true)
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.should be_success 
+        end
+        it 'ページ本体は特に返さない' do
+          Author.any_instance.stub(:save).with(any_args()).and_return(true)
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.body.should match /./
+        end
+      end
+    end
+    context 'ユーザ権限がないとき' do
+      before do
+        sign_out @user
+      end
+      it 'ステータスコード302 Foundを返す' do
+        put :update, :id => @author.id, :author => @attr
+        response.status.should eq 302
+      end
+      context 'html形式' do
+        it 'サインインページへ遷移する' do
+          put :update, :id => @author.id, :author => @attr
+          response.body.should redirect_to '/users/sign_in'
+        end
+      end
+      context 'json形式' do
+        it '応答メッセージにUnauthorizedを返す' do
+          put :update, :id => @author.id, :author => @attr, :format => :json
+          response.message.should match(/Unauthorized/)
+        end
+      end
+    end
+  end
+
+end
 end