1 # -*- encoding: utf-8 -*-
5 describe HomeController do
7 @admin =FactoryGirl.create :admin
8 @sp = FactoryGirl.create :system_picture
9 @lg = FactoryGirl.create :license_group
10 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
11 @user = FactoryGirl.create( :user_yas)
12 @author = FactoryGirl.create :author, :user_id => @user.id
13 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
14 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
15 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
16 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
17 @panel = FactoryGirl.create :panel, :author_id => @author.id
20 if MagicNumber['run_mode'] == 1
21 describe '自分のコミック一覧表示に於いて' do
23 @comic = FactoryGirl.create :comic, :author_id => @author.id
25 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
27 context 'パラメータpageについて' do
29 get :comics, :page => 5
30 assigns(:page).should eq 5
32 it '省略されると@pageに1値が入る' do
34 assigns(:page).should eq 1
36 it '与えられたpage_sizeがセットされている' do
37 get :comics, :page_size => 15
38 assigns(:page_size).should eq 15
40 it '省略されると@page_sizeにデフォルト値が入る' do
42 assigns(:page_size).should eq Author.default_comic_page_size
44 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
45 get :comics, :page_size => 1500
46 assigns(:page_size).should eq Author.comic_max_page_size
48 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
49 get :comics, :page_size => 0
50 assigns(:page_size).should eq Author.default_comic_page_size
53 context 'つつがなく終わるとき' do
54 it 'ステータスコード200 OKを返す' do
56 response.should be_success
58 it 'コミックモデルに一覧を問い合わせている' do
59 Comic.should_receive(:mylist).exactly(1)
62 it '@comicsにリストを取得している' do
64 assigns(:comics).should have_at_least(3).items
67 it '@paginateにページ制御を取得している' do
69 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
71 it 'comicsテンプレートを描画する' do
73 response.should render_template("comics")
78 get :comics, :format => :json
79 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
81 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
82 Comic.should_receive(:list_json_opt).exactly(1)
83 get :comics, :format => :json
85 it 'データがリスト構造になっている' do
86 get :comics, :format => :json
87 json = JSON.parse response.body
88 json.should have_at_least(3).items
90 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
91 get :comics, :format => :json
92 json = JSON.parse response.body
93 json.first.has_key?("title").should be_true
94 json.first.has_key?("visible").should be_true
98 context '作家権限がないとき' do
103 it 'ステータスコード302 Foundを返す' do
105 response.status.should eq 302
107 it 'サインインページへ遷移する' do
109 response.should redirect_to '/users/sign_in'
113 it 'ステータスコード401 Unauthorizedを返す' do
114 get :comics, :format => :json
115 response.status.should eq 401
117 it '応答メッセージにUnauthorizedを返す' do
118 get :comics, :format => :json
119 response.message.should match(/Unauthorized/)
125 describe '自分のコマ一覧表示に於いて' do
127 @panel = FactoryGirl.create :panel, :author_id => @author.id
129 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
131 context 'パラメータpageについて' do
133 get :panels, :page => 5
134 assigns(:page).should eq 5
136 it '省略されると@pageに1値が入る' do
138 assigns(:page).should eq 1
140 it '与えられたpage_sizeがセットされている' do
141 get :panels, :page_size => 15
142 assigns(:page_size).should eq 15
144 it '省略されると@page_sizeにデフォルト値が入る' do
146 assigns(:page_size).should eq Author.default_panel_page_size
148 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
149 get :panels, :page_size => 1500
150 assigns(:page_size).should eq Author.panel_max_page_size
152 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
153 get :panels, :page_size => 0
154 assigns(:page_size).should eq Author.default_panel_page_size
157 context 'つつがなく終わるとき' do
158 it 'コマモデルに一覧を問い合わせている' do
159 Panel.should_receive(:mylist).exactly(1)
162 it '@panelsにリストを取得している' do
164 assigns(:panels).should have_at_least(3).items
167 it '@paginateにページ制御を取得している' do
169 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
171 it 'ステータスコード200 OKを返す' do
173 response.should be_success
175 it 'panelsテンプレートを描画する' do
177 response.should render_template("panels")
181 it 'ステータスコード200 OKを返す' do
182 get :panels, :format => :json
183 response.should be_success
186 get :panels, :format => :json
187 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
189 it 'コマモデルにコマリストのjson出力を問い合わせている' do
190 Panel.should_receive(:list_as_json_text).exactly(1)
191 get :panels, :format => :json
193 it 'データがリスト構造になっている' do
194 get :panels, :format => :json
195 json = JSON.parse response.body
196 json.should have_at_least(3).items
198 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
199 get :panels, :format => :json
200 json = JSON.parse response.body
201 json.first.has_key?("z").should be_true
205 context '作家権限がないとき' do
210 it 'ステータスコード302 Foundを返す' do
212 response.status.should eq 302
214 it 'サインインページへ遷移する' do
216 response.should redirect_to '/users/sign_in'
220 it 'ステータスコード401 Unauthorizedを返す' do
221 get :panels, :format => :json
222 response.status.should eq 401
224 it '応答メッセージにUnauthorizedを返す' do
225 get :panels, :format => :json
226 response.message.should match(/Unauthorized/)
232 describe '自分のコマ絵一覧表示に於いて' do
234 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
235 :width => @p.width, :height => @p.height
237 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
239 context 'パラメータpageについて' do
241 get :panel_pictures, :page => 5
242 assigns(:page).should eq 5
244 it '省略されると@pageに1値が入る' do
246 assigns(:page).should eq 1
248 it '与えられたpage_sizeがセットされている' do
249 get :panel_pictures, :page_size => 15
250 assigns(:page_size).should eq 15
252 it '省略されると@page_sizeにデフォルト値が入る' do
254 assigns(:page_size).should eq Author.default_panel_picture_page_size
256 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
257 get :panel_pictures, :page_size => 1500
258 assigns(:page_size).should eq Author.panel_picture_max_page_size
260 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
261 get :panel_pictures, :page_size => 0
262 assigns(:page_size).should eq Author.default_panel_picture_page_size
265 context 'つつがなく終わるとき' do
266 it 'ステータスコード200 OKを返す' do
267 response.should be_success
269 it 'コマ絵モデルに一覧を問い合わせている' do
270 PanelPicture.should_receive(:mylist).exactly(1)
273 it '@panel_picturesにリストを取得している' do
275 assigns(:panel_pictures).should have_at_least(3).items
278 it '@paginateにページ制御を取得している' do
280 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
282 it 'panel_picturesテンプレートを描画する' do
284 response.should render_template("panel_pictures")
289 get :panel_pictures, :format => :json
290 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
292 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
293 PanelPicture.should_receive(:list_json_opt).exactly(1)
294 get :panel_pictures, :format => :json
296 it 'データがリスト構造になっている' do
297 get :panel_pictures, :format => :json
298 json = JSON.parse response.body
299 json.should have_at_least(3).items
301 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
302 get :panel_pictures, :format => :json
303 json = JSON.parse response.body
304 json.first.has_key?("link").should be_true
305 json.first.has_key?("x").should be_true
306 json.first.has_key?("y").should be_true
310 context '作家権限がないとき' do
315 it 'ステータスコード302 Foundを返す' do
317 response.status.should eq 302
319 it 'サインインページへ遷移する' do
321 response.should redirect_to '/users/sign_in'
325 it 'ステータスコード401 Unauthorizedを返す' do
326 get :panel_pictures, :format => :json
327 response.status.should eq 401
329 it '応答メッセージにUnauthorizedを返す' do
330 get :panel_pictures, :format => :json
331 response.message.should match(/Unauthorized/)
337 describe '自分のコマの絵地一覧表示に於いて' do
339 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
341 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
343 context 'パラメータpageについて' do
345 get :ground_pictures, :page => 5
346 assigns(:page).should eq 5
348 it '省略されると@pageに1値が入る' do
350 assigns(:page).should eq 1
352 it '与えられたpage_sizeがセットされている' do
353 get :ground_pictures, :page_size => 15
354 assigns(:page_size).should eq 15
356 it '省略されると@page_sizeにデフォルト値が入る' do
358 assigns(:page_size).should eq Author.default_ground_picture_page_size
360 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
361 get :ground_pictures, :page_size => 1500
362 assigns(:page_size).should eq Author.ground_picture_max_page_size
364 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
365 get :ground_pictures, :page_size => 0
366 assigns(:page_size).should eq Author.default_ground_picture_page_size
369 context 'つつがなく終わるとき' do
370 it 'ステータスコード200 OKを返す' do
372 response.should be_success
374 it '絵地モデルに一覧を問い合わせている' do
375 GroundPicture.should_receive(:mylist).exactly(1)
378 it '@ground_picturesにリストを取得している' do
380 assigns(:ground_pictures).should have_at_least(3).items
383 it '@paginateにページ制御を取得している' do
385 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
387 it 'ground_picturesテンプレートを描画する' do
389 response.should render_template("ground_pictures")
394 get :ground_pictures, :format => :json
395 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
397 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
398 GroundPicture.should_receive(:list_json_opt).exactly(1)
399 get :ground_pictures, :format => :json
401 it 'データがリスト構造になっている' do
402 get :ground_pictures, :format => :json
403 json = JSON.parse response.body
404 json.should have_at_least(3).items
406 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
407 get :ground_pictures, :format => :json
408 json = JSON.parse response.body
409 json.first.has_key?("panel_id").should be_true
410 json.first.has_key?("picture_id").should be_true
411 json.first.has_key?("z").should be_true
415 context '作家権限がないとき' do
420 it 'ステータスコード302 Foundを返す' do
422 response.status.should eq 302
424 it 'サインインページへ遷移する' do
426 response.should redirect_to '/users/sign_in'
430 it 'ステータスコード401 Unauthorizedを返す' do
431 get :ground_pictures, :format => :json
432 response.status.should eq 401
434 it '応答メッセージにUnauthorizedを返す' do
435 get :ground_pictures, :format => :json
436 response.message.should match(/Unauthorized/)
442 describe '自分の色地一覧表示に於いて' do
444 @gc = FactoryGirl.create :ground_color
446 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
448 context 'パラメータpageについて' do
450 get :ground_colors, :page => 5
451 assigns(:page).should eq 5
453 it '省略されると@pageに1値が入る' do
455 assigns(:page).should eq 1
457 it '与えられたpage_sizeがセットされている' do
458 get :ground_colors, :page_size => 15
459 assigns(:page_size).should eq 15
461 it '省略されると@page_sizeにデフォルト値が入る' do
463 assigns(:page_size).should eq Author.default_ground_color_page_size
465 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
466 get :ground_colors, :page_size => 1500
467 assigns(:page_size).should eq Author.ground_color_max_page_size
469 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
470 get :ground_colors, :page_size => 0
471 assigns(:page_size).should eq Author.default_ground_color_page_size
474 context 'つつがなく終わるとき' do
475 it 'ステータスコード200 OKを返す' do
477 response.should be_success
479 it '色地モデルに一覧を問い合わせている' do
480 GroundColor.should_receive(:mylist).exactly(1)
483 it '@ground_colorsにリストを取得している' do
485 assigns(:ground_colors).should have_at_least(3).items
488 it '@paginateにページ制御を取得している' do
490 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
492 it 'ground_colorsテンプレートを描画する' do
494 response.should render_template("ground_colors")
499 get :ground_colors, :format => :json
500 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
502 it '色地モデルにjson一覧出力オプションを問い合わせている' do
503 GroundColor.should_receive(:list_json_opt).exactly(1)
504 get :ground_colors, :format => :json
506 it 'データがリスト構造になっている' do
507 get :ground_colors, :format => :json
508 json = JSON.parse response.body
509 json.should have_at_least(3).items
511 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
512 get :ground_colors, :format => :json
513 json = JSON.parse response.body
514 json.first.has_key?("panel_id").should be_true
515 json.first.has_key?("code").should be_true
516 json.first.has_key?("z").should be_true
520 context '作家権限がないとき' do
525 it 'ステータスコード302 Foundを返す' do
527 response.status.should eq 302
529 it 'サインインページへ遷移する' do
531 response.should redirect_to '/users/sign_in'
535 it 'ステータスコード401 Unauthorizedを返す' do
536 get :ground_colors, :format => :json
537 response.status.should eq 401
539 it '応答メッセージにUnauthorizedを返す' do
540 get :ground_colors, :format => :json
541 response.message.should match(/Unauthorized/)
547 describe '自分の素材一覧表示に於いて' do
549 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
550 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
551 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
553 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
555 context 'パラメータpageについて' do
557 get :resource_pictures, :page => 5
558 assigns(:page).should eq 5
560 it '省略されると@pageに1値が入る' do
561 get :resource_pictures
562 assigns(:page).should eq 1
564 it '与えられたpage_sizeがセットされている' do
565 get :resource_pictures, :page_size => 15
566 assigns(:page_size).should eq 15
568 it '省略されると@page_sizeにデフォルト値が入る' do
569 get :resource_pictures
570 assigns(:page_size).should eq Author.default_resource_picture_page_size
572 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
573 get :resource_pictures, :page_size => 1500
574 assigns(:page_size).should eq Author.resource_picture_max_page_size
576 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
577 get :resource_pictures, :page_size => 0
578 assigns(:page_size).should eq Author.default_resource_picture_page_size
581 context 'つつがなく終わるとき' do
582 it 'ステータスコード200 OKを返す' do
583 get :resource_pictures
584 response.should be_success
586 it '素材モデルに一覧を問い合わせている' do
587 ResourcePicture.should_receive(:mylist).exactly(1)
588 get :resource_pictures
590 it '@resource_picturesにリストを取得している' do
591 get :resource_pictures
592 assigns(:resource_pictures).should have_at_least(3).items
595 it '@paginateにページ制御を取得している' do
596 get :resource_pictures
597 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
599 it 'resource_picturesテンプレートを描画する' do
600 get :resource_pictures
601 response.should render_template("resource_pictures")
606 get :resource_pictures, :format => :json
607 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
609 it '素材モデルにjson一覧出力オプションを問い合わせている' do
610 ResourcePicture.should_receive(:list_json_opt).exactly(1)
611 get :resource_pictures, :format => :json
613 it 'データがリスト構造になっている' do
614 get :resource_pictures, :format => :json
615 json = JSON.parse response.body
616 json.should have_at_least(3).items
618 it 'リストの先頭くらいは素材っぽいものであって欲しい' do
619 get :resource_pictures, :format => :json
620 json = JSON.parse response.body
621 json.first.has_key?("original_picture_id").should be_true
622 json.first.has_key?("license_id").should be_true
626 context '作家権限がないとき' do
631 it 'ステータスコード302 Foundを返す' do
632 get :resource_pictures
633 response.status.should eq 302
635 it 'サインインページへ遷移する' do
636 get :resource_pictures
637 response.should redirect_to '/users/sign_in'
641 it 'ステータスコード401 Unauthorizedを返す' do
642 get :resource_pictures, :format => :json
643 response.status.should eq 401
645 it '応答メッセージにUnauthorizedを返す' do
646 get :resource_pictures, :format => :json
647 response.message.should match(/Unauthorized/)
651 context '作家が絵師でないとき' do
653 Author.any_instance.stub(:artist?).and_return(false)
656 it 'ステータスコード302 Foundを返す' do
657 get :resource_pictures
658 response.status.should eq 302
661 get :resource_pictures
662 response.should redirect_to new_artist_path
666 it '例外403 forbiddenを返す' do
668 get :resource_pictures, :format => :json
669 }.should raise_error(ActiveRecord::Forbidden)
676 describe '自分のコミック一覧表示に於いて' do
678 @comic = FactoryGirl.create :comic, :author_id => @author.id
680 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
682 context 'つつがなく終わるとき' do
683 it 'ステータスコード200 OKを返す' do
685 response.should be_success
688 it 'comicsテンプレートを描画する' do
690 response.should render_template("comics")
695 get :comics, :format => :json
696 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
700 context '作家権限がないとき' do
705 it 'ステータスコード302 Foundを返す' do
707 response.status.should eq 302
709 it 'サインインページへ遷移する' do
711 response.should redirect_to '/users/sign_in'
715 it 'ステータスコード401 Unauthorizedを返す' do
716 get :comics, :format => :json
717 response.status.should eq 401
719 it '応答メッセージにUnauthorizedを返す' do
720 get :comics, :format => :json
721 response.message.should match(/Unauthorized/)
727 describe '自分のコマ一覧表示に於いて' do
729 @panel = FactoryGirl.create :panel, :author_id => @author.id
731 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
733 context 'つつがなく終わるとき' do
735 it 'ステータスコード200 OKを返す' do
737 response.should be_success
739 it 'panelsテンプレートを描画する' do
741 response.should render_template("panels")
745 it 'ステータスコード200 OKを返す' do
746 get :panels, :format => :json
747 response.should be_success
750 get :panels, :format => :json
751 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
755 context '作家権限がないとき' do
760 it 'ステータスコード302 Foundを返す' do
762 response.status.should eq 302
764 it 'サインインページへ遷移する' do
766 response.should redirect_to '/users/sign_in'
770 it 'ステータスコード401 Unauthorizedを返す' do
771 get :panels, :format => :json
772 response.status.should eq 401
774 it '応答メッセージにUnauthorizedを返す' do
775 get :panels, :format => :json
776 response.message.should match(/Unauthorized/)
782 describe '自分のコマ絵一覧表示に於いて' do
784 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
785 :width => @p.width, :height => @p.height
787 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
789 context 'つつがなく終わるとき' do
790 it 'ステータスコード200 OKを返す' do
792 response.should be_success
795 it 'panel_picturesテンプレートを描画する' do
797 response.should render_template("panel_pictures")
802 get :panel_pictures, :format => :json
803 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
807 context '作家権限がないとき' do
812 it 'ステータスコード302 Foundを返す' do
814 response.status.should eq 302
816 it 'サインインページへ遷移する' do
818 response.should redirect_to '/users/sign_in'
822 it 'ステータスコード401 Unauthorizedを返す' do
823 get :panel_pictures, :format => :json
824 response.status.should eq 401
826 it '応答メッセージにUnauthorizedを返す' do
827 get :panel_pictures, :format => :json
828 response.message.should match(/Unauthorized/)
835 describe '自分のコマの絵地一覧表示に於いて' do
837 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
839 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
841 context 'つつがなく終わるとき' do
842 it 'ステータスコード200 OKを返す' do
844 response.should be_success
847 it 'ground_picturesテンプレートを描画する' do
849 response.should render_template("ground_pictures")
854 get :ground_pictures, :format => :json
855 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
859 context '作家権限がないとき' do
864 it 'ステータスコード302 Foundを返す' do
866 response.status.should eq 302
868 it 'サインインページへ遷移する' do
870 response.should redirect_to '/users/sign_in'
874 it 'ステータスコード401 Unauthorizedを返す' do
875 get :ground_pictures, :format => :json
876 response.status.should eq 401
878 it '応答メッセージにUnauthorizedを返す' do
879 get :ground_pictures, :format => :json
880 response.message.should match(/Unauthorized/)
886 describe '自分の色地一覧表示に於いて' do
888 @gc = FactoryGirl.create :ground_color
890 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
892 context 'つつがなく終わるとき' do
893 it 'ステータスコード200 OKを返す' do
895 response.should be_success
898 it 'ground_colorsテンプレートを描画する' do
900 response.should render_template("ground_colors")
905 get :ground_colors, :format => :json
906 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
910 context '作家権限がないとき' do
915 it 'ステータスコード302 Foundを返す' do
917 response.status.should eq 302
919 it 'サインインページへ遷移する' do
921 response.should redirect_to '/users/sign_in'
925 it 'ステータスコード401 Unauthorizedを返す' do
926 get :ground_colors, :format => :json
927 response.status.should eq 401
929 it '応答メッセージにUnauthorizedを返す' do
930 get :ground_colors, :format => :json
931 response.message.should match(/Unauthorized/)
937 describe '自分の素材一覧表示に於いて' do
939 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
940 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
941 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
943 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
945 context 'つつがなく終わるとき' do
946 it 'ステータスコード200 OKを返す' do
947 get :resource_pictures
948 response.should be_success
951 it 'resource_picturesテンプレートを描画する' do
952 get :resource_pictures
953 response.should render_template("resource_pictures")
958 get :resource_pictures, :format => :json
959 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
963 context '作家権限がないとき' do
968 it 'ステータスコード302 Foundを返す' do
969 get :resource_pictures
970 response.status.should eq 302
972 it 'サインインページへ遷移する' do
973 get :resource_pictures
974 response.should redirect_to '/users/sign_in'
978 it 'ステータスコード401 Unauthorizedを返す' do
979 get :resource_pictures, :format => :json
980 response.status.should eq 401
982 it '応答メッセージにUnauthorizedを返す' do
983 get :resource_pictures, :format => :json
984 response.message.should match(/Unauthorized/)
988 context '作家が絵師でないとき' do
993 it 'ステータスコード302 Foundを返す' do
994 get :resource_pictures
995 response.status.should eq 302
998 get :resource_pictures
999 response.should redirect_to new_artist_path
1003 it '例外403 forbiddenを返す' do
1005 get :resource_pictures, :format => :json
1006 }.should raise_error(ActiveRecord::Forbidden)