OSDN Git Service

t#32046:
[pettanr/pettanr.git] / spec / controllers / scroll_panels_controller_spec.rb
index 2a4db41..5c1495e 100644 (file)
@@ -1,6 +1,6 @@
 # -*- encoding: utf-8 -*-
 require 'spec_helper'
-#ã\82¹ã\83\88ã\83¼ã\83ªã\83¼
+#ã\82¹ã\82¯ã\82³ã\83\9e
 describe ScrollPanelsController do
   before do
     @admin = FactoryGirl.create :admin
@@ -51,7 +51,7 @@ if MagicNumber['run_mode'] == 1
         get :index
         response.should be_success 
       end
-      it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼モデルに一覧を問い合わせている' do
+      it 'ã\82¹ã\82¯ã\82³ã\83\9eモデルに一覧を問い合わせている' do
         ScrollPanel.should_receive(:list).exactly(1)
         get :index
       end
@@ -74,7 +74,7 @@ if MagicNumber['run_mode'] == 1
           get :index, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼モデルにjson一覧出力オプションを問い合わせている' do
+        it 'ã\82¹ã\82¯ã\82³ã\83\9eモデルにjson一覧出力オプションを問い合わせている' do
           ScrollPanel.should_receive(:list_json_opt).exactly(1)
           get :index, :format => :json
         end
@@ -83,7 +83,7 @@ if MagicNumber['run_mode'] == 1
           json = JSON.parse response.body
           json.should have_at_least(3).items
         end
-        it 'ã\83ªã\82¹ã\83\88ã\81®å\85\88é ­ã\81\8fã\82\89ã\81\84ã\81¯ã\82¹ã\83\88ã\83¼ã\83ªã\83¼っぽいものであって欲しい' do
+        it 'ã\83ªã\82¹ã\83\88ã\81®å\85\88é ­ã\81\8fã\82\89ã\81\84ã\81¯ã\82¹ã\82¯ã\82³ã\83\9eっぽいものであって欲しい' do
           get :index, :format => :json
           json = JSON.parse response.body
           json.first.has_key?("panel_id").should be_true
@@ -148,7 +148,7 @@ if MagicNumber['run_mode'] == 1
       ScrollPanel.stub(:show).with(@scroll_panel.id.to_s, [nil, @admin]).and_return(@scroll_panel)
     end
     context 'つつがなく終わるとき' do
-      it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼モデルに単体取得を問い合わせている' do
+      it 'ã\82¹ã\82¯ã\82³ã\83\9eモデルに単体取得を問い合わせている' do
         ScrollPanel.should_receive(:show).with(@scroll_panel.id.to_s, [@user, nil]).exactly(1)
         get :show, :id => @scroll_panel.id
       end
@@ -175,7 +175,7 @@ if MagicNumber['run_mode'] == 1
           get :show, :id => @scroll_panel.id, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼ã\83¢ã\83\87ã\83«ã\81«ã\82¹ã\83\88ã\83¼ã\83ªã\83¼json出力を問い合わせている' do
+        it 'ã\82¹ã\82¯ã\82³ã\83\9eã\83¢ã\83\87ã\83«ã\81«ã\82¹ã\82¯ã\82³ã\83\9ejson出力を問い合わせている' do
           ScrollPanel.any_instance.should_receive(:scroll_panel_as_json).exactly(1)
           get :show, :id => @scroll_panel.id, :format => :json
         end
@@ -234,139 +234,6 @@ if MagicNumber['run_mode'] == 1
     end
   end
   
