OSDN Git Service

fix test
[pettanr/pettanr.git] / spec / controllers / scrolls_controller_spec.rb
index 041f309..78ad23a 100644 (file)
@@ -4,515 +4,298 @@ require 'spec_helper'
 describe ScrollsController do
   before do
     @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
-    @user = FactoryGirl.create :user_yas
-    @author = FactoryGirl.create :author, :user_id => @user.id
+    @author_yas =  FactoryGirl.create :yas_with_scrolls
+    @user_yas = @author_yas.user
+    @user_rom = FactoryGirl.create :user_rom
   end
-  
-if MagicNumber['run_mode'] == 1
+
+if Manifest.manifest.magic_numbers['run_mode'] == 1
   describe '一覧表示に於いて' do
     before do
-      @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
-      Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
-      sign_in @user
     end
-    context '事前チェックする' do
-      it '与えられたpageがセットされている' do
-        get :index, :page => 5
-        assigns(:page).should eq 5
-      end
-      it '省略されると@pageに1値が入る' do
-        get :index
-        assigns(:page).should eq 1
-      end
-      it '与えられたpage_sizeがセットされている' do
-        get :index, :page_size => 15
-        assigns(:page_size).should eq 15
-      end
-      it '省略されると@page_sizeにデフォルト値が入る' do
-        get :index
-        assigns(:page_size).should eq Scroll.default_page_size
-      end
-      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
-        get :index, :page_size => 1500
-        assigns(:page_size).should eq Scroll.max_page_size
+    
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       end
-      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
-        get :index, :page_size => 0
-        assigns(:page_size).should eq Scroll.default_page_size
+      it 'ステータス OKを返して、ファイラーまたはjsonデータを返す。' do
+        list_should_return_filer_or_json :index
       end
-    end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
+      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
         get :index
-        response.should be_success 
+        expect(assigns(:my_model_class)).to be Scroll
       end
-      it 'スクロールモデルに一覧を問い合わせている' do
-        Scroll.should_receive(:list).exactly(1)
+      it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
         get :index
+        expect(assigns(:list).item_name).to eq('scroll')
+        expect(assigns(:list).list_name).to eq('public')
       end
-      it '@scrollsにリストを取得している' do
+      it '@itemsにリストを取得している' do
         get :index
-        assigns(:scrolls).should have_at_least(3).items
+        expect(assigns(:items).size).to be >= 3
       end
       context 'html形式' do
-        it '@paginateにページ制御を取得している' do
-          get :index
-          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
-        end
-        it 'indexテンプレートを描画する' do
+        it '@filerにファイラーを取得している' do
           get :index
-          response.should render_template("index")
+          expect(assigns(:filer).class).to be Locmare::Filer
         end
       end
       context 'json形式' do
-        it 'jsonデータを返す' do
-          get :index, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-        it 'スクロールモデルにjson一覧出力オプションを問い合わせている' do
-          Scroll.should_receive(:list_json_opt).exactly(1)
-          get :index, :format => :json
-        end
-        it 'データがリスト構造になっている' do
-          get :index, :format => :json
-          json = JSON.parse response.body
-          json.should have_at_least(3).items
-        end
-        it 'リストの先頭くらいはスクロールっぽいものであって欲しい' do
-          get :index, :format => :json
-          json = JSON.parse response.body
-          json.first.has_key?("title").should be_true
-          json.first.has_key?("visible").should be_true
+        it '@filerにファイラーをセットしていない' do
+          get :index, format: :json
+          expect(assigns(:filer)).to be nil
         end
       end
     end
-    context 'ユーザ権限がないとき' do
+    context '件数取得' do
       before do
-        sign_out @user
+        sign_in @user_yas
       end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :index
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :index
-          response.should redirect_to '/users/sign_in'
-        end
+      it 'ステータス OKを返す' do
+        return_ok_at_get :count, format: :json
       end
       context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :index, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :index, :format => :json
-          response.message.should match(/Unauthorized/)
+        it 'jsonデータを返す' do
+          get :count, format: :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
       end
     end
-    context 'ユーザ権限はないが管理者権限があるとき' do
-      before do
-        sign_out @user
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答する' do
         sign_in @admin
+        return_ok_at_get :index
+        return_ok_at_get :index, format: :json
       end
-      it 'ステータスコード200 OKを返す' do
-        get :index
-        response.should be_success 
+      it '創作活動してないROM専の読者にも通常通り応答する' do
+        sign_in @user_rom
+        return_ok_at_get :index
+        return_ok_at_get :index, format: :json
+      end
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :index
       end
     end
