1 # -*- encoding: utf-8 -*-
5 describe HomeController do
7 SpeechBalloonTemplate.delete_all
8 @admin =FactoryGirl.create :admin
9 @sp = FactoryGirl.create :system_picture
10 @lg = FactoryGirl.create :license_group
11 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
12 @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'
13 @writing_format = FactoryGirl.create :writing_format
14 @user = FactoryGirl.create( :user_yas)
15 @author = FactoryGirl.create :author, :user_id => @user.id
16 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
17 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
18 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
19 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
20 @panel = FactoryGirl.create :panel, :author_id => @author.id
23 if MagicNumber['run_mode'] == 1
24 describe '自分のコミック一覧表示に於いて' do
26 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
28 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
30 context 'パラメータpageについて' do
32 get :scrolls, :page => 5
33 assigns(:page).should eq 5
35 it '省略されると@pageに1値が入る' do
37 assigns(:page).should eq 1
39 it '与えられたpage_sizeがセットされている' do
40 get :scrolls, :page_size => 15
41 assigns(:page_size).should eq 15
43 it '省略されると@page_sizeにデフォルト値が入る' do
45 assigns(:page_size).should eq Author.default_scroll_page_size
47 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
48 get :scrolls, :page_size => 1500
49 assigns(:page_size).should eq Author.scroll_max_page_size
51 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
52 get :scrolls, :page_size => 0
53 assigns(:page_size).should eq Author.default_scroll_page_size
56 context 'つつがなく終わるとき' do
57 it 'ステータスコード200 OKを返す' do
59 response.should be_success
61 it 'コミックモデルに一覧を問い合わせている' do
62 Scroll.should_receive(:mylist).exactly(1)
65 it '@scrollsにリストを取得している' do
67 assigns(:scrolls).should have_at_least(3).items
70 it '@paginateにページ制御を取得している' do
72 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
74 it 'scrollsテンプレートを描画する' do
76 response.should render_template("scrolls")
81 get :scrolls, :format => :json
82 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
84 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
85 Scroll.should_receive(:list_json_opt).exactly(1)
86 get :scrolls, :format => :json
88 it 'データがリスト構造になっている' do
89 get :scrolls, :format => :json
90 json = JSON.parse response.body
91 json.should have_at_least(3).items
93 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
94 get :scrolls, :format => :json
95 json = JSON.parse response.body
96 json.first.has_key?("title").should be_true
97 json.first.has_key?("visible").should be_true
101 context '作家権限がないとき' do
106 it 'ステータスコード302 Foundを返す' do
108 response.status.should eq 302
110 it 'サインインページへ遷移する' do
112 response.should redirect_to '/users/sign_in'
116 it 'ステータスコード401 Unauthorizedを返す' do
117 get :scrolls, :format => :json
118 response.status.should eq 401
120 it '応答メッセージにUnauthorizedを返す' do
121 get :scrolls, :format => :json
122 response.message.should match(/Unauthorized/)
128 describe '自分のコマ一覧表示に於いて' do
130 @panel = FactoryGirl.create :panel, :author_id => @author.id
132 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
134 context 'パラメータpageについて' do
136 get :panels, :page => 5
137 assigns(:page).should eq 5
139 it '省略されると@pageに1値が入る' do
141 assigns(:page).should eq 1
143 it '与えられたpage_sizeがセットされている' do
144 get :panels, :page_size => 15
145 assigns(:page_size).should eq 15
147 it '省略されると@page_sizeにデフォルト値が入る' do
149 assigns(:page_size).should eq Author.default_panel_page_size
151 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
152 get :panels, :page_size => 1500
153 assigns(:page_size).should eq Author.panel_max_page_size
155 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
156 get :panels, :page_size => 0
157 assigns(:page_size).should eq Author.default_panel_page_size
160 context 'つつがなく終わるとき' do
161 it 'コマモデルに一覧を問い合わせている' do
162 Panel.should_receive(:mylist).exactly(1)
165 it '@panelsにリストを取得している' do
167 assigns(:panels).should have_at_least(3).items
170 it '@paginateにページ制御を取得している' do
172 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
174 it 'ステータスコード200 OKを返す' do
176 response.should be_success
178 it 'panelsテンプレートを描画する' do
180 response.should render_template("panels")
184 it 'ステータスコード200 OKを返す' do
185 get :panels, :format => :json
186 response.should be_success
189 get :panels, :format => :json
190 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
192 it 'コマモデルにコマリストのjson出力を問い合わせている' do
193 Panel.should_receive(:list_as_json_text).exactly(1)
194 get :panels, :format => :json
196 it 'データがリスト構造になっている' do
197 get :panels, :format => :json
198 json = JSON.parse response.body
199 json.should have_at_least(3).items
201 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
202 get :panels, :format => :json
203 json = JSON.parse response.body
204 json.first.has_key?("z").should be_true
208 context '作家権限がないとき' do
213 it 'ステータスコード302 Foundを返す' do
215 response.status.should eq 302
217 it 'サインインページへ遷移する' do
219 response.should redirect_to '/users/sign_in'
223 it 'ステータスコード401 Unauthorizedを返す' do
224 get :panels, :format => :json
225 response.status.should eq 401
227 it '応答メッセージにUnauthorizedを返す' do
228 get :panels, :format => :json
229 response.message.should match(/Unauthorized/)
235 describe '自分のコマ絵一覧表示に於いて' do
237 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
238 :width => @p.width, :height => @p.height
240 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
242 context 'パラメータpageについて' do
244 get :panel_pictures, :page => 5
245 assigns(:page).should eq 5
247 it '省略されると@pageに1値が入る' do
249 assigns(:page).should eq 1
251 it '与えられたpage_sizeがセットされている' do
252 get :panel_pictures, :page_size => 15
253 assigns(:page_size).should eq 15
255 it '省略されると@page_sizeにデフォルト値が入る' do
257 assigns(:page_size).should eq Author.default_panel_picture_page_size
259 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
260 get :panel_pictures, :page_size => 1500
261 assigns(:page_size).should eq Author.panel_picture_max_page_size
263 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
264 get :panel_pictures, :page_size => 0
265 assigns(:page_size).should eq Author.default_panel_picture_page_size
268 context 'つつがなく終わるとき' do
269 it 'ステータスコード200 OKを返す' do
270 response.should be_success
272 it 'コマ絵モデルに一覧を問い合わせている' do
273 PanelPicture.should_receive(:mylist).exactly(1)
276 it '@panel_picturesにリストを取得している' do
278 assigns(:panel_pictures).should have_at_least(3).items
281 it '@paginateにページ制御を取得している' do
283 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
285 it 'panel_picturesテンプレートを描画する' do
287 response.should render_template("panel_pictures")
292 get :panel_pictures, :format => :json
293 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
295 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
296 PanelPicture.should_receive(:list_json_opt).exactly(1)
297 get :panel_pictures, :format => :json
299 it 'データがリスト構造になっている' do
300 get :panel_pictures, :format => :json
301 json = JSON.parse response.body
302 json.should have_at_least(3).items
304 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
305 get :panel_pictures, :format => :json
306 json = JSON.parse response.body
307 json.first.has_key?("link").should be_true
308 json.first.has_key?("x").should be_true
309 json.first.has_key?("y").should be_true
313 context '作家権限がないとき' do
318 it 'ステータスコード302 Foundを返す' do
320 response.status.should eq 302
322 it 'サインインページへ遷移する' do
324 response.should redirect_to '/users/sign_in'
328 it 'ステータスコード401 Unauthorizedを返す' do
329 get :panel_pictures, :format => :json
330 response.status.should eq 401
332 it '応答メッセージにUnauthorizedを返す' do
333 get :panel_pictures, :format => :json
334 response.message.should match(/Unauthorized/)
340 describe '自分のフキダシ一覧表示に於いて' do
342 @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
343 @speech = @sb.build_speech(
344 FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
346 @balloon = @sb.build_balloon(
347 FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
352 SpeechBalloon.stub(:mylist).and_return([@sb, @sb, @sb])
354 context 'パラメータpageについて' do
356 get :speech_balloons, :page => 5
357 assigns(:page).should eq 5
359 it '省略されると@pageに1値が入る' do
361 assigns(:page).should eq 1
363 it '与えられたpage_sizeがセットされている' do
364 get :speech_balloons, :page_size => 15
365 assigns(:page_size).should eq 15
367 it '省略されると@page_sizeにデフォルト値が入る' do
369 assigns(:page_size).should eq Author.default_speech_balloon_page_size
371 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
372 get :speech_balloons, :page_size => 1500
373 assigns(:page_size).should eq Author.speech_balloon_max_page_size
375 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
376 get :speech_balloons, :page_size => 0
377 assigns(:page_size).should eq Author.default_speech_balloon_page_size
380 context 'つつがなく終わるとき' do
381 it 'ステータスコード200 OKを返す' do
382 response.should be_success
384 it 'フキダシモデルに一覧を問い合わせている' do
385 SpeechBalloon.should_receive(:mylist).exactly(1)
388 it '@speech_balloonsにリストを取得している' do
390 assigns(:speech_balloons).should have_at_least(3).items
393 it '@paginateにページ制御を取得している' do
395 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
397 it 'speech_balloonsテンプレートを描画する' do
399 response.should render_template("speech_balloons")
404 get :speech_balloons, :format => :json
405 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
407 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
408 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
409 get :speech_balloons, :format => :json
411 it 'データがリスト構造になっている' do
412 get :speech_balloons, :format => :json
413 json = JSON.parse response.body
414 json.should have_at_least(3).items
416 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
417 get :speech_balloons, :format => :json
418 json = JSON.parse response.body
419 json.first.has_key?("speech_balloon_template_id").should be_true
420 json.first.has_key?("z").should be_true
421 json.first.has_key?("t").should be_true
425 context '作家権限がないとき' do
430 it 'ステータスコード302 Foundを返す' do
432 response.status.should eq 302
434 it 'サインインページへ遷移する' do
436 response.should redirect_to '/users/sign_in'
440 it 'ステータスコード401 Unauthorizedを返す' do
441 get :speech_balloons, :format => :json
442 response.status.should eq 401
444 it '応答メッセージにUnauthorizedを返す' do
445 get :speech_balloons, :format => :json
446 response.message.should match(/Unauthorized/)
452 describe '自分のコマの絵地一覧表示に於いて' do
454 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
456 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
458 context 'パラメータpageについて' do
460 get :ground_pictures, :page => 5
461 assigns(:page).should eq 5
463 it '省略されると@pageに1値が入る' do
465 assigns(:page).should eq 1
467 it '与えられたpage_sizeがセットされている' do
468 get :ground_pictures, :page_size => 15
469 assigns(:page_size).should eq 15
471 it '省略されると@page_sizeにデフォルト値が入る' do
473 assigns(:page_size).should eq Author.default_ground_picture_page_size
475 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
476 get :ground_pictures, :page_size => 1500
477 assigns(:page_size).should eq Author.ground_picture_max_page_size
479 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
480 get :ground_pictures, :page_size => 0
481 assigns(:page_size).should eq Author.default_ground_picture_page_size
484 context 'つつがなく終わるとき' do
485 it 'ステータスコード200 OKを返す' do
487 response.should be_success
489 it '絵地モデルに一覧を問い合わせている' do
490 GroundPicture.should_receive(:mylist).exactly(1)
493 it '@ground_picturesにリストを取得している' do
495 assigns(:ground_pictures).should have_at_least(3).items
498 it '@paginateにページ制御を取得している' do
500 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
502 it 'ground_picturesテンプレートを描画する' do
504 response.should render_template("ground_pictures")
509 get :ground_pictures, :format => :json
510 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
512 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
513 GroundPicture.should_receive(:list_json_opt).exactly(1)
514 get :ground_pictures, :format => :json
516 it 'データがリスト構造になっている' do
517 get :ground_pictures, :format => :json
518 json = JSON.parse response.body
519 json.should have_at_least(3).items
521 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
522 get :ground_pictures, :format => :json
523 json = JSON.parse response.body
524 json.first.has_key?("panel_id").should be_true
525 json.first.has_key?("picture_id").should be_true
526 json.first.has_key?("z").should be_true
530 context '作家権限がないとき' do
535 it 'ステータスコード302 Foundを返す' do
537 response.status.should eq 302
539 it 'サインインページへ遷移する' do
541 response.should redirect_to '/users/sign_in'
545 it 'ステータスコード401 Unauthorizedを返す' do
546 get :ground_pictures, :format => :json
547 response.status.should eq 401
549 it '応答メッセージにUnauthorizedを返す' do
550 get :ground_pictures, :format => :json
551 response.message.should match(/Unauthorized/)
557 describe '自分の色地一覧表示に於いて' do
559 @gc = FactoryGirl.create :ground_color
561 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
563 context 'パラメータpageについて' do
565 get :ground_colors, :page => 5
566 assigns(:page).should eq 5
568 it '省略されると@pageに1値が入る' do
570 assigns(:page).should eq 1
572 it '与えられたpage_sizeがセットされている' do
573 get :ground_colors, :page_size => 15
574 assigns(:page_size).should eq 15
576 it '省略されると@page_sizeにデフォルト値が入る' do
578 assigns(:page_size).should eq Author.default_ground_color_page_size
580 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
581 get :ground_colors, :page_size => 1500
582 assigns(:page_size).should eq Author.ground_color_max_page_size
584 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
585 get :ground_colors, :page_size => 0
586 assigns(:page_size).should eq Author.default_ground_color_page_size
589 context 'つつがなく終わるとき' do
590 it 'ステータスコード200 OKを返す' do
592 response.should be_success
594 it '色地モデルに一覧を問い合わせている' do
595 GroundColor.should_receive(:mylist).exactly(1)
598 it '@ground_colorsにリストを取得している' do
600 assigns(:ground_colors).should have_at_least(3).items
603 it '@paginateにページ制御を取得している' do
605 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
607 it 'ground_colorsテンプレートを描画する' do
609 response.should render_template("ground_colors")
614 get :ground_colors, :format => :json
615 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
617 it '色地モデルにjson一覧出力オプションを問い合わせている' do
618 GroundColor.should_receive(:list_json_opt).exactly(1)
619 get :ground_colors, :format => :json
621 it 'データがリスト構造になっている' do
622 get :ground_colors, :format => :json
623 json = JSON.parse response.body
624 json.should have_at_least(3).items
626 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
627 get :ground_colors, :format => :json
628 json = JSON.parse response.body
629 json.first.has_key?("panel_id").should be_true
630 json.first.has_key?("code").should be_true
631 json.first.has_key?("z").should be_true
635 context '作家権限がないとき' do
640 it 'ステータスコード302 Foundを返す' do
642 response.status.should eq 302
644 it 'サインインページへ遷移する' do
646 response.should redirect_to '/users/sign_in'
650 it 'ステータスコード401 Unauthorizedを返す' do
651 get :ground_colors, :format => :json
652 response.status.should eq 401
654 it '応答メッセージにUnauthorizedを返す' do
655 get :ground_colors, :format => :json
656 response.message.should match(/Unauthorized/)
662 describe '自分の素材一覧表示に於いて' do
664 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
665 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
666 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
668 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
670 context 'パラメータpageについて' do
672 get :resource_pictures, :page => 5
673 assigns(:page).should eq 5
675 it '省略されると@pageに1値が入る' do
676 get :resource_pictures
677 assigns(:page).should eq 1
679 it '与えられたpage_sizeがセットされている' do
680 get :resource_pictures, :page_size => 15
681 assigns(:page_size).should eq 15
683 it '省略されると@page_sizeにデフォルト値が入る' do
684 get :resource_pictures
685 assigns(:page_size).should eq Author.default_resource_picture_page_size
687 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
688 get :resource_pictures, :page_size => 1500
689 assigns(:page_size).should eq Author.resource_picture_max_page_size
691 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
692 get :resource_pictures, :page_size => 0
693 assigns(:page_size).should eq Author.default_resource_picture_page_size
696 context 'つつがなく終わるとき' do
697 it 'ステータスコード200 OKを返す' do
698 get :resource_pictures
699 response.should be_success
701 it '素材モデルに一覧を問い合わせている' do
702 ResourcePicture.should_receive(:mylist).exactly(1)
703 get :resource_pictures
705 it '@resource_picturesにリストを取得している' do
706 get :resource_pictures
707 assigns(:resource_pictures).should have_at_least(3).items
710 it '@paginateにページ制御を取得している' do
711 get :resource_pictures
712 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
714 it 'resource_picturesテンプレートを描画する' do
715 get :resource_pictures
716 response.should render_template("resource_pictures")
721 get :resource_pictures, :format => :json
722 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
724 it '素材モデルにjson一覧出力オプションを問い合わせている' do
725 ResourcePicture.should_receive(:list_json_opt).exactly(1)
726 get :resource_pictures, :format => :json
728 it 'データがリスト構造になっている' do
729 get :resource_pictures, :format => :json
730 json = JSON.parse response.body
731 json.should have_at_least(3).items
733 it 'リストの先頭くらいは素材っぽいものであって欲しい' do
734 get :resource_pictures, :format => :json
735 json = JSON.parse response.body
736 json.first.has_key?("original_picture_id").should be_true
737 json.first.has_key?("license_id").should be_true
741 context '作家権限がないとき' do
746 it 'ステータスコード302 Foundを返す' do
747 get :resource_pictures
748 response.status.should eq 302
750 it 'サインインページへ遷移する' do
751 get :resource_pictures
752 response.should redirect_to '/users/sign_in'
756 it 'ステータスコード401 Unauthorizedを返す' do
757 get :resource_pictures, :format => :json
758 response.status.should eq 401
760 it '応答メッセージにUnauthorizedを返す' do
761 get :resource_pictures, :format => :json
762 response.message.should match(/Unauthorized/)
766 context '作家が絵師でないとき' do
768 Author.any_instance.stub(:artist?).and_return(false)
771 it 'ステータスコード302 Foundを返す' do
772 get :resource_pictures
773 response.status.should eq 302
776 get :resource_pictures
777 response.should redirect_to new_artist_path
781 it '例外403 forbiddenを返す' do
783 get :resource_pictures, :format => :json
784 }.should raise_error(ActiveRecord::Forbidden)
791 describe '自分のコミック一覧表示に於いて' do
793 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
795 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
797 context 'つつがなく終わるとき' do
798 it 'ステータスコード200 OKを返す' do
800 response.should be_success
803 it 'scrollsテンプレートを描画する' do
805 response.should render_template("scrolls")
810 get :scrolls, :format => :json
811 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
815 context '作家権限がないとき' do
820 it 'ステータスコード302 Foundを返す' do
822 response.status.should eq 302
824 it 'サインインページへ遷移する' do
826 response.should redirect_to '/users/sign_in'
830 it 'ステータスコード401 Unauthorizedを返す' do
831 get :scrolls, :format => :json
832 response.status.should eq 401
834 it '応答メッセージにUnauthorizedを返す' do
835 get :scrolls, :format => :json
836 response.message.should match(/Unauthorized/)
842 describe '自分のコマ一覧表示に於いて' do
844 @panel = FactoryGirl.create :panel, :author_id => @author.id
846 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
848 context 'つつがなく終わるとき' do
850 it 'ステータスコード200 OKを返す' do
852 response.should be_success
854 it 'panelsテンプレートを描画する' do
856 response.should render_template("panels")
860 it 'ステータスコード200 OKを返す' do
861 get :panels, :format => :json
862 response.should be_success
865 get :panels, :format => :json
866 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
870 context '作家権限がないとき' do
875 it 'ステータスコード302 Foundを返す' do
877 response.status.should eq 302
879 it 'サインインページへ遷移する' do
881 response.should redirect_to '/users/sign_in'
885 it 'ステータスコード401 Unauthorizedを返す' do
886 get :panels, :format => :json
887 response.status.should eq 401
889 it '応答メッセージにUnauthorizedを返す' do
890 get :panels, :format => :json
891 response.message.should match(/Unauthorized/)
897 describe '自分のコマ絵一覧表示に於いて' do
899 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
900 :width => @p.width, :height => @p.height
902 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
904 context 'つつがなく終わるとき' do
905 it 'ステータスコード200 OKを返す' do
907 response.should be_success
910 it 'panel_picturesテンプレートを描画する' do
912 response.should render_template("panel_pictures")
917 get :panel_pictures, :format => :json
918 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
922 context '作家権限がないとき' do
927 it 'ステータスコード302 Foundを返す' do
929 response.status.should eq 302
931 it 'サインインページへ遷移する' do
933 response.should redirect_to '/users/sign_in'
937 it 'ステータスコード401 Unauthorizedを返す' do
938 get :panel_pictures, :format => :json
939 response.status.should eq 401
941 it '応答メッセージにUnauthorizedを返す' do
942 get :panel_pictures, :format => :json
943 response.message.should match(/Unauthorized/)
950 describe '自分のコマの絵地一覧表示に於いて' do
952 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
954 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
956 context 'つつがなく終わるとき' do
957 it 'ステータスコード200 OKを返す' do
959 response.should be_success
962 it 'ground_picturesテンプレートを描画する' do
964 response.should render_template("ground_pictures")
969 get :ground_pictures, :format => :json
970 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
974 context '作家権限がないとき' do
979 it 'ステータスコード302 Foundを返す' do
981 response.status.should eq 302
983 it 'サインインページへ遷移する' do
985 response.should redirect_to '/users/sign_in'
989 it 'ステータスコード401 Unauthorizedを返す' do
990 get :ground_pictures, :format => :json
991 response.status.should eq 401
993 it '応答メッセージにUnauthorizedを返す' do
994 get :ground_pictures, :format => :json
995 response.message.should match(/Unauthorized/)
1001 describe '自分の色地一覧表示に於いて' do
1003 @gc = FactoryGirl.create :ground_color
1005 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
1007 context 'つつがなく終わるとき' do
1008 it 'ステータスコード200 OKを返す' do
1010 response.should be_success
1013 it 'ground_colorsテンプレートを描画する' do
1015 response.should render_template("ground_colors")
1020 get :ground_colors, :format => :json
1021 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1025 context '作家権限がないとき' do
1030 it 'ステータスコード302 Foundを返す' do
1032 response.status.should eq 302
1034 it 'サインインページへ遷移する' do
1036 response.should redirect_to '/users/sign_in'
1040 it 'ステータスコード401 Unauthorizedを返す' do
1041 get :ground_colors, :format => :json
1042 response.status.should eq 401
1044 it '応答メッセージにUnauthorizedを返す' do
1045 get :ground_colors, :format => :json
1046 response.message.should match(/Unauthorized/)
1052 describe '自分の素材一覧表示に於いて' do
1054 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1055 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1056 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1058 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
1060 context 'つつがなく終わるとき' do
1061 it 'ステータスコード200 OKを返す' do
1062 get :resource_pictures
1063 response.should be_success
1066 it 'resource_picturesテンプレートを描画する' do
1067 get :resource_pictures
1068 response.should render_template("resource_pictures")
1073 get :resource_pictures, :format => :json
1074 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1078 context '作家権限がないとき' do
1083 it 'ステータスコード302 Foundを返す' do
1084 get :resource_pictures
1085 response.status.should eq 302
1087 it 'サインインページへ遷移する' do
1088 get :resource_pictures
1089 response.should redirect_to '/users/sign_in'
1093 it 'ステータスコード401 Unauthorizedを返す' do
1094 get :resource_pictures, :format => :json
1095 response.status.should eq 401
1097 it '応答メッセージにUnauthorizedを返す' do
1098 get :resource_pictures, :format => :json
1099 response.message.should match(/Unauthorized/)
1103 context '作家が絵師でないとき' do
1108 it 'ステータスコード302 Foundを返す' do
1109 get :resource_pictures
1110 response.status.should eq 302
1112 it '絵師登録ページへ遷移する' do
1113 get :resource_pictures
1114 response.should redirect_to new_artist_path
1118 it '例外403 forbiddenを返す' do
1120 get :resource_pictures, :format => :json
1121 }.should raise_error(ActiveRecord::Forbidden)