-  describe '閲覧に於いて' do
-    before do
-      @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
-    end
-    context 'パラメータチェックする' do
-      it '与えられたoffsetがセットされている' do
-        get :scroll, :id => @scroll.id, :offset => 5
-        assigns(:offset).should eq 5
-      end
-      it '省略されると@offsetに0値が入る' do
-        get :scroll, :id => @scroll.id
-        assigns(:offset).should eq 0
-      end
-      it '与えられたcountがセットされている' do
-        get :scroll, :id => @scroll.id, :count => 4
-        assigns(:panel_count).should eq 4
-      end
-      it '省略されると@panel_countにデフォルト値が入る' do
-        get :scroll, :id => @scroll.id
-        assigns(:panel_count).should eq ScrollPanel.default_panel_size
-      end
-      it '最大を超えると@panel_countにデフォルト最大値が入る' do
-        get :scroll, :id => @scroll.id, :count => 1500
-        assigns(:panel_count).should eq ScrollPanel.max_panel_size
-      end
-      it '不正な値が入ると@panel_countにデフォルト最大値が入る' do
-        get :scroll, :id => @scroll.id, :count => -1
-        assigns(:panel_count).should eq ScrollPanel.default_panel_size
-      end
-    end
-    context '事前チェックする' do
-      it 'コミックモデルに単体取得を問い合わせている' do
-        Scroll.should_receive(:show).with(@scroll.id.to_s, [@user, nil]).exactly(1)
-        get :scroll, :id => @scroll.id
-      end
-      it 'ストーリーモデルにプレイリスト取得を問い合わせている' do
-        ScrollPanel.should_receive(:play_list).with(@scroll, @author, 0, 30).exactly(1)
-        get :scroll, :id => @scroll.id
-      end
-    end
-    context 'つつがなく終わるとき' do
-      it '@scroll_panelsにリストを取得している' do
-        get :scroll, :id => @scroll.id
-        assigns(:scroll_panels).should have_at_least(3).items
-      end
-      context 'html形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :scroll, :id => @scroll.id
-          response.should be_success 
-        end
-        it 'scrollテンプレートを描画する' do
-          get :scroll, :id => @scroll.id
-          response.should render_template("scroll")
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード200 OKを返す' do
-          get :scroll, :id => @scroll.id, :format => :json
-          response.should be_success 
-        end
-        it 'jsonデータを返す' do
-          get :scroll, :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 :scroll, :id => @scroll.id, :format => :json
-        end
-        it 'データがリスト構造になっている' do
-          get :scroll, :id => @scroll.id, :format => :json
-          json = JSON.parse response.body
-          json.should have_at_least(3).items
-        end
-        it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
-          get :scroll, :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 :scroll, :id => @scroll.id
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :scroll, :id => @scroll.id
-          response.should redirect_to '/users/sign_in'
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :scroll, :id => @scroll.id, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :scroll, :id => @scroll.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, :id => @scroll.id
-        response.should be_success 
-      end
-    end
-    context 'ユーザだが作家登録していないとき' do
-      before do
-        @author.destroy
-      end
-      it 'ステータスコード200 OKを返す' do
-        get :scroll, :id => @scroll.id
-        response.should be_success 
-      end
-    end
-  end
-
   describe '新規作成フォーム表示に於いて' do
     before do
       sign_in @user
@@ -409,7 +276,7 @@ if MagicNumber['run_mode'] == 1
           get :new, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼ã\83¢ã\83\87ã\83«ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼のjson出力を問い合わせている' do
+        it 'ã\82¹ã\82¯ã\82³ã\83\9eã\83¢ã\83\87ã\83«ã\81®ã\82¹ã\82¯ã\82³ã\83\9eのjson出力を問い合わせている' do
           ScrollPanel.any_instance.should_receive(:scroll_panel_as_json).exactly(1)
           get :new, :format => :json
         end
@@ -500,7 +367,8 @@ if MagicNumber['run_mode'] == 1
         ScrollPanel.any_instance.should_receive(:overwrite).exactly(1)
         post :create, :scroll_panel => @attr
       end
-      it 'コミックモデルに編集取得を依頼している' do
+      it 'スクロールモデルに編集取得を依頼している' do
+        Scroll.stub(:edit).and_return(@scroll)
         Scroll.should_receive(:edit).with(@scroll.id, @author).exactly(1)
         post :create, :scroll_panel => @attr
       end
@@ -523,10 +391,10 @@ if MagicNumber['run_mode'] == 1
           post :create, :scroll_panel => @attr
           response.status.should eq 302
         end
-        it 'ã\82³ã\83\9fã\83\83ã\82¯ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼表示へ遷移する' do
+        it 'ã\82¹ã\82¯ã\83­ã\83¼ã\83«ã\81®ã\82¹ã\82¯ã\82³ã\83\9e表示へ遷移する' do
 #          ScrollPanel.any_instance.stub(:store).and_return(true)
           post :create, :scroll_panel => @attr
-          response.should redirect_to(:action => :scroll, :id => @attr[:scroll_id])
+          response.should redirect_to(play_scroll_path(@attr[:scroll_id]))
         end
       end
       context 'json形式' do
@@ -539,7 +407,7 @@ if MagicNumber['run_mode'] == 1
           post :create, :scroll_panel => @attr, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼ã\83¢ã\83\87ã\83«ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼のjson出力を問い合わせている' do
+        it 'ã\82¹ã\82¯ã\82³ã\83\9eã\83¢ã\83\87ã\83«ã\81®ã\82¹ã\82¯ã\82³ã\83\9eのjson出力を問い合わせている' do
           ScrollPanel.any_instance.should_receive(:scroll_panel_as_json).exactly(1)
           post :create, :scroll_panel => @attr, :format => :json
         end
@@ -644,7 +512,7 @@ if MagicNumber['run_mode'] == 1
       ScrollPanel.stub(:show).and_return(@scroll_panel)
     end
     context 'つつがなく終わるとき' do
-      it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼モデルに編集取得を問い合わせている' do
+      it 'ã\82¹ã\82¯ã\82³ã\83\9eモデルに編集取得を問い合わせている' do
         ScrollPanel.should_receive(:edit).exactly(1)
         get :edit, :id => @scroll_panel.id
       end