-    context 'ユーザだが作家登録していないとき' do
+  end
+  describe '作家フィルタ一覧及びカウント' do
+    before do
+    end
+    context '正常系の共通処理' do
       before do
-        @author.destroy
+        sign_in @user_yas
       end
-      context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :index
-          response.should be_success 
-        end
+      it '@itemsにリストを取得している' do
+        get :by_author
+        expect(assigns(:items).size).to be >= 3
+      end
+      it 'ステータスコード200 OKを返す' do
+        list_should_return_filer_or_json :by_author, id: @author_yas.id
+      end
+    end
+    context '権限' do
+      it 'ユーザ権限はないが管理者権限があるとき 200 OKを返す' do
+        sign_in @admin
+        return_ok_at_get :by_author, id: @author_yas.id
+        return_ok_at_get :by_author, id: @author_yas.id, format: :json
+      end
+      it 'ユーザだが作家登録していないとき 200 OKを返す' do
+        sign_in @user_rom
+        return_ok_at_get :by_author, id: @author_yas.id
+        return_ok_at_get :by_author, id: @author_yas.id, format: :json
+      end
+      it 'sign_inを返す' do
+        announce_sign_in_at_get :by_author, id: @author_yas.id
       end
     end
   end
   
   describe '単体表示に於いて' do
     before do
-      @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id, :title => 'normal'
-      Scroll.stub(:show).and_return(@scroll)
-      sign_in @user
+      @item = @author_yas.scrolls.first
+      @item_id = @item.id
     end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :show, :id => @scroll.id
-        response.should be_success
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       end
-      it 'スクロールモデルに単体取得を問い合わせている' do
-        Scroll.should_receive(:show).exactly(1)
-        get :show
+      it '[html, json, prof]でステータスコード200 OKを返す' do
+        return_ok_at_get :show, id: @item_id
+        return_ok_at_get :show, id: @item_id, format: :json
+        return_ok_at_get :show, id: @item_id, format: :prof
       end
-      it '@scrollにアレを取得している' do
-        get :show, :id => @scroll.id
-        assigns(:scroll).id.should eq(@scroll.id)
+      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
+        get :show, id: @item_id
+        expect(assigns(:my_model_class)).to be Scroll
+      end
+      it '@itemにリクエストしたアイテムを取得している' do
+        get :show, id: @item_id
+        expect(assigns(:item)).to eq(@item)
       end
       context 'html形式' do
         it 'showテンプレートを描画する' do
-          get :show, :id => @scroll.id
-          response.should render_template("show")
+          get :show, id: @item_id
+          expect(response).to render_template("show")
         end
       end
       context 'json形式' do
         it 'jsonデータを返す' do
-          get :show, :id => @scroll.id, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-        it 'スクロールモデルにjson単体出力オプションを問い合わせている' do
-          Scroll.should_receive(:show_json_opt).exactly(1)
-          get :show, :id => @scroll.id, :format => :json
-        end
-        it 'データがアレになっている' do
-          get :show, :id => @scroll.id, :format => :json
-          json = JSON.parse response.body
-          json["title"].should match(/normal/)
-          json["visible"].should_not be_nil
-        end
-      end
-    end
-    context 'ユーザ権限がないとき' do
-      before do
-        sign_out @user
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :show, :id => @scroll.id
-          response.status.should eq 302
+          get :show, id: @item_id, format: :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
-        it 'ã\82µã\82¤ã\83³ã\82¤ã\83³ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99ã\82\8b' do
-          get :show, :id => @scroll.id
-          response.body.should redirect_to '/users/sign_in'
+        it 'ã\83\97ã\83­ã\83\95ã\82¡ã\82¤ã\83©ã\83¼ã\81¯å¿\85è¦\81ã\81ªã\81\84ã\81®ã\81§@profilerã\81«ç\94¨æ\84\8fã\81\97ã\81¦ã\81\84ã\81ªã\81\84' do
+          get :show, id: @item_id, format: :json
+          expect(assigns(:profiler)).to be nil
         end
       end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :show, :id => @scroll.id, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :show, :id => @scroll.id, :format => :json
-          response.message.should match(/Unauthorized/)
+      context 'prof形式' do
+        it 'プロファイラーテンプレートを描画する' do
+          get :show, id: @item_id, format: :prof
+          expect(response).to render_template("templates/r/profiler/profiler")
         end
       end
     end
-    context 'ユーザ権限はないが管理者権限があるとき' do
-      before do
-        sign_out @user
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答する' do
         sign_in @admin
