1 # -*- encoding: utf-8 -*-
4 describe ScrollsController do
6 @admin =FactoryGirl.create :admin
7 @user_yas = FactoryGirl.create :user_yas_with_owner
8 @user_rom = FactoryGirl.create :user_rom
9 @author_yas = @user_yas.author
12 if Manifest.manifest.magic_numbers['run_mode'] == 1
13 describe '一覧表示に於いて' do
15 factory_contents :scroll_hello, @author_yas
22 it 'ステータス OKを返して、ファイラーまたはjsonデータを返す。' do
23 list_should_return_filer_or_json :index
25 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
27 expect(assigns(:my_model_class)).to be Scroll
29 it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
31 expect(assigns(:list).item_name).to eq('scroll')
32 expect(assigns(:list).list_name).to eq('public')
34 it '@itemsにリストを取得している' do
36 expect(assigns(:items).size).to be >= 3
39 it '@filerにファイラーを取得している' do
41 expect(assigns(:filer).class).to be Locmare::Filer
45 it '@filerにファイラーをセットしていない' do
46 get :index, format: :json
47 expect(assigns(:filer)).to be nil
56 return_ok_at_get :count, format: :json
61 expect(response.status).to eq(406)
66 get :count, format: :json
67 expect {JSON.parse(response.body)}.not_to raise_error
71 context 'サインインの状態が例外的なとき' do
72 it 'ユーザではなく管理者でも通常通り応答する' do
74 return_ok_at_get :index
75 return_ok_at_get :index, format: :json
77 it '創作活動してないROM専の読者にも通常通り応答する' do
79 return_ok_at_get :index
80 return_ok_at_get :index, format: :json
82 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
83 announce_sign_in_at_get :index
87 describe '作家フィルタ一覧及びカウント' do
89 factory_contents :scroll_hello, @author_yas
96 it 'ステータス OKを返して、ファイラーまたはjsonデータを返す。' do
97 list_should_return_filer_or_json :by_author, id: @author_yas.id
99 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
100 get :by_author, id: @author_yas.id
101 expect(assigns(:my_model_class)).to be Scroll
103 it 'リストグループのマニフェストから新着リストの取得処理を@listに取得している' do
104 get :by_author, id: @author_yas.id
105 expect(assigns(:list).item_name).to eq('scroll')
106 expect(assigns(:list).list_name).to eq('by_author')
108 it '@itemsにリストを取得している' do
109 get :by_author, id: @author_yas.id
110 expect(assigns(:items).size).to be >= 3
113 it '@filerにファイラーを取得している' do
114 get :by_author, id: @author_yas.id
115 expect(assigns(:filer).class).to be Locmare::Filer
119 it '@filerにファイラーをセットしていない' do
120 get :by_author, id: @author_yas.id, format: :json
121 expect(assigns(:filer)).to be nil
130 return_ok_at_get :count_by_author, id: @author_yas.id, format: :json
133 it '必要ないので実装していない' do
134 get :count_by_author, id: @author_yas.id
135 expect(response.status).to eq(406)
140 get :count_by_author, id: @author_yas.id, format: :json
141 expect {JSON.parse(response.body)}.not_to raise_error
145 context 'サインインの状態が例外的なとき' do
146 it 'ユーザではなく管理者でも通常通り応答する' do
148 return_ok_at_get :by_author, id: @author_yas.id
149 return_ok_at_get :by_author, id: @author_yas.id, format: :json
151 it '創作活動してないROM専の読者にも通常通り応答する' do
153 return_ok_at_get :by_author, id: @author_yas.id
154 return_ok_at_get :by_author, id: @author_yas.id, format: :json
156 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
157 announce_sign_in_at_get :by_author, id: @author_yas.id
162 describe '単体表示に於いて' do
164 @item = FactoryGirl.create :scroll_hello, author: @author_yas
167 context '正常系の共通処理' do
171 it '[html, json, prof]でステータスコード200 OKを返す' do
172 return_ok_at_get :show, id: @item_id
173 return_ok_at_get :show, id: @item_id, format: :json
174 return_ok_at_get :show, id: @item_id, format: :prof
176 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
177 get :show, id: @item_id
178 expect(assigns(:my_model_class)).to be Scroll
180 it '@itemにリクエストしたアイテムを取得している' do
181 get :show, id: @item_id
182 expect(assigns(:item)).to eq(@item)
185 it 'showテンプレートを描画する' do
186 get :show, id: @item_id
187 expect(response).to render_template("show")
192 get :show, id: @item_id, format: :json
193 expect {JSON.parse(response.body)}.not_to raise_error
195 it 'プロファイラーは必要ないので@profilerに用意していない' do
196 get :show, id: @item_id, format: :json
197 expect(assigns(:profiler)).to be nil
201 it 'プロファイラーテンプレートを描画する' do
202 get :show, id: @item_id, format: :prof
203 expect(response).to render_template("templates/r/profiler/profiler")
207 context 'サインインの状態が例外的なとき' do
208 it 'ユーザではなく管理者でも通常通り応答する' do
210 return_ok_at_get :show, id: @item_id
211 return_ok_at_get :show, id: @item_id, format: :json
213 it '創作活動してないROM専の読者にも通常通り応答する' do
215 return_ok_at_get :show, id: @item_id
216 return_ok_at_get :show, id: @item_id, format: :json
218 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
219 announce_sign_in_at_get :show, id: @item_id
224 describe 'プレイリストに於いて' do
226 @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
229 context '正常系の共通処理' do
233 it '[html, json]でステータス OKを返す' do
234 return_ok_at_get :play, id: @item_id
235 return_ok_at_get :play, id: @item_id, format: :json
237 it 'コントローラのマニフェストからScrollPanelモデルを@my_model_classに取得している' do
238 # リクエストの対象はスクロールであるが、返されるのはスクコマのリストである。
240 get :play, id: @item_id
241 expect(assigns(:my_model_class)).to be ScrollPanel
243 it '@itemにリクエストしたスクロールを取得している' do
244 get :play, id: @item_id
245 expect(assigns(:item)).to eq(@item)
247 it 'リストグループのマニフェストからプレイリストの取得処理を@listに取得している' do
248 get :play, id: @item_id
249 expect(assigns(:list).item_name).to eq('scroll_panel')
250 expect(assigns(:list).list_name).to eq('play')
252 it '@itemsにプレイリストを取得している' do
253 get :play, id: @item_id
254 expect(assigns(:items).size).to be >= 3
255 expect(assigns(:count)).to be >= 3
256 expect(assigns(:pager)).not_to be nil
259 it 'playテンプレートを描画する' do
260 get :play, id: @item_id
261 expect(response).to render_template("play")
266 get :play, id: @item_id, format: :json
267 expect {JSON.parse(response.body)}.not_to raise_error
271 context 'サインインの状態が例外的なとき' do
272 it 'ユーザではなく管理者でも通常通り応答する' do
274 return_ok_at_get :play, id: @item_id
275 return_ok_at_get :play, id: @item_id, format: :json
277 it '創作活動してないROM専の読者にも通常通り応答する' do
279 return_ok_at_get :play, id: @item_id
280 return_ok_at_get :play, id: @item_id, format: :json
282 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
283 announce_sign_in_at_get :play, id: @item_id
288 describe '新規作成フォーム表示に於いて' do
291 context '正常系の共通処理' do
295 it '[html, json]でステータス OKを返す' do
296 return_ok_at_get :new
297 return_ok_at_get :new, format: :json
299 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
301 expect(assigns(:my_model_class)).to be Scroll
303 it '@itemに新規データを用意している' do
305 @item = assigns(:item)
306 expect(@item.is_a?(Scroll)).to be true
307 expect(@item.new_record?).to be true
309 it '@formに入力フォーム(Bucket)を取得している' do
311 @item = assigns(:item)
312 expect(assigns(:form).item).to eq(@item)
313 expect(assigns(:form).mounted).to eq(true)
314 expect(assigns(:form).submit).to eq(true)
316 it 'スクロールモデルにデフォルト値補充とブーストを依頼している' do
317 allow_any_instance_of(Scroll).to receive(:supply_default)
318 allow_any_instance_of(Scroll).to receive(:boosts)
319 expect_any_instance_of(Scroll).to receive(:supply_default)
320 expect_any_instance_of(Scroll).to receive(:boosts)
324 it 'formテンプレートを描画する' do
326 expect(response).to render_template("templates/r/form/form")
331 get :new, format: :json
332 expect {JSON.parse(response.body)}.not_to raise_error
336 context 'サインインの状態が例外的なとき' do
339 it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
342 announce_regist_author_for_html
343 announce_regist_author_for_json :get
345 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
346 announce_sign_in_at_get :new
348 it 'ユーザではなく管理者でもサインインページに遷移する' do
350 announce_sign_in_at_get :new
355 describe '新規作成に於いて' do
357 @attributes = FactoryGirl.attributes_for(:scroll_hello, author_id: @author_yas.id)
358 @attr = {:scroll => @attributes}
360 context '正常系の共通処理' do
364 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
367 expect(assigns(:my_model_class)).to be Scroll
369 it '@itemに新規アイテムを用意している' do
372 @item = assigns(:item)
373 expect(@item.is_a?(Scroll)).to be true
376 it 'ステータスコード302 Foundを返して, 作成されたアイテムの表示ページへ遷移する' do
378 expect(response.status).to eq(302)
379 expect(response).to redirect_to Scroll.last
383 it 'ステータスコード200 OKを返して, 作成されたアイテムをjsonデータで返す' do
384 post_save @attr.merge(:format => :json)
385 expect(response).to be_success
386 expect {JSON.parse(response.body)}.not_to raise_error
390 context '検証、保存に失敗したとき' do
396 it 'ステータスコード200 OKを返して, formテンプレートを描画する' do
398 expect(response).to be_success
399 expect(response).to render_template("templates/r/form/form")
401 it '@formに入力フォーム(Bucket)を取得している' do
403 @item = assigns(:item)
404 expect(assigns(:form).item).to eq(@item)
405 expect(assigns(:form).mounted).to eq(true)
406 expect(assigns(:form).submit).to eq(true)
410 it 'ステータスコード422 unprocessable_entityを返して, 応答メッセージUnprocessable Entityを返す' do
411 post_save @attr.merge(:format => :json)
412 expect(response.status).to eq(422)
413 expect(response.message).to match(/Unprocessable/)
417 context 'サインインの状態が例外的なとき' do
421 it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
424 announce_regist_author_for_html
425 announce_regist_author_for_json :post, @attr
427 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
429 announce_sign_in_for_html
430 post_save @attr.merge(:format => :json)
431 announce_sign_in_for_json
433 it 'ユーザではなく管理者でもサインインページに遷移する' do
436 announce_sign_in_for_html
437 post_save @attr.merge(:format => :json)
438 announce_sign_in_for_json
443 describe '編集フォーム表示に於いて' do
445 @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
448 context '正常系の共通処理' do
452 it '[html, json]でステータス OKを返す' do
453 return_ok_at_get :edit, id: @item_id
454 return_ok_at_get :edit, id: @item_id, format: :json
456 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
457 get :edit, id: @item_id
458 expect(assigns(:my_model_class)).to be Scroll
460 it '@itemにリクエストしたスクロールを取得している' do
461 get :edit, id: @item_id
462 expect(assigns(:item).is_a?(Scroll)).to be true
463 expect(assigns(:item).new_record?).not_to be true
464 expect(assigns(:item)).to eq(@item)
466 it '@formに入力フォーム(Bucket)を取得している' do
467 get :edit, id: @item_id
468 @item = assigns(:item)
469 expect(assigns(:form).item).to eq(@item)
470 expect(assigns(:form).mounted).to eq(true)
471 expect(assigns(:form).submit).to eq(true)
473 it 'スクロールモデルにデフォルト値補充とブーストを依頼している' do
474 allow_any_instance_of(Scroll).to receive(:boosts)
475 expect_any_instance_of(Scroll).to receive(:boosts)
476 get :edit, id: @item_id
479 it 'formテンプレートを描画する' do
480 get :edit, id: @item_id
481 expect(response).to render_template("templates/r/form/form")
486 get :edit, id: @item_id, format: :json
487 expect {JSON.parse(response.body)}.not_to raise_error
491 context 'サインインの状態が例外的なとき' do
495 it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
497 get :edit, id: @item_id
498 expect(response.status).to eq(302)
499 expect(response).to redirect_to new_author_path
501 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
502 announce_sign_in_at_get :new
504 it 'ユーザではなく管理者でもサインインページに遷移する' do
506 announce_sign_in_at_get :new
513 @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
515 @attributes = FactoryGirl.attributes_for(:scroll_hidden, author_id: @author_yas.id)
516 @attr = {:id => @item_id, :scroll => @attributes}
518 context '正常系の共通処理' do
522 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
525 expect(assigns(:my_model_class)).to be Scroll
527 it '@itemにリクエストしたアイテムを取得して, 更新している' do
530 expect(assigns(:item).is_a?(Scroll)).to be true
531 expect(assigns(:item).visible).to eq(0)
532 expect(assigns(:item)).to eq(@item)
535 it 'ステータスコード302 Foundを返して, 作成されたアイテムの表示ページへ遷移する' do
537 expect(response.status).to eq(302)
538 expect(response).to redirect_to @item
542 it 'ステータスコード200 OKを返して, ページ本体は特に返さない' do
543 put_save @attr.merge(:format => :json)
544 expect(response).to be_success
545 expect(response.message).to match /./
549 context '検証、保存に失敗したとき' do
555 it 'ステータスコード200 OKを返して, formテンプレートを描画する' do
557 expect(response).to be_success
558 expect(response).to render_template("templates/r/form/form")
560 it '@formに入力フォーム(Bucket)を取得している' do
562 @item = assigns(:item)
563 expect(assigns(:form).item).to eq(@item)
564 expect(assigns(:form).mounted).to eq(true)
565 expect(assigns(:form).submit).to eq(true)
569 it 'ステータスコード422 unprocessable_entityを返して, 応答メッセージUnprocessable Entityを返す' do
570 put_save @attr.merge(:format => :json)
571 expect(response.status).to eq(422)
572 expect(response.message).to match(/Unprocessable/)
576 context 'サインインの状態が例外的なとき' do
580 it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
583 announce_regist_author_for_html
584 announce_regist_author_for_json :put, @attr
586 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
588 announce_sign_in_for_html
589 put_save @attr.merge(:format => :json)
590 announce_sign_in_for_json
592 it 'ユーザではなく管理者でもサインインページに遷移する' do
595 announce_sign_in_for_html
596 put_save @attr.merge(:format => :json)
597 announce_sign_in_for_json
604 @item = FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
606 @attr = {:id => @item_id}
607 @attr_with_json = @attr.merge(:format => :json)
609 context '正常系の共通処理' do
613 it 'コントローラのマニフェストからScrollモデルを@my_model_classに取得している' do
616 expect(assigns(:my_model_class)).to be Scroll
618 it '@itemにリクエストしたアイテムを取得している' do
621 expect(assigns(:item).is_a?(Scroll)).to be true
622 expect(assigns(:item)).to eq(@item)
627 }.should change Scroll, :count
629 it 'ぶら下がるリーフも削除されている' do
632 }.should change ScrollPanel, :count
635 it 'ステータスコード302 Foundを返して, マイスクロールの一覧ページへ遷移する' do
637 expect(response.status).to eq(302)
638 expect(response).to redirect_to '/home/scrolls'
642 it 'ステータスコード200 OKを返して, ページ本体は特に返さない' do
643 destroy_save @attr_with_json
644 expect(response).to be_success
645 expect(response.message).to match /./
649 context '検証、保存に失敗したとき' do
652 reject_destroy Scroll
655 it 'ステータスコード302 Foundを返して, そのスクロールの詳細ページへ遷移する' do
657 expect(response.status).to eq(302)
658 expect(response).to redirect_to @item
662 it 'ステータスコード422 unprocessable_entityを返して, 応答メッセージUnprocessable Entityを返す' do
663 destroy_save @attr_with_json
664 expect(response.status).to eq(422)
665 expect(response.message).to match(/Unprocessable/)
669 context 'サインインの状態が例外的なとき' do
673 it '創作活動してないROM専の読者には作家登録ページへ遷移する' do
676 announce_regist_author_for_html
677 announce_regist_author_for_json :delete, @attr_with_json
679 it 'ゲスト(サインインしていない)はサインインページに遷移する' do
681 announce_sign_in_for_html
682 destroy_save @attr_with_json
683 announce_sign_in_for_json
685 it 'ユーザではなく管理者でもサインインページに遷移する' do
687 destroy_save id: @item_id
688 announce_sign_in_for_html
689 destroy_save @attr_with_json
690 announce_sign_in_for_json
696 describe '一覧表示に於いて' do
698 @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
699 Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
702 context '正常系の共通処理' do
703 it 'ステータスコード200 OKを返す' do
705 response.should be_success
708 it 'indexテンプレートを描画する' do
710 response.should render_template("index")
715 get :index, :format => :json
716 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
720 context 'ユーザ権限がないとき' do
724 it 'ステータスコード200 OKを返す' do
726 response.should be_success
729 it 'indexテンプレートを描画する' do
731 response.should render_template("index")
736 get :index, :format => :json
737 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
743 describe '単体表示に於いて' do
745 @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id, :title => 'normal'
746 Scroll.stub(:show).and_return(@scroll)
749 context '正常系の共通処理' do
750 it 'ステータスコード200 OKを返す' do
751 get :show, :id => @scroll.id
752 response.should be_success
755 it 'showテンプレートを描画する' do
756 get :show, :id => @scroll.id
757 response.should render_template("show")
762 get :show, :id => @scroll.id, :format => :json
763 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
767 context 'ユーザ権限がないとき' do
771 it 'ステータスコード200 OKを返す' do
772 get :show, :id => @scroll.id
773 response.should be_success
776 it 'showテンプレートを描画する' do
777 get :show, :id => @scroll.id
778 response.should render_template("show")
783 get :show, :id => @scroll.id, :format => :json
784 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
789 describe 'スクロール数取得に於いて' do
791 Scroll.should_receive(:visible_count).and_return(3)
794 context '正常系の共通処理' do
795 it 'ステータスコード200 OKを返す' do
796 get :count, :format => :json
797 response.should be_success
801 get :count, :format => :json
802 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
808 describe '新規作成フォーム表示に於いて' do
812 context '正常系の共通処理' do
813 it 'ステータスコード200 OKを返す' do
815 response.should be_success
818 it 'newテンプレートを描画する' do
820 response.should render_template("new")
824 it 'new.jsテンプレートを描画する' do
825 get :new, :format => :js
826 response.should render_template("new")
831 get :new, :format => :json
832 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
836 context 'ユーザ権限がないとき' do
841 it 'ステータスコード302 Foundを返す' do
843 response.status.should eq 302
845 it 'サインインページへ遷移する' do
847 response.body.should redirect_to '/users/sign_in'
851 it 'ステータスコード401 Unauthorizedを返す' do
852 get :new, :format => :js
853 response.status.should eq 401
855 it '応答メッセージにUnauthorizedを返す' do
856 get :new, :format => :js
857 response.message.should match(/Unauthorized/)
861 it 'ステータスコード401 Unauthorizedを返す' do
862 get :new, :format => :json
863 response.status.should eq 401
865 it '応答メッセージにUnauthorizedを返す' do
866 get :new, :format => :json
867 response.message.should match(/Unauthorized/)
873 describe '新規作成に於いて' do
876 @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'normal')
878 context '正常系の共通処理' do
880 it 'ステータスコード302 Foundを返す' do
881 Scroll.any_instance.stub(:save).and_return(true)
882 post :create, :scroll => @attr
883 response.status.should eq 302
885 it '作成されたスクロールの表示ページへ遷移する' do
886 # Scroll.any_instance.stub(:save).and_return(true)
887 post :create, :scroll => @attr
888 response.should redirect_to(Scroll.last)
892 it 'ステータスコード200 OKを返す' do
893 # Scroll.any_instance.stub(:save).and_return(true)
894 post :create, :scroll => @attr, :format => :json
895 response.should be_success
897 it '作成されたスクロールをjsonデータで返す' do
898 post :create, :scroll => @attr, :format => :json
899 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
903 context 'ユーザ権限がないとき' do
908 it 'ステータスコード302 Foundを返す' do
909 post :create, :scroll => @attr
910 response.status.should eq 302
912 it 'サインインページへ遷移する' do
913 post :create, :scroll => @attr
914 response.body.should redirect_to '/users/sign_in'
918 it 'ステータスコード401 Unauthorizedを返す' do
919 post :create, :scroll => @attr, :format => :json
920 response.status.should eq 401
922 it '応答メッセージにUnauthorizedを返す' do
923 post :create, :scroll => @attr, :format => :json
924 response.message.should match(/Unauthorized/)
930 describe '編集フォーム表示に於いて' do
932 @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
934 Scroll.stub(:edit).and_return(@scroll)
936 context '正常系の共通処理' do
937 it 'ステータスコード200 OKを返す' do
938 get :edit, :id => @scroll.id
939 response.should be_success
942 it 'editテンプレートを描画する' do
943 get :edit, :id => @scroll.id
944 response.should render_template("edit")
948 it 'edit.jsテンプレートを描画する' do
949 get :edit, :id => @scroll.id, :format => :js
950 response.should render_template("edit")
954 context 'ユーザ権限がないとき' do
959 it 'ステータスコード302 Foundを返す' do
960 get :edit, :id => @scroll.id
961 response.status.should eq 302
963 it 'サインインページへ遷移する' do
964 get :edit, :id => @scroll.id
965 response.body.should redirect_to '/users/sign_in'
969 it 'ステータスコード401 Unauthorizedを返す' do
970 get :edit, :id => @scroll.id, :format => :js
971 response.status.should eq 401
973 it '応答メッセージにUnauthorizedを返す' do
974 get :edit, :id => @scroll.id, :format => :js
975 response.message.should match(/Unauthorized/)
983 @scroll = FactoryGirl.create :scroll, :author => @author
984 @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'updated title', :visible => 0)
987 context '正常系の共通処理' do
989 it 'ステータスコード302 Foundを返す' do
990 Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
991 put :update, :id => @scroll.id, :scroll => @attr
992 response.status.should eq 302
994 it '更新されたスクロールの表示ページへ遷移する' do
995 put :update, :id => @scroll.id, :scroll => @attr
996 response.should redirect_to(@scroll)
1000 it 'ステータスコード200 OKを返す' do
1001 Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
1002 put :update, :id => @scroll.id, :scroll => @attr, :format => :json
1003 response.should be_success
1005 it 'ページ本体は特に返さない' do
1006 Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
1007 put :update, :id => @scroll.id, :scroll => @attr, :format => :json
1008 response.body.should match /./
1012 context 'ユーザ権限がないとき' do
1016 it 'ステータスコード302 Foundを返す' do
1017 put :update, :id => @scroll.id, :scroll => @attr
1018 response.status.should eq 302
1021 it 'サインインページへ遷移する' do
1022 put :update, :id => @scroll.id, :scroll => @attr
1023 response.body.should redirect_to '/users/sign_in'
1029 describe '削除に於いて' do
1031 @scroll = FactoryGirl.create :scroll, :author => @author
1034 context '正常系の共通処理' do
1037 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
1039 it 'ステータスコード302 Foundを返す' do
1040 delete :destroy, :id => @scroll.id
1041 response.status.should eq 302
1043 it 'マイスクロールの一覧ページへ遷移する' do
1044 delete :destroy, :id => @scroll.id
1045 response.should redirect_to('/home/scroll')
1050 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
1052 it 'ステータスコード200 OKを返す' do
1053 delete :destroy, :id => @scroll.id, :format => :json
1054 response.should be_success
1056 it 'ページ本体は特に返さない' do
1057 delete :destroy, :id => @scroll.id, :format => :json
1058 response.body.should match /./
1062 context 'ユーザ権限がないとき' do
1066 it 'ステータスコード302 Foundを返す' do
1067 delete :destroy, :id => @scroll.id
1068 response.status.should eq 302
1071 it 'サインインページへ遷移する' do
1072 delete :destroy, :id => @scroll.id
1073 response.body.should redirect_to '/users/sign_in'
1077 it '応答メッセージにUnauthorizedを返す' do
1078 delete :destroy, :id => @scroll.id, :format => :json
1079 response.message.should match(/Unauthorized/)