@@ -756,7 +624,7 @@ if MagicNumber['run_mode'] == 1
         ScrollPanel.any_instance.should_receive(:store).exactly(1)
         put :update, :id => @scroll_panel.id, :scroll_panel => @attr
       end
-      it "@scroll_panelã\81«ä½\9cæ\88\90ã\81\95ã\82\8cã\81\9fã\82¹ã\83\88ã\83¼ã\83ªã\83¼を保持していて、それがDBにある" do
+      it "@scroll_panelã\81«ä½\9cæ\88\90ã\81\95ã\82\8cã\81\9fã\82¹ã\82¯ã\82³ã\83\9eを保持していて、それがDBにある" do
         put :update, :id => @scroll_panel.id, :scroll_panel => @attr
         assigns(:scroll_panel).should be_a(ScrollPanel)
         assigns(:scroll_panel).should be_persisted
@@ -767,10 +635,10 @@ if MagicNumber['run_mode'] == 1
           put :update, :id => @scroll_panel.id, :scroll_panel => @attr
           response.status.should eq 302
         end
-        it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼表示へ遷移する' do
+        it 'ã\82¹ã\82¯ã\82³ã\83\9e表示へ遷移する' do
 #          ScrollPanel.any_instance.stub(:store).and_return(true)
           put :update, :id => @scroll_panel.id, :scroll_panel => @attr
-          response.should redirect_to(:action => :scroll, :id => @attr[:scroll_id])
+          response.should redirect_to(play_scroll_path(@attr[:scroll_id]))
         end
       end
       context 'json形式' do
@@ -879,7 +747,7 @@ if MagicNumber['run_mode'] == 1
         ScrollPanel.stub(:edit).with(any_args()).and_return @scroll_panel
         ScrollPanel.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true)
       end
-      it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼モデルに編集取得を問い合わせている' do
+      it 'ã\82¹ã\82¯ã\82³ã\83\9eモデルに編集取得を問い合わせている' do
         ScrollPanel.should_receive(:edit).exactly(1)
         delete :destroy, :id => @scroll_panel.id
       end
@@ -903,7 +771,7 @@ if MagicNumber['run_mode'] == 1
         end
         it '閲覧ページへ遷移する' do
           delete :destroy, :id => @scroll_panel.id
-          response.should redirect_to(:controller => 'scroll_panels', :action => :scroll, :id => @scroll_panel.scroll_id)
+          response.should redirect_to(play_scroll_path(@scroll_panel.scroll_id) )
         end
       end
       context 'json形式' do
@@ -978,7 +846,7 @@ if MagicNumber['run_mode'] == 1
           delete :destroy, :id => @scroll_panel.id
           response.status.should eq 302
         end
-        it 'ã\81\9dã\81®ã\82³ã\83\9fã\83\83ã\82¯の詳細ページへ遷移する' do
+        it 'ã\81\9dã\81®ã\82¹ã\82¯ã\83­ã\83¼ã\83«の詳細ページへ遷移する' do
           delete :destroy, :id => @scroll_panel.id
           response.should redirect_to(scroll_panel_path(@scroll_panel))
         end
@@ -995,9 +863,9 @@ if MagicNumber['run_mode'] == 1
       end
     end
 =begin
-    context '対象ã\82¹ã\83\88ã\83¼ã\83ªã\83¼がないとき' do
+    context '対象ã\82¹ã\82¯ã\82³ã\83\9eがないとき' do
     end
-    context 'ä»\96人ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼だったとき' do
+    context 'ä»\96人ã\81®ã\82¹ã\82¯ã\82³ã\83\9eだったとき' do
     end
 =end
   end
@@ -1244,7 +1112,7 @@ else
           post :create, :scroll_panel => @attr
           response.status.should eq 302
         end
-        it 'ã\82³ã\83\9fã\83\83ã\82¯ã\81®ã\82¹ã\83\88ã\83¼ã\83ªã\83¼表示へ遷移する' do
+        it 'ã\82¹ã\82¯ã\83­ã\83¼ã\83«ã\81®ã\82¹ã\82¯ã\82³ã\83\9e表示へ遷移する' do
 #          ScrollPanel.any_instance.stub(:store).and_return(true)
           post :create, :scroll_panel => @attr
           response.should redirect_to(:action => :scroll, :id => @attr[:scroll_id])
@@ -1357,7 +1225,7 @@ else
           put :update, :id => @scroll_panel.id, :scroll_panel => @attr
           response.status.should eq 302
         end
-        it 'ã\82¹ã\83\88ã\83¼ã\83ªã\83¼表示へ遷移する' do
+        it 'ã\82¹ã\82¯ã\82³ã\83\9e表示へ遷移する' do
 #          ScrollPanel.any_instance.stub(:store).and_return(true)
           put :update, :id => @scroll_panel.id, :scroll_panel => @attr
           response.should redirect_to(:action => :scroll, :id => @attr[:scroll_id])