+        return_ok_at_get :show, id: @item_id
+        return_ok_at_get :show, id: @item_id, format: :json
       end
-      it 'ステータスコード200 OKを返す' do
-        get :show, :id => @scroll.id
-        response.should be_success 
-      end
-    end
-    context 'ユーザだが作家登録していないとき' do
-      before do
-        @author.destroy
-      end
-      context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :show, :id => @scroll.id
-          response.should be_success
-        end
-      end
-    end
-=begin
-    context '対象スクロールがないとき' do
-      context 'html形式' do
-        it '例外404 not_foundを返す' do
-          lambda{
-            get :show, :id => 0
-          }.should raise_error(ActiveRecord::RecordNotFound)
-        end
+      it '創作活動してないROM専の読者にも通常通り応答する' do
+        sign_in @user_rom
+        return_ok_at_get :show, id: @item_id
+        return_ok_at_get :show, id: @item_id, format: :json
       end
-      context 'json形式' do
-        it '例外404 not_foundを返す' do
-          lambda{ 
-            get :show, :id => 0, :format => :json
-          }.should raise_error(ActiveRecord::RecordNotFound)
-        end
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :show, id: @item_id
       end
     end
-    context '非公開スクロールを見ようとしたとき' do
-      context 'html形式' do
-        it '例外403 forbiddenを返す' do
-          Scroll.any_instance.stub(:visible?).with(any_args()).and_return(false)
-          hidden = FactoryGirl.create :hidden_scroll, :author_id => @author.id
-          lambda{
-            get :show, :id => hidden
-          }.should raise_error(ActiveRecord::Forbidden)
-        end
-      end
-      context 'json形式' do
-        it '例外403 forbiddenを返す' do
-          Scroll.any_instance.stub(:visible?).with(any_args()).and_return(false)
-          hidden = FactoryGirl.create :hidden_scroll, :author_id => @author.id
-          lambda{
-            get :show, :id => hidden, :format => :json
-          }.should raise_error(ActiveRecord::Forbidden)
-        end
-      end
-    end
-=end
   end
   
-  describe '閲覧に於いて' do
+  describe 'プレイリストに於いて' do
     before do
-      @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
-      @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @author.id
-      Scroll.stub(:show).with(@scroll.id.to_s, [@user, nil]).and_return(@scroll)
-      Scroll.stub(:show).with(@scroll.id.to_s, [nil, @admin]).and_return(@scroll)
-      ScrollPanel.stub(:count).and_return(10)
-      ScrollPanel.stub(:play_list).with(any_args).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
-      sign_in @user
+      @item = @author_yas.scrolls.first
+      @item_id = @item.id
     end
-    context 'パラメータチェックする' do
-      it '与えられたoffsetがセットされている' do
-        get :play, :id => @scroll.id, :offset => 5
-        assigns(:offset).should eq 5
-      end
-      it '省略されると@offsetに0値が入る' do
-        get :play, :id => @scroll.id
-        assigns(:offset).should eq 0
-      end
-      it '与えられたcountがセットされている' do
-        get :play, :id => @scroll.id, :count => 4
-        assigns(:panel_count).should eq 4
-      end
-      it '省略されると@panel_countにデフォルト値が入る' do
-        get :play, :id => @scroll.id
-        assigns(:panel_count).should eq ScrollPanel.default_panel_size
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       end
-      it '最大を超えると@panel_countにデフォルト最大値が入る' do
-        get :play, :id => @scroll.id, :count => 1500
-        assigns(:panel_count).should eq ScrollPanel.max_panel_size
+      it '[html, json]でステータス OKを返す' do
+        return_ok_at_get :play, id: @item_id
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-      it '不正な値が入ると@panel_countにデフォルト最大値が入る' do
-        get :play, :id => @scroll.id, :count => -1
-        assigns(:panel_count).should eq ScrollPanel.default_panel_size
+      it 'コントローラのマニフェストからScrollPanelモデルを@my_model_classに取得している' do
+        # リクエストの対象はスクロールであるが、返されるのはスクコマのリストである。
+        # くれぐれも間違えないように。 
+        get :play, :id => @item_id
+        expect(assigns(:my_model_class)).to be ScrollPanel
       end
-    end
-    context '事前チェックする' do
-      it 'スクロールモデルに単体取得を問い合わせている' do
-        Scroll.should_receive(:show).with(@scroll.id.to_s, [@user, nil]).exactly(1)
-        get :play, :id => @scroll.id
+      it '@itemにリクエストしたスクロールを取得している' do
+        get :play, :id => @item_id
+        expect(assigns(:item)).to eq(@item)
       end
