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 @writing_format = FactoryGirl.create :writing_format
13 @user = FactoryGirl.create( :user_yas)
14 @author = FactoryGirl.create :author, :user_id => @user.id
15 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
16 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
17 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
18 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
19 @panel = FactoryGirl.create :panel, :author_id => @author.id
22 if MagicNumber['run_mode'] == 1
23 describe '自分のコミック一覧表示に於いて' do
25 @comic = FactoryGirl.create :comic, :author_id => @author.id
27 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
29 context 'パラメータpageについて' do
31 get :comics, :page => 5
32 assigns(:page).should eq 5
34 it '省略されると@pageに1値が入る' do
36 assigns(:page).should eq 1
38 it '与えられたpage_sizeがセットされている' do
39 get :comics, :page_size => 15
40 assigns(:page_size).should eq 15
42 it '省略されると@page_sizeにデフォルト値が入る' do
44 assigns(:page_size).should eq Author.default_comic_page_size
46 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
47 get :comics, :page_size => 1500
48 assigns(:page_size).should eq Author.comic_max_page_size
50 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
51 get :comics, :page_size => 0
52 assigns(:page_size).should eq Author.default_comic_page_size
55 context 'つつがなく終わるとき' do
56 it 'ステータスコード200 OKを返す' do
58 response.should be_success
60 it 'コミックモデルに一覧を問い合わせている' do
61 Comic.should_receive(:mylist).exactly(1)
64 it '@comicsにリストを取得している' do
66 assigns(:comics).should have_at_least(3).items
69 it '@paginateにページ制御を取得している' do
71 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
73 it 'comicsテンプレートを描画する' do
75 response.should render_template("comics")
80 get :comics, :format => :json
81 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
83 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
84 Comic.should_receive(:list_json_opt).exactly(1)
85 get :comics, :format => :json
87 it 'データがリスト構造になっている' do
88 get :comics, :format => :json
89 json = JSON.parse response.body
90 json.should have_at_least(3).items
92 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
93 get :comics, :format => :json
94 json = JSON.parse response.body
95 json.first.has_key?("title").should be_true
96 json.first.has_key?("visible").should be_true
100 context '作家権限がないとき' do
105 it 'ステータスコード302 Foundを返す' do
107 response.status.should eq 302
109 it 'サインインページへ遷移する' do
111 response.should redirect_to '/users/sign_in'
115 it 'ステータスコード401 Unauthorizedを返す' do
116 get :comics, :format => :json
117 response.status.should eq 401
119 it '応答メッセージにUnauthorizedを返す' do
120 get :comics, :format => :json
121 response.message.should match(/Unauthorized/)
127 describe '自分のコマ一覧表示に於いて' do
129 @panel = FactoryGirl.create :panel, :author_id => @author.id
131 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
133 context 'パラメータpageについて' do
135 get :panels, :page => 5
136 assigns(:page).should eq 5
138 it '省略されると@pageに1値が入る' do
140 assigns(:page).should eq 1
142 it '与えられたpage_sizeがセットされている' do
143 get :panels, :page_size => 15
144 assigns(:page_size).should eq 15
146 it '省略されると@page_sizeにデフォルト値が入る' do
148 assigns(:page_size).should eq Author.default_panel_page_size
150 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
151 get :panels, :page_size => 1500
152 assigns(:page_size).should eq Author.panel_max_page_size
154 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
155 get :panels, :page_size => 0
156 assigns(:page_size).should eq Author.default_panel_page_size
159 context 'つつがなく終わるとき' do
160 it 'コマモデルに一覧を問い合わせている' do
161 Panel.should_receive(:mylist).exactly(1)
164 it '@panelsにリストを取得している' do
166 assigns(:panels).should have_at_least(3).items
169 it '@paginateにページ制御を取得している' do
171 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
173 it 'ステータスコード200 OKを返す' do
175 response.should be_success
177 it 'panelsテンプレートを描画する' do
179 response.should render_template("panels")
183 it 'ステータスコード200 OKを返す' do
184 get :panels, :format => :json
185 response.should be_success
188 get :panels, :format => :json
189 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
191 it 'コマモデルにコマリストのjson出力を問い合わせている' do
192 Panel.should_receive(:list_as_json_text).exactly(1)
193 get :panels, :format => :json
195 it 'データがリスト構造になっている' do
196 get :panels, :format => :json
197 json = JSON.parse response.body
198 json.should have_at_least(3).items
200 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
201 get :panels, :format => :json
202 json = JSON.parse response.body
203 json.first.has_key?("z").should be_true
207 context '作家権限がないとき' do
212 it 'ステータスコード302 Foundを返す' do
214 response.status.should eq 302
216 it 'サインインページへ遷移する' do
218 response.should redirect_to '/users/sign_in'
222 it 'ステータスコード401 Unauthorizedを返す' do
223 get :panels, :format => :json
224 response.status.should eq 401
226 it '応答メッセージにUnauthorizedを返す' do
227 get :panels, :format => :json
228 response.message.should match(/Unauthorized/)
234 describe '自分のコマ絵一覧表示に於いて' do
236 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
237 :width => @p.width, :height => @p.height
239 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
241 context 'パラメータpageについて' do
243 get :panel_pictures, :page => 5
244 assigns(:page).should eq 5
246 it '省略されると@pageに1値が入る' do
248 assigns(:page).should eq 1
250 it '与えられたpage_sizeがセットされている' do
251 get :panel_pictures, :page_size => 15
252 assigns(:page_size).should eq 15
254 it '省略されると@page_sizeにデフォルト値が入る' do
256 assigns(:page_size).should eq Author.default_panel_picture_page_size
258 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
259 get :panel_pictures, :page_size => 1500
260 assigns(:page_size).should eq Author.panel_picture_max_page_size
262 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
263 get :panel_pictures, :page_size => 0
264 assigns(:page_size).should eq Author.default_panel_picture_page_size
267 context 'つつがなく終わるとき' do
268 it 'ステータスコード200 OKを返す' do
269 response.should be_success
271 it 'コマ絵モデルに一覧を問い合わせている' do
272 PanelPicture.should_receive(:mylist).exactly(1)
275 it '@panel_picturesにリストを取得している' do
277 assigns(:panel_pictures).should have_at_least(3).items
280 it '@paginateにページ制御を取得している' do
282 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
284 it 'panel_picturesテンプレートを描画する' do
286 response.should render_template("panel_pictures")
291 get :panel_pictures, :format => :json
292 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
294 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
295 PanelPicture.should_receive(:list_json_opt).exactly(1)
296 get :panel_pictures, :format => :json
298 it 'データがリスト構造になっている' do
299 get :panel_pictures, :format => :json
300 json = JSON.parse response.body
301 json.should have_at_least(3).items
303 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
304 get :panel_pictures, :format => :json
305 json = JSON.parse response.body
306 json.first.has_key?("link").should be_true
307 json.first.has_key?("x").should be_true
308 json.first.has_key?("y").should be_true
312 context '作家権限がないとき' do
317 it 'ステータスコード302 Foundを返す' do
319 response.status.should eq 302
321 it 'サインインページへ遷移する' do
323 response.should redirect_to '/users/sign_in'
327 it 'ステータスコード401 Unauthorizedを返す' do
328 get :panel_pictures, :format => :json
329 response.status.should eq 401
331 it '応答メッセージにUnauthorizedを返す' do
332 get :panel_pictures, :format => :json
333 response.message.should match(/Unauthorized/)
339 describe '自分のフキダシ一覧表示に於いて' do
341 @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
342 @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
343 @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id
345 SpeechBalloon.stub(:mylist).and_return([@sb, @sb, @sb])
347 context 'パラメータpageについて' do
349 get :speech_balloons, :page => 5
350 assigns(:page).should eq 5
352 it '省略されると@pageに1値が入る' do
354 assigns(:page).should eq 1
356 it '与えられたpage_sizeがセットされている' do
357 get :speech_balloons, :page_size => 15
358 assigns(:page_size).should eq 15
360 it '省略されると@page_sizeにデフォルト値が入る' do
362 assigns(:page_size).should eq Author.default_speech_balloon_page_size
364 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
365 get :speech_balloons, :page_size => 1500
366 assigns(:page_size).should eq Author.speech_balloon_max_page_size
368 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
369 get :speech_balloons, :page_size => 0
370 assigns(:page_size).should eq Author.default_speech_balloon_page_size
373 context 'つつがなく終わるとき' do
374 it 'ステータスコード200 OKを返す' do
375 response.should be_success
377 it 'フキダシモデルに一覧を問い合わせている' do
378 SpeechBalloon.should_receive(:mylist).exactly(1)
381 it '@speech_balloonsにリストを取得している' do
383 assigns(:speech_balloons).should have_at_least(3).items
386 it '@paginateにページ制御を取得している' do
388 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
390 it 'speech_balloonsテンプレートを描画する' do
392 response.should render_template("speech_balloons")
397 get :speech_balloons, :format => :json
398 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
400 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
401 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
402 get :speech_balloons, :format => :json
404 it 'データがリスト構造になっている' do
405 get :speech_balloons, :format => :json
406 json = JSON.parse response.body
407 json.should have_at_least(3).items
409 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
410 get :speech_balloons, :format => :json
411 json = JSON.parse response.body
412 json.first.has_key?("speech_balloon_template_id").should be_true
413 json.first.has_key?("z").should be_true
414 json.first.has_key?("t").should be_true
418 context '作家権限がないとき' do
423 it 'ステータスコード302 Foundを返す' do
425 response.status.should eq 302
427 it 'サインインページへ遷移する' do
429 response.should redirect_to '/users/sign_in'
433 it 'ステータスコード401 Unauthorizedを返す' do
434 get :speech_balloons, :format => :json
435 response.status.should eq 401
437 it '応答メッセージにUnauthorizedを返す' do
438 get :speech_balloons, :format => :json
439 response.message.should match(/Unauthorized/)
445 describe '自分のコマの絵地一覧表示に於いて' do
447 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
449 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
451 context 'パラメータpageについて' do
453 get :ground_pictures, :page => 5
454 assigns(:page).should eq 5
456 it '省略されると@pageに1値が入る' do
458 assigns(:page).should eq 1
460 it '与えられたpage_sizeがセットされている' do
461 get :ground_pictures, :page_size => 15
462 assigns(:page_size).should eq 15
464 it '省略されると@page_sizeにデフォルト値が入る' do
466 assigns(:page_size).should eq Author.default_ground_picture_page_size
468 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
469 get :ground_pictures, :page_size => 1500
470 assigns(:page_size).should eq Author.ground_picture_max_page_size
472 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
473 get :ground_pictures, :page_size => 0
474 assigns(:page_size).should eq Author.default_ground_picture_page_size
477 context 'つつがなく終わるとき' do
478 it 'ステータスコード200 OKを返す' do
480 response.should be_success
482 it '絵地モデルに一覧を問い合わせている' do
483 GroundPicture.should_receive(:mylist).exactly(1)
486 it '@ground_picturesにリストを取得している' do
488 assigns(:ground_pictures).should have_at_least(3).items
491 it '@paginateにページ制御を取得している' do
493 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
495 it 'ground_picturesテンプレートを描画する' do
497 response.should render_template("ground_pictures")
502 get :ground_pictures, :format => :json
503 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
505 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
506 GroundPicture.should_receive(:list_json_opt).exactly(1)
507 get :ground_pictures, :format => :json
509 it 'データがリスト構造になっている' do
510 get :ground_pictures, :format => :json
511 json = JSON.parse response.body
512 json.should have_at_least(3).items
514 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
515 get :ground_pictures, :format => :json
516 json = JSON.parse response.body
517 json.first.has_key?("panel_id").should be_true
518 json.first.has_key?("picture_id").should be_true
519 json.first.has_key?("z").should be_true
523 context '作家権限がないとき' do
528 it 'ステータスコード302 Foundを返す' do
530 response.status.should eq 302
532 it 'サインインページへ遷移する' do
534 response.should redirect_to '/users/sign_in'
538 it 'ステータスコード401 Unauthorizedを返す' do
539 get :ground_pictures, :format => :json
540 response.status.should eq 401
542 it '応答メッセージにUnauthorizedを返す' do
543 get :ground_pictures, :format => :json
544 response.message.should match(/Unauthorized/)
550 describe '自分の色地一覧表示に於いて' do
552 @gc = FactoryGirl.create :ground_color
554 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
556 context 'パラメータpageについて' do
558 get :ground_colors, :page => 5
559 assigns(:page).should eq 5
561 it '省略されると@pageに1値が入る' do
563 assigns(:page).should eq 1
565 it '与えられたpage_sizeがセットされている' do
566 get :ground_colors, :page_size => 15
567 assigns(:page_size).should eq 15
569 it '省略されると@page_sizeにデフォルト値が入る' do
571 assigns(:page_size).should eq Author.default_ground_color_page_size
573 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
574 get :ground_colors, :page_size => 1500
575 assigns(:page_size).should eq Author.ground_color_max_page_size
577 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
578 get :ground_colors, :page_size => 0
579 assigns(:page_size).should eq Author.default_ground_color_page_size
582 context 'つつがなく終わるとき' do
583 it 'ステータスコード200 OKを返す' do
585 response.should be_success
587 it '色地モデルに一覧を問い合わせている' do
588 GroundColor.should_receive(:mylist).exactly(1)
591 it '@ground_colorsにリストを取得している' do
593 assigns(:ground_colors).should have_at_least(3).items
596 it '@paginateにページ制御を取得している' do
598 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
600 it 'ground_colorsテンプレートを描画する' do
602 response.should render_template("ground_colors")
607 get :ground_colors, :format => :json
608 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
610 it '色地モデルにjson一覧出力オプションを問い合わせている' do
611 GroundColor.should_receive(:list_json_opt).exactly(1)
612 get :ground_colors, :format => :json
614 it 'データがリスト構造になっている' do
615 get :ground_colors, :format => :json
616 json = JSON.parse response.body
617 json.should have_at_least(3).items
619 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
620 get :ground_colors, :format => :json
621 json = JSON.parse response.body
622 json.first.has_key?("panel_id").should be_true
623 json.first.has_key?("code").should be_true
624 json.first.has_key?("z").should be_true
628 context '作家権限がないとき' do
633 it 'ステータスコード302 Foundを返す' do
635 response.status.should eq 302
637 it 'サインインページへ遷移する' do
639 response.should redirect_to '/users/sign_in'
643 it 'ステータスコード401 Unauthorizedを返す' do
644 get :ground_colors, :format => :json
645 response.status.should eq 401
647 it '応答メッセージにUnauthorizedを返す' do
648 get :ground_colors, :format => :json
649 response.message.should match(/Unauthorized/)
655 describe '自分の素材一覧表示に於いて' do
657 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
658 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
659 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
661 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
663 context 'パラメータpageについて' do
665 get :resource_pictures, :page => 5
666 assigns(:page).should eq 5
668 it '省略されると@pageに1値が入る' do
669 get :resource_pictures
670 assigns(:page).should eq 1
672 it '与えられたpage_sizeがセットされている' do
673 get :resource_pictures, :page_size => 15
674 assigns(:page_size).should eq 15
676 it '省略されると@page_sizeにデフォルト値が入る' do
677 get :resource_pictures
678 assigns(:page_size).should eq Author.default_resource_picture_page_size
680 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
681 get :resource_pictures, :page_size => 1500
682 assigns(:page_size).should eq Author.resource_picture_max_page_size
684 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
685 get :resource_pictures, :page_size => 0
686 assigns(:page_size).should eq Author.default_resource_picture_page_size
689 context 'つつがなく終わるとき' do
690 it 'ステータスコード200 OKを返す' do
691 get :resource_pictures
692 response.should be_success
694 it '素材モデルに一覧を問い合わせている' do
695 ResourcePicture.should_receive(:mylist).exactly(1)
696 get :resource_pictures
698 it '@resource_picturesにリストを取得している' do
699 get :resource_pictures
700 assigns(:resource_pictures).should have_at_least(3).items
703 it '@paginateにページ制御を取得している' do
704 get :resource_pictures
705 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
707 it 'resource_picturesテンプレートを描画する' do
708 get :resource_pictures
709 response.should render_template("resource_pictures")
714 get :resource_pictures, :format => :json
715 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
717 it '素材モデルにjson一覧出力オプションを問い合わせている' do
718 ResourcePicture.should_receive(:list_json_opt).exactly(1)
719 get :resource_pictures, :format => :json
721 it 'データがリスト構造になっている' do
722 get :resource_pictures, :format => :json
723 json = JSON.parse response.body
724 json.should have_at_least(3).items
726 it 'リストの先頭くらいは素材っぽいものであって欲しい' do
727 get :resource_pictures, :format => :json
728 json = JSON.parse response.body
729 json.first.has_key?("original_picture_id").should be_true
730 json.first.has_key?("license_id").should be_true
734 context '作家権限がないとき' do
739 it 'ステータスコード302 Foundを返す' do
740 get :resource_pictures
741 response.status.should eq 302
743 it 'サインインページへ遷移する' do
744 get :resource_pictures
745 response.should redirect_to '/users/sign_in'
749 it 'ステータスコード401 Unauthorizedを返す' do
750 get :resource_pictures, :format => :json
751 response.status.should eq 401
753 it '応答メッセージにUnauthorizedを返す' do
754 get :resource_pictures, :format => :json
755 response.message.should match(/Unauthorized/)
759 context '作家が絵師でないとき' do
761 Author.any_instance.stub(:artist?).and_return(false)
764 it 'ステータスコード302 Foundを返す' do
765 get :resource_pictures
766 response.status.should eq 302
769 get :resource_pictures
770 response.should redirect_to new_artist_path
774 it '例外403 forbiddenを返す' do
776 get :resource_pictures, :format => :json
777 }.should raise_error(ActiveRecord::Forbidden)
784 describe '自分のコミック一覧表示に於いて' do
786 @comic = FactoryGirl.create :comic, :author_id => @author.id
788 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
790 context 'つつがなく終わるとき' do
791 it 'ステータスコード200 OKを返す' do
793 response.should be_success
796 it 'comicsテンプレートを描画する' do
798 response.should render_template("comics")
803 get :comics, :format => :json
804 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
808 context '作家権限がないとき' do
813 it 'ステータスコード302 Foundを返す' do
815 response.status.should eq 302
817 it 'サインインページへ遷移する' do
819 response.should redirect_to '/users/sign_in'
823 it 'ステータスコード401 Unauthorizedを返す' do
824 get :comics, :format => :json
825 response.status.should eq 401
827 it '応答メッセージにUnauthorizedを返す' do
828 get :comics, :format => :json
829 response.message.should match(/Unauthorized/)
835 describe '自分のコマ一覧表示に於いて' do
837 @panel = FactoryGirl.create :panel, :author_id => @author.id
839 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
841 context 'つつがなく終わるとき' do
843 it 'ステータスコード200 OKを返す' do
845 response.should be_success
847 it 'panelsテンプレートを描画する' do
849 response.should render_template("panels")
853 it 'ステータスコード200 OKを返す' do
854 get :panels, :format => :json
855 response.should be_success
858 get :panels, :format => :json
859 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
863 context '作家権限がないとき' do
868 it 'ステータスコード302 Foundを返す' do
870 response.status.should eq 302
872 it 'サインインページへ遷移する' do
874 response.should redirect_to '/users/sign_in'
878 it 'ステータスコード401 Unauthorizedを返す' do
879 get :panels, :format => :json
880 response.status.should eq 401
882 it '応答メッセージにUnauthorizedを返す' do
883 get :panels, :format => :json
884 response.message.should match(/Unauthorized/)
890 describe '自分のコマ絵一覧表示に於いて' do
892 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
893 :width => @p.width, :height => @p.height
895 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
897 context 'つつがなく終わるとき' do
898 it 'ステータスコード200 OKを返す' do
900 response.should be_success
903 it 'panel_picturesテンプレートを描画する' do
905 response.should render_template("panel_pictures")
910 get :panel_pictures, :format => :json
911 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
915 context '作家権限がないとき' do
920 it 'ステータスコード302 Foundを返す' do
922 response.status.should eq 302
924 it 'サインインページへ遷移する' do
926 response.should redirect_to '/users/sign_in'
930 it 'ステータスコード401 Unauthorizedを返す' do
931 get :panel_pictures, :format => :json
932 response.status.should eq 401
934 it '応答メッセージにUnauthorizedを返す' do
935 get :panel_pictures, :format => :json
936 response.message.should match(/Unauthorized/)
943 describe '自分のコマの絵地一覧表示に於いて' do
945 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
947 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
949 context 'つつがなく終わるとき' do
950 it 'ステータスコード200 OKを返す' do
952 response.should be_success
955 it 'ground_picturesテンプレートを描画する' do
957 response.should render_template("ground_pictures")
962 get :ground_pictures, :format => :json
963 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
967 context '作家権限がないとき' do
972 it 'ステータスコード302 Foundを返す' do
974 response.status.should eq 302
976 it 'サインインページへ遷移する' do
978 response.should redirect_to '/users/sign_in'
982 it 'ステータスコード401 Unauthorizedを返す' do
983 get :ground_pictures, :format => :json
984 response.status.should eq 401
986 it '応答メッセージにUnauthorizedを返す' do
987 get :ground_pictures, :format => :json
988 response.message.should match(/Unauthorized/)
994 describe '自分の色地一覧表示に於いて' do
996 @gc = FactoryGirl.create :ground_color
998 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
1000 context 'つつがなく終わるとき' do
1001 it 'ステータスコード200 OKを返す' do
1003 response.should be_success
1006 it 'ground_colorsテンプレートを描画する' do
1008 response.should render_template("ground_colors")
1013 get :ground_colors, :format => :json
1014 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1018 context '作家権限がないとき' do
1023 it 'ステータスコード302 Foundを返す' do
1025 response.status.should eq 302
1027 it 'サインインページへ遷移する' do
1029 response.should redirect_to '/users/sign_in'
1033 it 'ステータスコード401 Unauthorizedを返す' do
1034 get :ground_colors, :format => :json
1035 response.status.should eq 401
1037 it '応答メッセージにUnauthorizedを返す' do
1038 get :ground_colors, :format => :json
1039 response.message.should match(/Unauthorized/)
1045 describe '自分の素材一覧表示に於いて' do
1047 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1048 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1049 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1051 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
1053 context 'つつがなく終わるとき' do
1054 it 'ステータスコード200 OKを返す' do
1055 get :resource_pictures
1056 response.should be_success
1059 it 'resource_picturesテンプレートを描画する' do
1060 get :resource_pictures
1061 response.should render_template("resource_pictures")
1066 get :resource_pictures, :format => :json
1067 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1071 context '作家権限がないとき' do
1076 it 'ステータスコード302 Foundを返す' do
1077 get :resource_pictures
1078 response.status.should eq 302
1080 it 'サインインページへ遷移する' do
1081 get :resource_pictures
1082 response.should redirect_to '/users/sign_in'
1086 it 'ステータスコード401 Unauthorizedを返す' do
1087 get :resource_pictures, :format => :json
1088 response.status.should eq 401
1090 it '応答メッセージにUnauthorizedを返す' do
1091 get :resource_pictures, :format => :json
1092 response.message.should match(/Unauthorized/)
1096 context '作家が絵師でないとき' do
1101 it 'ステータスコード302 Foundを返す' do
1102 get :resource_pictures
1103 response.status.should eq 302
1105 it '絵師登録ページへ遷移する' do
1106 get :resource_pictures
1107 response.should redirect_to new_artist_path
1111 it '例外403 forbiddenを返す' do
1113 get :resource_pictures, :format => :json
1114 }.should raise_error(ActiveRecord::Forbidden)