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 @item = assigns(:item)
463 expect(@item.is_a?(Scroll)).to be true
464 expect(@item.new_record?).not_to be true
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 @item = assigns(:item)
531 expect(@item.is_a?(Scroll)).to be true
532 expect(@item.visible).to eq(0)
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 @scroll = FactoryGirl.create :scroll, :author => @author
607 context '事前チェックしておく' do
609 Scroll.stub(:edit).with(any_args()).and_return @scroll
610 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
612 it 'スクロールモデルに編集取得を問い合わせている' do
613 Scroll.should_receive(:edit).exactly(1)
614 delete :destroy, :id => @scroll.id
617 Scroll.any_instance.should_receive(:destroy_with_scroll_panel).exactly(1)
618 delete :destroy, :id => @scroll.id
620 it '@scrollにアレを取得している' do
621 delete :destroy, :id => @scroll.id
622 assigns(:scroll).id.should eq(@scroll.id)
625 context '正常系の共通処理' do
628 delete :destroy, :id => @scroll.id
629 }.should change Scroll, :count
633 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
635 it 'ステータスコード302 Foundを返す' do
636 delete :destroy, :id => @scroll.id
637 response.status.should eq 302
639 it 'マイスクロールの一覧ページへ遷移する' do
640 delete :destroy, :id => @scroll.id
641 response.should redirect_to('/home/scrolls')
646 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
648 it 'ステータスコード200 OKを返す' do
649 delete :destroy, :id => @scroll.id, :format => :json
650 response.should be_success
653 delete :destroy, :id => @scroll.id, :format => :json
654 response.body.should match /./
658 context 'ユーザ権限がないとき' do
663 it 'ステータスコード302 Foundを返す' do
664 delete :destroy, :id => @scroll.id
665 response.status.should eq 302
667 it 'サインインページへ遷移する' do
668 delete :destroy, :id => @scroll.id
669 response.body.should redirect_to '/users/sign_in'
673 it '応答メッセージにUnauthorizedを返す' do
674 delete :destroy, :id => @scroll.id, :format => :json
675 response.message.should match(/Unauthorized/)
679 context 'ユーザ権限はないが管理者権限があるとき' do
685 it 'ステータスコード302 Foundを返す' do
686 delete :destroy, :id => @scroll.id
687 response.status.should eq 302
689 it 'サインインページへ遷移する' do
690 delete :destroy, :id => @scroll.id
691 response.body.should redirect_to '/users/sign_in'
695 context 'ユーザだが作家登録していないとき' do
700 it 'ステータスコード302 Foundを返す' do
701 delete :destroy, :id => @scroll.id
702 response.status.should eq 302
705 delete :destroy, :id => @scroll.id
706 response.body.should redirect_to new_author_path
710 context '削除に失敗したとき' do
712 Scroll.any_instance.stub(:destroy_with_scroll_panel).and_return(false)
715 it 'ステータスコード302 Foundを返す' do
716 delete :destroy, :id => @scroll.id
717 response.status.should eq 302
719 it 'そのスクロールの詳細ページへ遷移する' do
720 delete :destroy, :id => @scroll.id
721 response.should redirect_to(scroll_path(@scroll))
725 it 'ステータスコード422 unprocessable_entity を返す' do
726 delete :destroy, :id => @scroll.id, :format => :json
727 response.status.should eq 422
729 it '応答メッセージUnprocessable Entityを返す' do
730 delete :destroy, :id => @scroll.id, :format => :json
731 response.message.should match(/Unprocessable/)
738 describe '一覧表示に於いて' do
740 @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
741 Scroll.stub(:list).and_return([@scroll, @scroll, @scroll])
744 context '正常系の共通処理' do
745 it 'ステータスコード200 OKを返す' do
747 response.should be_success
750 it 'indexテンプレートを描画する' do
752 response.should render_template("index")
757 get :index, :format => :json
758 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
762 context 'ユーザ権限がないとき' do
766 it 'ステータスコード200 OKを返す' do
768 response.should be_success
771 it 'indexテンプレートを描画する' do
773 response.should render_template("index")
778 get :index, :format => :json
779 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
785 describe '単体表示に於いて' do
787 @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id, :title => 'normal'
788 Scroll.stub(:show).and_return(@scroll)
791 context '正常系の共通処理' do
792 it 'ステータスコード200 OKを返す' do
793 get :show, :id => @scroll.id
794 response.should be_success
797 it 'showテンプレートを描画する' do
798 get :show, :id => @scroll.id
799 response.should render_template("show")
804 get :show, :id => @scroll.id, :format => :json
805 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
809 context 'ユーザ権限がないとき' do
813 it 'ステータスコード200 OKを返す' do
814 get :show, :id => @scroll.id
815 response.should be_success
818 it 'showテンプレートを描画する' do
819 get :show, :id => @scroll.id
820 response.should render_template("show")
825 get :show, :id => @scroll.id, :format => :json
826 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
831 describe 'スクロール数取得に於いて' do
833 Scroll.should_receive(:visible_count).and_return(3)
836 context '正常系の共通処理' do
837 it 'ステータスコード200 OKを返す' do
838 get :count, :format => :json
839 response.should be_success
843 get :count, :format => :json
844 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
850 describe '新規作成フォーム表示に於いて' do
854 context '正常系の共通処理' do
855 it 'ステータスコード200 OKを返す' do
857 response.should be_success
860 it 'newテンプレートを描画する' do
862 response.should render_template("new")
866 it 'new.jsテンプレートを描画する' do
867 get :new, :format => :js
868 response.should render_template("new")
873 get :new, :format => :json
874 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
878 context 'ユーザ権限がないとき' do
883 it 'ステータスコード302 Foundを返す' do
885 response.status.should eq 302
887 it 'サインインページへ遷移する' do
889 response.body.should redirect_to '/users/sign_in'
893 it 'ステータスコード401 Unauthorizedを返す' do
894 get :new, :format => :js
895 response.status.should eq 401
897 it '応答メッセージにUnauthorizedを返す' do
898 get :new, :format => :js
899 response.message.should match(/Unauthorized/)
903 it 'ステータスコード401 Unauthorizedを返す' do
904 get :new, :format => :json
905 response.status.should eq 401
907 it '応答メッセージにUnauthorizedを返す' do
908 get :new, :format => :json
909 response.message.should match(/Unauthorized/)
915 describe '新規作成に於いて' do
918 @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'normal')
920 context '正常系の共通処理' do
922 it 'ステータスコード302 Foundを返す' do
923 Scroll.any_instance.stub(:save).and_return(true)
924 post :create, :scroll => @attr
925 response.status.should eq 302
927 it '作成されたスクロールの表示ページへ遷移する' do
928 # Scroll.any_instance.stub(:save).and_return(true)
929 post :create, :scroll => @attr
930 response.should redirect_to(Scroll.last)
934 it 'ステータスコード200 OKを返す' do
935 # Scroll.any_instance.stub(:save).and_return(true)
936 post :create, :scroll => @attr, :format => :json
937 response.should be_success
939 it '作成されたスクロールをjsonデータで返す' do
940 post :create, :scroll => @attr, :format => :json
941 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
945 context 'ユーザ権限がないとき' do
950 it 'ステータスコード302 Foundを返す' do
951 post :create, :scroll => @attr
952 response.status.should eq 302
954 it 'サインインページへ遷移する' do
955 post :create, :scroll => @attr
956 response.body.should redirect_to '/users/sign_in'
960 it 'ステータスコード401 Unauthorizedを返す' do
961 post :create, :scroll => @attr, :format => :json
962 response.status.should eq 401
964 it '応答メッセージにUnauthorizedを返す' do
965 post :create, :scroll => @attr, :format => :json
966 response.message.should match(/Unauthorized/)
972 describe '編集フォーム表示に於いて' do
974 @scroll = FactoryGirl.create :scroll, :author_id => @user.author.id
976 Scroll.stub(:edit).and_return(@scroll)
978 context '正常系の共通処理' do
979 it 'ステータスコード200 OKを返す' do
980 get :edit, :id => @scroll.id
981 response.should be_success
984 it 'editテンプレートを描画する' do
985 get :edit, :id => @scroll.id
986 response.should render_template("edit")
990 it 'edit.jsテンプレートを描画する' do
991 get :edit, :id => @scroll.id, :format => :js
992 response.should render_template("edit")
996 context 'ユーザ権限がないとき' do
1001 it 'ステータスコード302 Foundを返す' do
1002 get :edit, :id => @scroll.id
1003 response.status.should eq 302
1005 it 'サインインページへ遷移する' do
1006 get :edit, :id => @scroll.id
1007 response.body.should redirect_to '/users/sign_in'
1011 it 'ステータスコード401 Unauthorizedを返す' do
1012 get :edit, :id => @scroll.id, :format => :js
1013 response.status.should eq 401
1015 it '応答メッセージにUnauthorizedを返す' do
1016 get :edit, :id => @scroll.id, :format => :js
1017 response.message.should match(/Unauthorized/)
1023 describe '更新に於いて' do
1025 @scroll = FactoryGirl.create :scroll, :author => @author
1026 @attr = FactoryGirl.attributes_for(:scroll, :author_id => @author.id, :title => 'updated title', :visible => 0)
1029 context '正常系の共通処理' do
1031 it 'ステータスコード302 Foundを返す' do
1032 Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
1033 put :update, :id => @scroll.id, :scroll => @attr
1034 response.status.should eq 302
1036 it '更新されたスクロールの表示ページへ遷移する' do
1037 put :update, :id => @scroll.id, :scroll => @attr
1038 response.should redirect_to(@scroll)
1042 it 'ステータスコード200 OKを返す' do
1043 Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
1044 put :update, :id => @scroll.id, :scroll => @attr, :format => :json
1045 response.should be_success
1047 it 'ページ本体は特に返さない' do
1048 Scroll.any_instance.stub(:save).with(any_args()).and_return(true)
1049 put :update, :id => @scroll.id, :scroll => @attr, :format => :json
1050 response.body.should match /./
1054 context 'ユーザ権限がないとき' do
1058 it 'ステータスコード302 Foundを返す' do
1059 put :update, :id => @scroll.id, :scroll => @attr
1060 response.status.should eq 302
1063 it 'サインインページへ遷移する' do
1064 put :update, :id => @scroll.id, :scroll => @attr
1065 response.body.should redirect_to '/users/sign_in'
1071 describe '削除に於いて' do
1073 @scroll = FactoryGirl.create :scroll, :author => @author
1076 context '正常系の共通処理' do
1079 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
1081 it 'ステータスコード302 Foundを返す' do
1082 delete :destroy, :id => @scroll.id
1083 response.status.should eq 302
1085 it 'マイスクロールの一覧ページへ遷移する' do
1086 delete :destroy, :id => @scroll.id
1087 response.should redirect_to('/home/scroll')
1092 Scroll.any_instance.stub(:destroy_with_scroll_panel).with(any_args()).and_return(true)
1094 it 'ステータスコード200 OKを返す' do
1095 delete :destroy, :id => @scroll.id, :format => :json
1096 response.should be_success
1098 it 'ページ本体は特に返さない' do
1099 delete :destroy, :id => @scroll.id, :format => :json
1100 response.body.should match /./
1104 context 'ユーザ権限がないとき' do
1108 it 'ステータスコード302 Foundを返す' do
1109 delete :destroy, :id => @scroll.id
1110 response.status.should eq 302
1113 it 'サインインページへ遷移する' do
1114 delete :destroy, :id => @scroll.id
1115 response.body.should redirect_to '/users/sign_in'
1119 it '応答メッセージにUnauthorizedを返す' do
1120 delete :destroy, :id => @scroll.id, :format => :json
1121 response.message.should match(/Unauthorized/)