-      it 'スクコマモデルにプレイリスト取得を問い合わせている' do
-        ScrollPanel.should_receive(:play_list).with(@scroll, @author, 0, 30).exactly(1)
-        get :play, :id => @scroll.id
+      it 'リストグループのマニフェストからプレイリストの取得処理を@listに取得している' do
+        get :play, :id => @item_id
+        expect(assigns(:list).item_name).to eq('scroll_panel')
+        expect(assigns(:list).list_name).to eq('play')
       end
-    end
-    context 'つつがなく終わるとき' do
-      it '@scroll_panelsにリストを取得している' do
-        get :play, :id => @scroll.id
-        assigns(:scroll_panels).should have_at_least(3).items
+      it '@itemsにプレイリストを取得している' do
+        get :play, :id => @item_id
+        expect(assigns(:items).size).to be >= 3
+        expect(assigns(:count)).to be >= 3
+        expect(assigns(:pager)).to be nil
       end
       context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :play, :id => @scroll.id
-          response.should be_success 
-        end
-        it 'scrollテンプレートを描画する' do
-          get :play, :id => @scroll.id
-          response.should render_template("scroll")
+        it 'playテンプレートを描画する' do
+          get :play, :id => @item_id
+          expect(response).to render_template("play")
         end
       end
       context 'json形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          response.should be_success 
-        end
         it 'jsonデータを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-        it 'スクコマモデルにスクコマリストのjson出力を問い合わせている' do
-          ScrollPanel.should_receive(:list_as_json_text).exactly(1)
-          get :play, :id => @scroll.id, :format => :json
-        end
-        it 'データがリスト構造になっている' do
-          get :play, :id => @scroll.id, :format => :json
-          json = JSON.parse response.body
-          json.should have_at_least(3).items
-        end
-        it 'リストの先頭くらいはスクコマっぽいものであって欲しい' do
-          get :play, :id => @scroll.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?("author_id").should be_true
-        end
-      end
-    end
-    context 'ユーザ権限がないとき' do
-      before do
-        sign_out @user
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :play, :id => @scroll.id
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :play, :id => @scroll.id
-          response.should redirect_to '/users/sign_in'
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :play, :id => @scroll.id, :format => :json
-          response.message.should match(/Unauthorized/)
+          get :play, :id => @item_id, :format => :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
       end
     end
-    context 'ユーザ権限はないが管理者権限があるとき' do
-      before do
-        sign_out @user
+    context 'サインインの状態が例外的なとき' do
+      it 'ユーザではなく管理者でも通常通り応答する' do
         sign_in @admin
+        return_ok_at_get :play, id: @item_id
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-      it 'ステータスコード200 OKを返す' do
-        get :play, :id => @scroll.id
-        response.should be_success 
+      it '創作活動してないROM専の読者にも通常通り応答する' do
+        sign_in @user_rom
+        return_ok_at_get :play, id: @item_id
+        return_ok_at_get :play, id: @item_id, format: :json
       end
-    end
-    context 'ユーザだが作家登録していないとき' do
-      before do
-        @author.destroy
-      end
-      it 'ステータスコード200 OKを返す' do
-        get :play, :id => @scroll.id
-        response.should be_success 
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :play, id: @item_id
       end
     end
   end
-
-  describe 'スクロール数取得に於いて' do
+  
+  describe '新規作成フォーム表示に於いて' do
     before do
-      Scroll.should_receive(:visible_count).and_return(3)
-#      sign_in @user
+      @item = @author_yas.scrolls.first
+      @item_id = @item.id
     end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :count, :format => :json
-        response.should be_success 
+    context '正常系の共通処理' do
+      before do
+        sign_in @user_yas
       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構造になっていてスクロール数が1である' do
-          get :count, :format => :json
-          json = JSON.parse response.body
-          json["count"].should == 3
-        end
+      it '[html, json]でステータス OKを返す' do
+        return_ok_at_get :new
+        return_ok_at_get :new, format: :json
       end
-    end
-  end
-
-  describe '新規作成フォーム表示に於いて' do
-    before do
-      sign_in @user
-    end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
+      it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
         get :new
-        response.should be_success 
+        expect(assigns(:my_model_class)).to be Scroll
       end
-      it '@scrollに新規データを用意している' do
+      it '@itemに新規データを用意している' do
         get :new
-        assigns(:scroll).should be_a_new(Scroll)
+        expect(assigns(:item)).to eq(@item)
       end
