1 # -*- encoding: utf-8 -*-
5 describe OriginalPicturesController do
7 @admin = FactoryGirl.create :admin
8 @user = FactoryGirl.create( :user_yas)
9 @author = FactoryGirl.create :author, :user_id => @user.id
10 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
11 @sp = FactoryGirl.create :system_picture
12 @lg = FactoryGirl.create :license_group
13 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
16 describe '一覧表示に於いて' do
18 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
20 OriginalPicture.stub(:mylist).and_return([@op, @op, @op])
22 context 'パラメータpageについて' do
24 get :index, :page => 5
25 assigns(:page).should eq 5
27 it '省略されると@pageに1値が入る' do
29 assigns(:page).should eq 1
31 it '与えられたpage_sizeがセットされている' do
32 get :index, :page_size => 15
33 assigns(:page_size).should eq 15
35 it '省略されると@page_sizeにデフォルト値が入る' do
37 assigns(:page_size).should eq OriginalPicture.default_page_size
39 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
40 get :index, :page_size => 1500
41 assigns(:page_size).should eq OriginalPicture.max_page_size
43 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
44 get :index, :page_size => 0
45 assigns(:page_size).should eq OriginalPicture.default_page_size
48 context 'つつがなく終わるとき' do
49 it 'ステータスコード200 OKを返す' do
51 response.should be_success
53 it '原画モデルにマイリストを問い合わせている' do
54 OriginalPicture.should_receive(:mylist).exactly(1)
57 it '@original_picturesにリストを取得している' do
59 assigns(:original_pictures).should have_at_least(3).items
62 it 'indexテンプレートを描画する' do
64 response.should render_template("index")
69 get :index, :format => :json
70 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
72 it '原画モデルにjson一覧出力オプションを問い合わせている' do
73 OriginalPicture.should_receive(:list_json_opt).exactly(1)
74 get :index, :format => :json
76 it 'データがリスト構造になっている' do
77 get :index, :format => :json
78 json = JSON.parse response.body
79 json.should have_at_least(3).items
81 it 'リストの先頭くらいは原画っぽいものであって欲しい' do
82 get :index, :format => :json
83 json = JSON.parse response.body
84 json.first.has_key?("ext").should be_true
85 json.first.has_key?("md5").should be_true
86 json.first.has_key?("artist_id").should be_true
87 json.first.has_key?("width").should be_true
91 context '作家権限がないとき' do
96 it 'ステータスコード302 Foundを返す' do
98 response.status.should eq 302
100 it 'サインインページへ遷移する' do
102 response.should redirect_to '/users/sign_in'
106 it 'ステータスコード401 Unauthorizedを返す' do
107 get :index, :format => :json
108 response.status.should eq 401
110 it '応答メッセージにUnauthorizedを返す' do
111 get :index, :format => :json
112 response.message.should match(/Unauthorized/)
116 context '作家が絵師でないとき' do
118 Author.any_instance.stub(:artist?).and_return(false)
121 it 'ステータスコード302 Foundを返す' do
123 response.status.should eq 302
127 response.should redirect_to new_artist_path
131 it '例外403 forbiddenを返す' do
133 get :index, :format => :json
134 }.should raise_error(ActiveRecord::Forbidden)
140 describe '単体表示に於いて' do
142 @pic = FactoryGirl.create :original_picture, :artist_id => @artist.id
144 OriginalPicture.stub(:show).and_return(@pic)
146 context 'つつがなく終わるとき' do
147 it 'ステータスコード200 OKを返す' do
148 get :show, :id => @pic.id
149 response.should be_success
151 it '原画モデルに単体取得を問い合わせている' do
152 OriginalPicture.should_receive(:show).exactly(1)
155 it '@original_pictureにアレを取得している' do
156 get :show, :id => @pic.id
157 assigns(:original_picture).id.should eq(@pic.id)
160 it 'showテンプレートを描画する' do
161 get :show, :id => @pic.id
162 response.should render_template("show")
167 get :show, :id => @pic.id, :format => :json
168 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
170 it '原画モデルにjson単体出力オプションを問い合わせている' do
171 OriginalPicture.should_receive(:show_json_opt).exactly(1)
172 get :show, :id => @pic.id, :format => :json
175 get :show, :id => @pic.id, :format => :json
176 json = JSON.parse response.body
177 json["ext"].should match(/png/)
178 json["md5"].should be_true
179 json["artist_id"].should be_true
180 json["width"].should be_true
183 #画像送信では、send_dataにスタブをおいてテストしたいが、ここに噛ませると
184 #renderが働かず、エラーとなってしまう。そこで、原画のファイル取得部分に
185 #スタブをおいてsend_dataがデータを返す体裁でテストする。
188 OriginalPicture.any_instance.stub(:mime_type).and_return('image/png')
189 OriginalPicture.any_instance.stub(:restore).and_return('aaa')
191 it '画像モデルに画像データを問い合わせる' do
192 OriginalPicture.any_instance.should_receive(:restore).exactly(1)
193 get :show, :id => @pic.id, :format => :png
195 it '画像モデルにMimeTypeを問い合わせる' do
196 OriginalPicture.any_instance.should_receive(:mime_type).exactly(1)
197 get :show, :id => @pic.id, :format => :png
200 get :show, :id => @pic.id, :format => :png
201 response.body.should eq 'aaa'
206 OriginalPicture.any_instance.stub(:mime_type).and_return('image/gif')
207 OriginalPicture.any_instance.stub(:restore).and_return('bbb')
209 it '画像モデルに画像データを問い合わせる' do
210 OriginalPicture.any_instance.should_receive(:restore).exactly(1)
211 get :show, :id => @pic.id, :format => :gif
213 it '画像モデルにMimeTypeを問い合わせる' do
214 OriginalPicture.any_instance.should_receive(:mime_type).exactly(1)
215 get :show, :id => @pic.id, :format => :gif
218 get :show, :id => @pic.id, :format => :gif
219 response.body.should eq 'bbb'
224 OriginalPicture.any_instance.stub(:mime_type).and_return('image/jpeg')
225 OriginalPicture.any_instance.stub(:restore).and_return('ccc')
227 it '画像モデルに画像データを問い合わせる' do
228 OriginalPicture.any_instance.should_receive(:restore).exactly(1)
229 get :show, :id => @pic.id, :format => :jpeg
231 it '画像モデルにMimeTypeを問い合わせる' do
232 OriginalPicture.any_instance.should_receive(:mime_type).exactly(1)
233 get :show, :id => @pic.id, :format => :jpeg
236 get :show, :id => @pic.id, :format => :jpeg
237 response.body.should eq 'ccc'
241 context '作家権限がないとき' do
246 it 'ステータスコード302 Foundを返す' do
247 get :show, :id => @pic.id
248 response.status.should eq 302
250 it 'サインインページへ遷移する' do
251 get :show, :id => @pic.id
252 response.body.should redirect_to '/users/sign_in'
256 it 'ステータスコード401 Unauthorizedを返す' do
257 get :show, :id => @pic.id, :format => :json
258 response.status.should eq 401
260 it '応答メッセージにUnauthorizedを返す' do
261 get :show, :id => @pic.id, :format => :json
262 response.message.should match(/Unauthorized/)
266 context '作家が絵師でないとき' do
268 Author.any_instance.stub(:artist?).and_return(false)
271 it 'ステータスコード302 Foundを返す' do
272 get :show, :id => @pic.id
273 response.status.should eq 302
276 get :show, :id => @pic.id
277 response.should redirect_to new_artist_path
281 it '例外403 forbiddenを返す' do
283 get :show, :id => @pic.id, :format => :json
284 }.should raise_error(ActiveRecord::Forbidden)
289 context '対象原画がないとき' do
291 OriginalPicture.unstub(:show)
294 it '例外404 not_foundを返す' do
297 }.should raise_error(ActiveRecord::RecordNotFound)
301 it '例外404 not_foundを返す' do
303 get :show, :id => 0, :format => :json
304 }.should raise_error(ActiveRecord::RecordNotFound)
308 context '他人の原画を見ようとしたとき' do
310 OriginalPicture.stub(:show).and_return(@pic)
311 OriginalPicture.any_instance.stub(:own?).with(any_args()).and_return(false)
314 it '例外403 forbiddenを返す' do
316 get :show, :id => @pic.id
317 }.should raise_error(ActiveRecord::Forbidden)
321 it '例外403 forbiddenを返す' do
323 get :show, :id => @pic.id, :format => :json
324 }.should raise_error(ActiveRecord::Forbidden)
331 describe '履歴一覧表示に於いて' do
333 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
334 @p = FactoryGirl.create :picture, :artist_id => @artist.id, :license_id => @license.id, :revision => 0,
335 :original_picture_id => @op.id
337 OriginalPicture.stub(:show).and_return(@op)
338 OriginalPicture.any_instance.stub(:history).and_return([@p, @p, @p])
340 context 'つつがなく終わるとき' do
341 it 'ステータスコード200 OKを返す' do
342 get :history, :id => @op.id
343 response.should be_success
345 it '原画モデルに単体取得を問い合わせている' do
346 OriginalPicture.should_receive(:show).exactly(1)
347 get :history, :id => @op.id
349 it '自身に履歴一覧を問い合わせている' do
350 OriginalPicture.any_instance.should_receive(:history).exactly(1)
351 get :history, :id => @op.id
353 it '@historyにリストを取得している' do
354 get :history, :id => @op.id
355 assigns(:history).should have_at_least(3).items
358 it 'historyテンプレートを描画する' do
359 get :history, :id => @op.id
360 response.should render_template("history")
365 get :history, :id => @op.id, :format => :json
366 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
368 it 'データがリスト構造になっている' do
369 get :history, :id => @op.id, :format => :json
370 json = JSON.parse response.body
371 json.should have_at_least(3).items
373 it 'リストの先頭くらいは原画っぽいものであって欲しい' do
374 get :history, :id => @op.id, :format => :json
375 json = JSON.parse response.body
376 json.first.has_key?("ext").should be_true
380 context '作家権限がないとき' do
385 it 'ステータスコード302 Foundを返す' do
386 get :history, :id => @op.id
387 response.status.should eq 302
389 it 'サインインページへ遷移する' do
390 get :history, :id => @op.id
391 response.should redirect_to '/users/sign_in'
395 it 'ステータスコード401 Unauthorizedを返す' do
396 get :history, :id => @op.id, :format => :json
397 response.status.should eq 401
399 it '応答メッセージにUnauthorizedを返す' do
400 get :history, :id => @op.id, :format => :json
401 response.message.should match(/Unauthorized/)
405 context '作家が絵師でないとき' do
407 Author.any_instance.stub(:artist?).and_return(false)
410 it 'ステータスコード302 Foundを返す' do
411 get :history, :id => @op.id
412 response.status.should eq 302
415 get :history, :id => @op.id
416 response.should redirect_to new_artist_path
420 it '例外403 forbiddenを返す' do
422 get :history, :id => @op.id, :format => :json
423 }.should raise_error(ActiveRecord::Forbidden)
429 describe '新規作成フォーム表示に於いて' do
433 context 'つつがなく終わるとき' do
434 it '@original_pictureに新規データを用意している' do
436 assigns(:original_picture).should be_a_new(OriginalPicture)
438 it '原画モデルにデフォルト値補充を依頼している' do
439 OriginalPicture.any_instance.should_receive(:supply_default).exactly(1)
443 it 'ステータスコード200 OKを返す' do
445 response.should be_success
447 it 'ページテンプレートnewを描画する' do
449 response.should render_template("new")
453 it 'ステータスコード200 OKを返す' do
454 get :new, :format => :js
455 response.should be_success
457 it '部分テンプレートnew.jsを描画する' do
458 get :new, :format => :js
459 response.should render_template("new")
464 get :new, :format => :json
465 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
467 it '原画モデルにjson単体出力オプションを問い合わせている' do
468 OriginalPicture.should_receive(:show_json_opt).exactly(1)
469 get :new, :format => :json
473 context '作家権限がないとき' do
478 it 'ステータスコード302 Foundを返す' do
480 response.status.should eq 302
482 it 'サインインページへ遷移する' do
484 response.body.should redirect_to '/users/sign_in'
488 it 'ステータスコード401 Unauthorizedを返す' do
489 get :new, :format => :js
490 response.status.should eq 401
492 it '応答メッセージにUnauthorizedを返す' do
493 get :new, :format => :js
494 response.message.should match(/Unauthorized/)
498 context '作家が絵師でないとき' do
500 Author.any_instance.stub(:artist?).and_return(false)
503 it 'ステータスコード302 Foundを返す' do
505 response.status.should eq 302
509 response.should redirect_to new_artist_path
513 it 'ステータスコード200 Okを返す' do
514 get :new, :format => :js
515 response.status.should eq 200
517 it '絵師登録部分テンプレートartists/new.jsを描画する' do
518 get :new, :format => :js
519 response.should render_template("artists/new")
523 it '例外403 forbiddenを返す' do
525 get :new, :format => :json
526 }.should raise_error(ActiveRecord::Forbidden)
532 describe '新規作成に於いて' do
535 @attr = {:original_picture => {:file => "abc\ndef\nghi"}}
536 @imager = ImagerTest.load("abc\ndef\nghi")
537 OriginalPicturesController.any_instance.stub(:set_image).with(any_args()).and_return("abc\ndef\nghi")
539 context '事前チェックしておく' do
541 PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
542 OriginalPicture.any_instance.stub(:store).with(@imager).and_return(true)
544 it '画像ライブラリをロードする' do
545 PettanImager.should_receive(:load).with(any_args()).exactly(1)
548 it '原画モデルにデフォルト値補充を依頼している' do
549 OriginalPicture.any_instance.should_receive(:supply_default).with(any_args()).exactly(1)
552 it '原画モデルに上書き補充を依頼している' do
553 OriginalPicture.any_instance.should_receive(:overwrite).with(@artist).exactly(1)
557 OriginalPicture.any_instance.should_receive(:store).with(@imager).exactly(1)
561 context 'つつがなく終わるとき' do
563 PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
565 it "@original_pictureに作成された原画を保持している" do
567 assigns(:original_picture).should be_a(OriginalPicture)
570 it 'ステータスコード302 Foundを返す' do
572 response.status.should eq 302
574 it '作成された原画の表示ページへ遷移する' do
576 response.should redirect_to(OriginalPicture.last)
581 @attr.merge!({:format => :json})
583 it 'ステータスコード200 OKを返す' do
585 response.should be_success
587 it '作成された原画をjsonデータで返す' do
589 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
591 it '原画モデルにjson単体出力オプションを問い合わせている' do
592 OriginalPicture.should_receive(:show_json_opt).exactly(1)
597 json = JSON.parse response.body
598 json["ext"].should match(/png/)
599 json["md5"].should be_true
600 json["artist_id"].should be_true
601 json["width"].should be_true
605 context '作家権限がないとき' do
610 it 'ステータスコード302 Foundを返す' do
612 response.status.should eq 302
614 it 'サインインページへ遷移する' do
616 response.body.should redirect_to '/users/sign_in'
621 @attr.merge!({:format => :json})
623 it 'ステータスコード401 Unauthorizedを返す' do
625 response.status.should eq 401
627 it '応答メッセージにUnauthorizedを返す' do
629 response.message.should match(/Unauthorized/)
633 context '作家が絵師でないとき' do
635 Author.any_instance.stub(:artist?).and_return(false)
638 it 'ステータスコード302 Foundを返す' do
640 response.status.should eq 302
644 response.should redirect_to new_artist_path
649 @attr.merge!({:format => :json})
651 it '例外403 forbiddenを返す' do
654 }.should raise_error(ActiveRecord::Forbidden)
658 context '検証、保存に失敗した' do
660 PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
661 OriginalPicture.any_instance.stub(:store).with(@imager).and_return(false)
663 it "未保存の原画を保持している" do
665 assigns(:original_picture).should be_a_new(OriginalPicture)
668 it 'ステータスコード200 OKを返す' do
670 response.status.should eq 200
674 response.should render_template("new")
679 @attr.merge!({:format => :json})
681 it 'ステータスコード422 unprocessable_entity を返す' do
683 response.status.should eq 422
685 it '応答メッセージUnprocessable Entityを返す' do
687 response.message.should match(/Unprocessable/)
693 describe '編集フォーム表示に於いて' do
695 @pic = FactoryGirl.create :original_picture, :artist_id => @artist.id
697 OriginalPicture.stub(:show).and_return(@pic)
699 context 'つつがなく終わるとき' do
700 it 'ステータスコード200 OKを返す' do
701 get :edit, :id => @pic.id
702 response.should be_success
704 it '原画モデルに編集取得を問い合わせている' do
705 OriginalPicture.should_receive(:edit).exactly(1)
706 get :edit, :id => @pic.id
708 it '@original_pictureにデータを用意している' do
709 get :edit, :id => @pic.id
710 assigns(:original_picture).should eq @pic
713 it 'ページテンプレートeditを描画する' do
714 get :edit, :id => @pic.id
715 response.should render_template("edit")
719 it '部分テンプレートedit.jsを描画する' do
720 get :edit, :id => @pic.id, :format => :js
721 response.should render_template("edit")
725 context '作家権限がないとき' do
730 it 'ステータスコード302 Foundを返す' do
731 get :edit, :id => @pic.id
732 response.status.should eq 302
734 it 'サインインページへ遷移する' do
735 get :edit, :id => @pic.id
736 response.body.should redirect_to '/users/sign_in'
740 it 'ステータスコード401 Unauthorizedを返す' do
741 get :edit, :id => @pic.id, :format => :js
742 response.status.should eq 401
744 it '応答メッセージにUnauthorizedを返す' do
745 get :edit, :id => @pic.id, :format => :js
746 response.message.should match(/Unauthorized/)
750 context '作家が絵師でないとき' do
752 Author.any_instance.stub(:artist?).and_return(false)
755 it 'ステータスコード302 Foundを返す' do
756 get :edit, :id => @pic.id
757 response.status.should eq 302
760 get :edit, :id => @pic.id
761 response.should redirect_to new_artist_path
765 it 'ステータスコード200 Okを返す' do
766 get :edit, :id => @pic.id, :format => :js
767 response.status.should eq 200
769 it '絵師登録部分テンプレートartists/new.jsを描画する' do
770 get :edit, :id => @pic.id, :format => :js
771 response.should render_template("artists/new")
779 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
780 OriginalPicture.stub(:edit).with(@op.id.to_s, @artist).and_return(@op)
781 OriginalPicturesController.any_instance.stub(:set_image).with(any_args()).and_return("abc\ndef\nghi")
783 @attr = {:file => "abc\ndef\nghi"}
784 @imager = ImagerTest.load("abc\ndef\nghi")
786 context '事前チェックしておく' do
788 PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
789 OriginalPicture.any_instance.stub(:store).with(@imager).and_return(true)
791 it '画像ライブラリをロードする' do
792 PettanImager.should_receive(:load).with(any_args()).exactly(1)
793 put :update, :id => @op.id, :original_picture => @attr
795 it '原画モデルに編集取得を問い合わせている' do
796 OriginalPicture.should_receive(:edit).with(@op.id.to_s, @artist).exactly(1)
797 put :update, :id => @op.id, :original_picture => @attr
799 it '原画モデルに上書き補充を依頼している' do
800 OriginalPicture.any_instance.should_receive(:overwrite).with(@artist).exactly(1)
801 put :update, :id => @op.id, :original_picture => @attr
804 OriginalPicture.any_instance.should_receive(:store).with(@imager).exactly(1)
805 put :update, :id => @op.id, :original_picture => @attr
808 context 'つつがなく終わるとき' do
810 PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
812 it '@original_pictureにアレを取得している' do
813 put :update, :id => @op.id, :original_picture => @attr
814 assigns(:original_picture).should eq(@op)
817 it 'ステータスコード302 Foundを返す' do
818 put :update, :id => @op.id, :original_picture => @attr
819 response.status.should eq 302
821 it '更新された原画の表示ページへ遷移する' do
822 put :update, :id => @op.id, :original_picture => @attr
823 response.should redirect_to(@pic)
827 it 'ステータスコード200 OKを返す' do
828 put :update, :id => @op.id, :original_picture => @attr, :format => :json
829 response.should be_success
832 put :update, :id => @op.id, :original_picture => @attr, :format => :json
833 response.body.should match /./
837 context '作家権限がないとき' do
842 it 'ステータスコード302 Foundを返す' do
843 put :update, :id => @op.id, :original_picture => @attr
844 response.status.should eq 302
846 it 'サインインページへ遷移する' do
847 put :update, :id => @op.id, :original_picture => @attr
848 response.body.should redirect_to '/users/sign_in'
852 it 'ステータスコード401 Unauthorizedを返す' do
853 put :update, :id => @op.id, :original_picture => @attr, :format => :json
854 response.status.should eq 401
856 it '応答メッセージにUnauthorizedを返す' do
857 put :update, :id => @op.id, :original_picture => @attr, :format => :json
858 response.message.should match(/Unauthorized/)
862 context '作家が絵師でないとき' do
864 Author.any_instance.stub(:artist?).and_return(false)
867 it 'ステータスコード302 Foundを返す' do
868 put :update, :id => @op.id, :original_picture => @attr
869 response.status.should eq 302
872 put :update, :id => @op.id, :original_picture => @attr
873 response.should redirect_to new_artist_path
877 it '例外403 forbiddenを返す' do
879 put :update, :id => @op.id, :original_picture => @attr, :format => :json
880 }.should raise_error(ActiveRecord::Forbidden)
884 context '検証、保存に失敗した' do
886 PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
887 OriginalPicture.any_instance.stub(:store).with(@imager).and_return(false)
890 it 'ステータスコード200 Okを返す' do
891 put :update, :id => @op.id, :original_picture => @attr
892 response.status.should eq 200
895 put :update, :id => @op.id, :original_picture => @attr
896 response.should render_template("edit")
900 it 'ステータスコード422 unprocessable_entity を返す' do
901 put :update, :id => @op.id, :original_picture => @attr, :format => :json
902 response.status.should eq 422
904 it '応答メッセージUnprocessable Entityを返す' do
905 put :update, :id => @op.id, :original_picture => @attr, :format => :json
906 response.message.should match(/Unprocessable/)
914 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
917 context '事前チェックしておく' do
919 OriginalPicture.stub(:edit).with(any_args()).and_return @op
920 OriginalPicture.any_instance.stub(:destroy_with_resource_picture).with(any_args()).and_return(true)
922 it '原画モデルに編集取得を問い合わせている' do
923 OriginalPicture.should_receive(:edit).exactly(1)
924 delete :destroy, :id => @op.id
927 OriginalPicture.any_instance.should_receive(:destroy_with_resource_picture).exactly(1)
928 delete :destroy, :id => @op.id
930 it '@original_pictureにアレを取得している' do
931 delete :destroy, :id => @op.id
932 assigns(:original_picture).id.should eq(@op.id)
935 context 'つつがなく終わるとき' do
937 OriginalPicture.any_instance.stub(:destroy_with_resource_picture).with(any_args()).and_return(true)
940 it 'ステータスコード302 Foundを返す' do
941 delete :destroy, :id => @op.id
942 response.status.should eq 302
944 it '原画の一覧ページへ遷移する' do
945 delete :destroy, :id => @op.id
946 response.should redirect_to(original_pictures_path)
950 it 'ステータスコード200 OKを返す' do
951 delete :destroy, :id => @op.id, :format => :json
952 response.should be_success
955 delete :destroy, :id => @op.id, :format => :json
956 response.body.should match /./
960 context '作家権限がないとき' do
964 it 'ステータスコード302 Foundを返す' do
965 delete :destroy, :id => @op.id
966 response.status.should eq 302
969 it 'サインインページへ遷移する' do
970 delete :destroy, :id => @op.id
971 response.body.should redirect_to '/users/sign_in'
975 it '応答メッセージにUnauthorizedを返す' do
976 delete :destroy, :id => @op.id, :format => :json
977 response.message.should match(/Unauthorized/)
981 context '削除に失敗したとき' do
983 OriginalPicture.any_instance.stub(:destroy_with_resource_picture).and_return(false)
986 it 'ステータスコード302 Foundを返す' do
987 delete :destroy, :id => @op.id
988 response.status.should eq 302
990 it 'その原画の詳細ページへ遷移する' do
991 delete :destroy, :id => @op.id
992 response.should redirect_to(original_picture_path(@op))
996 it 'ステータスコード422 unprocessable_entity を返す' do
997 delete :destroy, :id => @op.id, :format => :json
998 response.status.should eq 422
1000 it '応答メッセージUnprocessable Entityを返す' do
1001 delete :destroy, :id => @op.id, :format => :json
1002 response.message.should match(/Unprocessable/)