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 @speech_balloon_template = FactoryGirl.create :speech_balloon_template
12 @user = FactoryGirl.create( :user_yas)
13 @author = FactoryGirl.create :author, :user_id => @user.id
14 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
15 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
16 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
17 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
18 @panel = FactoryGirl.create :panel, :author_id => @author.id
21 if MagicNumber['run_mode'] == 1
22 describe '自分のコミック一覧表示に於いて' do
24 @comic = FactoryGirl.create :comic, :author_id => @author.id
26 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
28 context 'パラメータpageについて' do
30 get :comics, :page => 5
31 assigns(:page).should eq 5
33 it '省略されると@pageに1値が入る' do
35 assigns(:page).should eq 1
37 it '与えられたpage_sizeがセットされている' do
38 get :comics, :page_size => 15
39 assigns(:page_size).should eq 15
41 it '省略されると@page_sizeにデフォルト値が入る' do
43 assigns(:page_size).should eq Author.default_comic_page_size
45 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
46 get :comics, :page_size => 1500
47 assigns(:page_size).should eq Author.comic_max_page_size
49 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
50 get :comics, :page_size => 0
51 assigns(:page_size).should eq Author.default_comic_page_size
54 context 'つつがなく終わるとき' do
55 it 'ステータスコード200 OKを返す' do
57 response.should be_success
59 it 'コミックモデルに一覧を問い合わせている' do
60 Comic.should_receive(:mylist).exactly(1)
63 it '@comicsにリストを取得している' do
65 assigns(:comics).should have_at_least(3).items
68 it '@paginateにページ制御を取得している' do
70 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
72 it 'comicsテンプレートを描画する' do
74 response.should render_template("comics")
79 get :comics, :format => :json
80 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
82 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
83 Comic.should_receive(:list_json_opt).exactly(1)
84 get :comics, :format => :json
86 it 'データがリスト構造になっている' do
87 get :comics, :format => :json
88 json = JSON.parse response.body
89 json.should have_at_least(3).items
91 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
92 get :comics, :format => :json
93 json = JSON.parse response.body
94 json.first.has_key?("title").should be_true
95 json.first.has_key?("visible").should be_true
99 context '作家権限がないとき' do
104 it 'ステータスコード302 Foundを返す' do
106 response.status.should eq 302
108 it 'サインインページへ遷移する' do
110 response.should redirect_to '/users/sign_in'
114 it 'ステータスコード401 Unauthorizedを返す' do
115 get :comics, :format => :json
116 response.status.should eq 401
118 it '応答メッセージにUnauthorizedを返す' do
119 get :comics, :format => :json
120 response.message.should match(/Unauthorized/)
126 describe '自分のコマ一覧表示に於いて' do
128 @panel = FactoryGirl.create :panel, :author_id => @author.id
130 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
132 context 'パラメータpageについて' do
134 get :panels, :page => 5
135 assigns(:page).should eq 5
137 it '省略されると@pageに1値が入る' do
139 assigns(:page).should eq 1
141 it '与えられたpage_sizeがセットされている' do
142 get :panels, :page_size => 15
143 assigns(:page_size).should eq 15
145 it '省略されると@page_sizeにデフォルト値が入る' do
147 assigns(:page_size).should eq Author.default_panel_page_size
149 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
150 get :panels, :page_size => 1500
151 assigns(:page_size).should eq Author.panel_max_page_size
153 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
154 get :panels, :page_size => 0
155 assigns(:page_size).should eq Author.default_panel_page_size
158 context 'つつがなく終わるとき' do
159 it 'コマモデルに一覧を問い合わせている' do
160 Panel.should_receive(:mylist).exactly(1)
163 it '@panelsにリストを取得している' do
165 assigns(:panels).should have_at_least(3).items
168 it '@paginateにページ制御を取得している' do
170 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
172 it 'ステータスコード200 OKを返す' do
174 response.should be_success
176 it 'panelsテンプレートを描画する' do
178 response.should render_template("panels")
182 it 'ステータスコード200 OKを返す' do
183 get :panels, :format => :json
184 response.should be_success
187 get :panels, :format => :json
188 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
190 it 'コマモデルにコマリストのjson出力を問い合わせている' do
191 Panel.should_receive(:list_as_json_text).exactly(1)
192 get :panels, :format => :json
194 it 'データがリスト構造になっている' do
195 get :panels, :format => :json
196 json = JSON.parse response.body
197 json.should have_at_least(3).items
199 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
200 get :panels, :format => :json
201 json = JSON.parse response.body
202 json.first.has_key?("z").should be_true
206 context '作家権限がないとき' do
211 it 'ステータスコード302 Foundを返す' do
213 response.status.should eq 302
215 it 'サインインページへ遷移する' do
217 response.should redirect_to '/users/sign_in'
221 it 'ステータスコード401 Unauthorizedを返す' do
222 get :panels, :format => :json
223 response.status.should eq 401
225 it '応答メッセージにUnauthorizedを返す' do
226 get :panels, :format => :json
227 response.message.should match(/Unauthorized/)
233 describe '自分のコマ絵一覧表示に於いて' do
235 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
236 :width => @p.width, :height => @p.height
238 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
240 context 'パラメータpageについて' do
242 get :panel_pictures, :page => 5
243 assigns(:page).should eq 5
245 it '省略されると@pageに1値が入る' do
247 assigns(:page).should eq 1
249 it '与えられたpage_sizeがセットされている' do
250 get :panel_pictures, :page_size => 15
251 assigns(:page_size).should eq 15
253 it '省略されると@page_sizeにデフォルト値が入る' do
255 assigns(:page_size).should eq Author.default_panel_picture_page_size
257 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
258 get :panel_pictures, :page_size => 1500
259 assigns(:page_size).should eq Author.panel_picture_max_page_size
261 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
262 get :panel_pictures, :page_size => 0
263 assigns(:page_size).should eq Author.default_panel_picture_page_size
266 context 'つつがなく終わるとき' do
267 it 'ステータスコード200 OKを返す' do
268 response.should be_success
270 it 'コマ絵モデルに一覧を問い合わせている' do
271 PanelPicture.should_receive(:mylist).exactly(1)
274 it '@panel_picturesにリストを取得している' do
276 assigns(:panel_pictures).should have_at_least(3).items
279 it '@paginateにページ制御を取得している' do
281 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
283 it 'panel_picturesテンプレートを描画する' do
285 response.should render_template("panel_pictures")
290 get :panel_pictures, :format => :json
291 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
293 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
294 PanelPicture.should_receive(:list_json_opt).exactly(1)
295 get :panel_pictures, :format => :json
297 it 'データがリスト構造になっている' do
298 get :panel_pictures, :format => :json
299 json = JSON.parse response.body
300 json.should have_at_least(3).items
302 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
303 get :panel_pictures, :format => :json
304 json = JSON.parse response.body
305 json.first.has_key?("link").should be_true
306 json.first.has_key?("x").should be_true
307 json.first.has_key?("y").should be_true
311 context '作家権限がないとき' do
316 it 'ステータスコード302 Foundを返す' do
318 response.status.should eq 302
320 it 'サインインページへ遷移する' do
322 response.should redirect_to '/users/sign_in'
326 it 'ステータスコード401 Unauthorizedを返す' do
327 get :panel_pictures, :format => :json
328 response.status.should eq 401
330 it '応答メッセージにUnauthorizedを返す' do
331 get :panel_pictures, :format => :json
332 response.message.should match(/Unauthorized/)
338 describe '自分のフキダシ一覧表示に於いて' do
340 @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
341 @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
342 @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id
344 SpeechBalloon.stub(:mylist).and_return([@sb, @sb, @sb])
346 context 'パラメータpageについて' do
348 get :speech_balloons, :page => 5
349 assigns(:page).should eq 5
351 it '省略されると@pageに1値が入る' do
353 assigns(:page).should eq 1
355 it '与えられたpage_sizeがセットされている' do
356 get :speech_balloons, :page_size => 15
357 assigns(:page_size).should eq 15
359 it '省略されると@page_sizeにデフォルト値が入る' do
361 assigns(:page_size).should eq Author.default_speech_balloon_page_size
363 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
364 get :speech_balloons, :page_size => 1500
365 assigns(:page_size).should eq Author.speech_balloon_max_page_size
367 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
368 get :speech_balloons, :page_size => 0
369 assigns(:page_size).should eq Author.default_speech_balloon_page_size
372 context 'つつがなく終わるとき' do
373 it 'ステータスコード200 OKを返す' do
374 response.should be_success
376 it 'フキダシモデルに一覧を問い合わせている' do
377 SpeechBalloon.should_receive(:mylist).exactly(1)
380 it '@speech_balloonsにリストを取得している' do
382 assigns(:speech_balloons).should have_at_least(3).items
385 it '@paginateにページ制御を取得している' do
387 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
389 it 'speech_balloonsテンプレートを描画する' do
391 response.should render_template("speech_balloons")
396 get :speech_balloons, :format => :json
397 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
399 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
400 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
401 get :speech_balloons, :format => :json
403 it 'データがリスト構造になっている' do
404 get :speech_balloons, :format => :json
405 json = JSON.parse response.body
406 json.should have_at_least(3).items
408 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
409 get :speech_balloons, :format => :json
410 json = JSON.parse response.body
411 json.first.has_key?("speech_balloon_template_id").should be_true
412 json.first.has_key?("z").should be_true
413 json.first.has_key?("t").should be_true
417 context '作家権限がないとき' do
422 it 'ステータスコード302 Foundを返す' do
424 response.status.should eq 302
426 it 'サインインページへ遷移する' do
428 response.should redirect_to '/users/sign_in'
432 it 'ステータスコード401 Unauthorizedを返す' do
433 get :speech_balloons, :format => :json
434 response.status.should eq 401
436 it '応答メッセージにUnauthorizedを返す' do
437 get :speech_balloons, :format => :json
438 response.message.should match(/Unauthorized/)
444 describe '自分のコマの絵地一覧表示に於いて' do
446 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
448 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
450 context 'パラメータpageについて' do
452 get :ground_pictures, :page => 5
453 assigns(:page).should eq 5
455 it '省略されると@pageに1値が入る' do
457 assigns(:page).should eq 1
459 it '与えられたpage_sizeがセットされている' do
460 get :ground_pictures, :page_size => 15
461 assigns(:page_size).should eq 15
463 it '省略されると@page_sizeにデフォルト値が入る' do
465 assigns(:page_size).should eq Author.default_ground_picture_page_size
467 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
468 get :ground_pictures, :page_size => 1500
469 assigns(:page_size).should eq Author.ground_picture_max_page_size
471 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
472 get :ground_pictures, :page_size => 0
473 assigns(:page_size).should eq Author.default_ground_picture_page_size
476 context 'つつがなく終わるとき' do
477 it 'ステータスコード200 OKを返す' do
479 response.should be_success
481 it '絵地モデルに一覧を問い合わせている' do
482 GroundPicture.should_receive(:mylist).exactly(1)
485 it '@ground_picturesにリストを取得している' do
487 assigns(:ground_pictures).should have_at_least(3).items
490 it '@paginateにページ制御を取得している' do
492 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
494 it 'ground_picturesテンプレートを描画する' do
496 response.should render_template("ground_pictures")
501 get :ground_pictures, :format => :json
502 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
504 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
505 GroundPicture.should_receive(:list_json_opt).exactly(1)
506 get :ground_pictures, :format => :json
508 it 'データがリスト構造になっている' do
509 get :ground_pictures, :format => :json
510 json = JSON.parse response.body
511 json.should have_at_least(3).items
513 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
514 get :ground_pictures, :format => :json
515 json = JSON.parse response.body
516 json.first.has_key?("panel_id").should be_true
517 json.first.has_key?("picture_id").should be_true
518 json.first.has_key?("z").should be_true
522 context '作家権限がないとき' do
527 it 'ステータスコード302 Foundを返す' do
529 response.status.should eq 302
531 it 'サインインページへ遷移する' do
533 response.should redirect_to '/users/sign_in'
537 it 'ステータスコード401 Unauthorizedを返す' do
538 get :ground_pictures, :format => :json
539 response.status.should eq 401
541 it '応答メッセージにUnauthorizedを返す' do
542 get :ground_pictures, :format => :json
543 response.message.should match(/Unauthorized/)
549 describe '自分の色地一覧表示に於いて' do
551 @gc = FactoryGirl.create :ground_color
553 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
555 context 'パラメータpageについて' do
557 get :ground_colors, :page => 5
558 assigns(:page).should eq 5
560 it '省略されると@pageに1値が入る' do
562 assigns(:page).should eq 1
564 it '与えられたpage_sizeがセットされている' do
565 get :ground_colors, :page_size => 15
566 assigns(:page_size).should eq 15
568 it '省略されると@page_sizeにデフォルト値が入る' do
570 assigns(:page_size).should eq Author.default_ground_color_page_size
572 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
573 get :ground_colors, :page_size => 1500
574 assigns(:page_size).should eq Author.ground_color_max_page_size
576 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
577 get :ground_colors, :page_size => 0
578 assigns(:page_size).should eq Author.default_ground_color_page_size
581 context 'つつがなく終わるとき' do
582 it 'ステータスコード200 OKを返す' do
584 response.should be_success
586 it '色地モデルに一覧を問い合わせている' do
587 GroundColor.should_receive(:mylist).exactly(1)
590 it '@ground_colorsにリストを取得している' do
592 assigns(:ground_colors).should have_at_least(3).items
595 it '@paginateにページ制御を取得している' do
597 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
599 it 'ground_colorsテンプレートを描画する' do
601 response.should render_template("ground_colors")
606 get :ground_colors, :format => :json
607 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
609 it '色地モデルにjson一覧出力オプションを問い合わせている' do
610 GroundColor.should_receive(:list_json_opt).exactly(1)
611 get :ground_colors, :format => :json
613 it 'データがリスト構造になっている' do
614 get :ground_colors, :format => :json
615 json = JSON.parse response.body
616 json.should have_at_least(3).items
618 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
619 get :ground_colors, :format => :json
620 json = JSON.parse response.body
621 json.first.has_key?("panel_id").should be_true
622 json.first.has_key?("code").should be_true
623 json.first.has_key?("z").should be_true
627 context '作家権限がないとき' do
632 it 'ステータスコード302 Foundを返す' do
634 response.status.should eq 302
636 it 'サインインページへ遷移する' do
638 response.should redirect_to '/users/sign_in'
642 it 'ステータスコード401 Unauthorizedを返す' do
643 get :ground_colors, :format => :json
644 response.status.should eq 401
646 it '応答メッセージにUnauthorizedを返す' do
647 get :ground_colors, :format => :json
648 response.message.should match(/Unauthorized/)
654 describe '自分の素材一覧表示に於いて' do
656 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
657 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
658 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
660 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
662 context 'パラメータpageについて' do
664 get :resource_pictures, :page => 5
665 assigns(:page).should eq 5
667 it '省略されると@pageに1値が入る' do
668 get :resource_pictures
669 assigns(:page).should eq 1
671 it '与えられたpage_sizeがセットされている' do
672 get :resource_pictures, :page_size => 15
673 assigns(:page_size).should eq 15
675 it '省略されると@page_sizeにデフォルト値が入る' do
676 get :resource_pictures
677 assigns(:page_size).should eq Author.default_resource_picture_page_size
679 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
680 get :resource_pictures, :page_size => 1500
681 assigns(:page_size).should eq Author.resource_picture_max_page_size
683 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
684 get :resource_pictures, :page_size => 0
685 assigns(:page_size).should eq Author.default_resource_picture_page_size
688 context 'つつがなく終わるとき' do
689 it 'ステータスコード200 OKを返す' do
690 get :resource_pictures
691 response.should be_success
693 it '素材モデルに一覧を問い合わせている' do
694 ResourcePicture.should_receive(:mylist).exactly(1)
695 get :resource_pictures
697 it '@resource_picturesにリストを取得している' do
698 get :resource_pictures
699 assigns(:resource_pictures).should have_at_least(3).items
702 it '@paginateにページ制御を取得している' do
703 get :resource_pictures
704 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
706 it 'resource_picturesテンプレートを描画する' do
707 get :resource_pictures
708 response.should render_template("resource_pictures")
713 get :resource_pictures, :format => :json
714 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
716 it '素材モデルにjson一覧出力オプションを問い合わせている' do
717 ResourcePicture.should_receive(:list_json_opt).exactly(1)
718 get :resource_pictures, :format => :json
720 it 'データがリスト構造になっている' do
721 get :resource_pictures, :format => :json
722 json = JSON.parse response.body
723 json.should have_at_least(3).items
725 it 'リストの先頭くらいは素材っぽいものであって欲しい' do
726 get :resource_pictures, :format => :json
727 json = JSON.parse response.body
728 json.first.has_key?("original_picture_id").should be_true
729 json.first.has_key?("license_id").should be_true
733 context '作家権限がないとき' do
738 it 'ステータスコード302 Foundを返す' do
739 get :resource_pictures
740 response.status.should eq 302
742 it 'サインインページへ遷移する' do
743 get :resource_pictures
744 response.should redirect_to '/users/sign_in'
748 it 'ステータスコード401 Unauthorizedを返す' do
749 get :resource_pictures, :format => :json
750 response.status.should eq 401
752 it '応答メッセージにUnauthorizedを返す' do
753 get :resource_pictures, :format => :json
754 response.message.should match(/Unauthorized/)
758 context '作家が絵師でないとき' do
760 Author.any_instance.stub(:artist?).and_return(false)
763 it 'ステータスコード302 Foundを返す' do
764 get :resource_pictures
765 response.status.should eq 302
768 get :resource_pictures
769 response.should redirect_to new_artist_path
773 it '例外403 forbiddenを返す' do
775 get :resource_pictures, :format => :json
776 }.should raise_error(ActiveRecord::Forbidden)
783 describe '自分のコミック一覧表示に於いて' do
785 @comic = FactoryGirl.create :comic, :author_id => @author.id
787 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
789 context 'つつがなく終わるとき' do
790 it 'ステータスコード200 OKを返す' do
792 response.should be_success
795 it 'comicsテンプレートを描画する' do
797 response.should render_template("comics")
802 get :comics, :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 :comics, :format => :json
824 response.status.should eq 401
826 it '応答メッセージにUnauthorizedを返す' do
827 get :comics, :format => :json
828 response.message.should match(/Unauthorized/)
834 describe '自分のコマ一覧表示に於いて' do
836 @panel = FactoryGirl.create :panel, :author_id => @author.id
838 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
840 context 'つつがなく終わるとき' do
842 it 'ステータスコード200 OKを返す' do
844 response.should be_success
846 it 'panelsテンプレートを描画する' do
848 response.should render_template("panels")
852 it 'ステータスコード200 OKを返す' do
853 get :panels, :format => :json
854 response.should be_success
857 get :panels, :format => :json
858 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
862 context '作家権限がないとき' do
867 it 'ステータスコード302 Foundを返す' do
869 response.status.should eq 302
871 it 'サインインページへ遷移する' do
873 response.should redirect_to '/users/sign_in'
877 it 'ステータスコード401 Unauthorizedを返す' do
878 get :panels, :format => :json
879 response.status.should eq 401
881 it '応答メッセージにUnauthorizedを返す' do
882 get :panels, :format => :json
883 response.message.should match(/Unauthorized/)
889 describe '自分のコマ絵一覧表示に於いて' do
891 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
892 :width => @p.width, :height => @p.height
894 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
896 context 'つつがなく終わるとき' do
897 it 'ステータスコード200 OKを返す' do
899 response.should be_success
902 it 'panel_picturesテンプレートを描画する' do
904 response.should render_template("panel_pictures")
909 get :panel_pictures, :format => :json
910 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
914 context '作家権限がないとき' do
919 it 'ステータスコード302 Foundを返す' do
921 response.status.should eq 302
923 it 'サインインページへ遷移する' do
925 response.should redirect_to '/users/sign_in'
929 it 'ステータスコード401 Unauthorizedを返す' do
930 get :panel_pictures, :format => :json
931 response.status.should eq 401
933 it '応答メッセージにUnauthorizedを返す' do
934 get :panel_pictures, :format => :json
935 response.message.should match(/Unauthorized/)
942 describe '自分のコマの絵地一覧表示に於いて' do
944 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
946 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
948 context 'つつがなく終わるとき' do
949 it 'ステータスコード200 OKを返す' do
951 response.should be_success
954 it 'ground_picturesテンプレートを描画する' do
956 response.should render_template("ground_pictures")
961 get :ground_pictures, :format => :json
962 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
966 context '作家権限がないとき' do
971 it 'ステータスコード302 Foundを返す' do
973 response.status.should eq 302
975 it 'サインインページへ遷移する' do
977 response.should redirect_to '/users/sign_in'
981 it 'ステータスコード401 Unauthorizedを返す' do
982 get :ground_pictures, :format => :json
983 response.status.should eq 401
985 it '応答メッセージにUnauthorizedを返す' do
986 get :ground_pictures, :format => :json
987 response.message.should match(/Unauthorized/)
993 describe '自分の色地一覧表示に於いて' do
995 @gc = FactoryGirl.create :ground_color
997 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
999 context 'つつがなく終わるとき' do
1000 it 'ステータスコード200 OKを返す' do
1002 response.should be_success
1005 it 'ground_colorsテンプレートを描画する' do
1007 response.should render_template("ground_colors")
1012 get :ground_colors, :format => :json
1013 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1017 context '作家権限がないとき' do
1022 it 'ステータスコード302 Foundを返す' do
1024 response.status.should eq 302
1026 it 'サインインページへ遷移する' do
1028 response.should redirect_to '/users/sign_in'
1032 it 'ステータスコード401 Unauthorizedを返す' do
1033 get :ground_colors, :format => :json
1034 response.status.should eq 401
1036 it '応答メッセージにUnauthorizedを返す' do
1037 get :ground_colors, :format => :json
1038 response.message.should match(/Unauthorized/)
1044 describe '自分の素材一覧表示に於いて' do
1046 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1047 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1048 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1050 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
1052 context 'つつがなく終わるとき' do
1053 it 'ステータスコード200 OKを返す' do
1054 get :resource_pictures
1055 response.should be_success
1058 it 'resource_picturesテンプレートを描画する' do
1059 get :resource_pictures
1060 response.should render_template("resource_pictures")
1065 get :resource_pictures, :format => :json
1066 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1070 context '作家権限がないとき' do
1075 it 'ステータスコード302 Foundを返す' do
1076 get :resource_pictures
1077 response.status.should eq 302
1079 it 'サインインページへ遷移する' do
1080 get :resource_pictures
1081 response.should redirect_to '/users/sign_in'
1085 it 'ステータスコード401 Unauthorizedを返す' do
1086 get :resource_pictures, :format => :json
1087 response.status.should eq 401
1089 it '応答メッセージにUnauthorizedを返す' do
1090 get :resource_pictures, :format => :json
1091 response.message.should match(/Unauthorized/)
1095 context '作家が絵師でないとき' do
1100 it 'ステータスコード302 Foundを返す' do
1101 get :resource_pictures
1102 response.status.should eq 302
1104 it '絵師登録ページへ遷移する' do
1105 get :resource_pictures
1106 response.should redirect_to new_artist_path
1110 it '例外403 forbiddenを返す' do
1112 get :resource_pictures, :format => :json
1113 }.should raise_error(ActiveRecord::Forbidden)