-      it 'スクロールモデルにデフォルト値補充を依頼している' do
-        Scroll.any_instance.should_receive(:supply_default).exactly(1)
+      it '@formに入力フォーム(Bucket)を取得している' do
+        get :new
+        expect(assigns(:form).item).to eq(@item)
+        expect(assigns(:form).mounted).to eq(true)
+        expect(assigns(:form).submit).to eq(true)
+      end
+      it 'スクロールモデルにデフォルト値補充とブーストを依頼している' do
+        expect_any_instance_of(Scroll).to receive(:supply_default)
+        expect_any_instance_of(Scroll).to receive(:boosts)
         get :new
       end
       context 'html形式' do
-        it 'newテンプレートを描画する' do
+        it 'formテンプレートを描画する' 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")
+          expect(response).to render_template("templates/r/form/form")
         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
-          Scroll.should_receive(:show_json_opt).exactly(1)
-          get :new, :format => :json
+          get :new, format: :json
+          expect {JSON.parse(response.body)}.not_to raise_error
         end
       end
     end
-    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84とき' do
+    context 'ã\82µã\82¤ã\83³ã\82¤ã\83³ã\81®ç\8a¶æ\85\8bã\81\8cä¾\8bå¤\96ç\9a\84ã\81ªとき' do
       before do
-        sign_out @user
+        sign_in @user_rom
       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
+      it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
+        get :new
+        expect(response.status).to eq(302)
+        expect(response).to redirect_to new_author_path
+        return_ok_at_get :play, id: @item_id, format: :json
       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
+      it 'ゲスト(サインインしていない)はサインインページに遷移する' do
+        announce_sign_in_at_get :new, id: @item_id
       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
+      it 'ユーザではなく管理者でもサインインページに遷移する' do
         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
+        announce_sign_in_at_get :new, id: @item_id
       end
     end
     context 'ユーザだが作家登録していないとき' do
@@ -524,7 +307,7 @@ if MagicNumber['run_mode'] == 1
           get :new, @attr
           response.status.should eq 302
         end
-        it '作家登録ページへ遷移する' do
+        it '' do
           get :new, @attr
           response.body.should redirect_to new_author_path
         end
@@ -555,7 +338,7 @@ if MagicNumber['run_mode'] == 1
         post :create, :scroll => @attr
       end
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it "@scrollに作成されたスクロールを保持していて、それがDBにある" do
         post :create, :scroll => @attr
         assigns(:scroll).should be_a(Scroll)
@@ -684,7 +467,7 @@ if MagicNumber['run_mode'] == 1
       sign_in @user
       Scroll.stub(:edit).and_return(@scroll)
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :edit, :id => @scroll.id
         response.should be_success 
@@ -798,7 +581,7 @@ if MagicNumber['run_mode'] == 1
         assigns(:scroll).id.should eq(@scroll.id)
       end
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it '更新される' do
         put :update, :id => @scroll.id, :scroll => @attr
         Scroll.find(@scroll.id).visible.should eq 0
@@ -930,7 +713,7 @@ if MagicNumber['run_mode'] == 1
         assigns(:scroll).id.should eq(@scroll.id)
       end
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it '削除される' do
         lambda {
           delete :destroy, :id => @scroll.id
@@ -1049,7 +832,7 @@ else
       Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :index
         response.should be_success 
@@ -1096,7 +879,7 @@ else
       Scroll.stub(:show).and_return(@scroll)
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :show, :id => @scroll.id
         response.should be_success
@@ -1141,7 +924,7 @@ else
       Scroll.should_receive(:visible_count).and_return(3)
       sign_out @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :count, :format => :json
         response.should be_success 
@@ -1159,7 +942,7 @@ else
     before do
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :new
         response.should be_success 
@@ -1225,7 +1008,7 @@ else
       sign_in @user
       @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'normal')
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
           Scroll.any_instance.stub(:save).and_return(true)
@@ -1283,7 +1066,7 @@ else
       sign_in @user
       Scroll.stub(:edit).and_return(@scroll)
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       it 'ステータスコード200 OKを返す' do
         get :edit, :id => @scroll.id
         response.should be_success 
@@ -1334,7 +1117,7 @@ else
       @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'updated title', :visible => 0)
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       context 'html形式' do
         it 'ステータスコード302 Foundを返す' do
           Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
@@ -1381,7 +1164,7 @@ else
       @scroll = FactoryGirl.create :scroll, :author => @author
       sign_in @user
     end
-    context 'つつがなく終わるとき' do
+    context '正常系の共通処理' do
       context 'html形式' do
         before do
           Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)