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 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
131 @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id
133 ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
135 context 'パラメータpageについて' do
137 get :scroll_panels, :page => 5
138 assigns(:page).should eq 5
140 it '省略されると@pageに1値が入る' do
142 assigns(:page).should eq 1
144 it '与えられたpage_sizeがセットされている' do
145 get :scroll_panels, :page_size => 15
146 assigns(:page_size).should eq 15
148 it '省略されると@page_sizeにデフォルト値が入る' do
150 assigns(:page_size).should eq Author.default_scroll_panel_page_size
152 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
153 get :scroll_panels, :page_size => 1500
154 assigns(:page_size).should eq Author.scroll_panel_max_page_size
156 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
157 get :scroll_panels, :page_size => 0
158 assigns(:page_size).should eq Author.default_scroll_panel_page_size
161 context 'つつがなく終わるとき' do
162 it 'ステータスコード200 OKを返す' do
164 response.should be_success
166 it 'スクコマモデルに一覧を問い合わせている' do
167 ScrollPanel.should_receive(:mylist).exactly(1)
170 it '@scroll_panelsにリストを取得している' do
172 assigns(:scroll_panels).should have_at_least(3).items
175 it '@paginateにページ制御を取得している' do
177 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
179 it 'scroll_panelsテンプレートを描画する' do
181 response.should render_template("scroll_panels")
186 get :scroll_panels, :format => :json
187 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
189 it 'スクコマモデルにjson一覧出力オプションを問い合わせている' do
190 ScrollPanel.should_receive(:list_json_opt).exactly(1)
191 get :scroll_panels, :format => :json
193 it 'データがリスト構造になっている' do
194 get :scroll_panels, :format => :json
195 json = JSON.parse response.body
196 json.should have_at_least(3).items
198 it 'リストの先頭くらいはスクコマっぽいものであって欲しい' do
199 get :scroll_panels, :format => :json
200 json = JSON.parse response.body
201 json.first.has_key?("scroll_id").should be_true
202 json.first.has_key?("panel_id").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 :scroll_panels, :format => :json
223 response.status.should eq 401
225 it '応答メッセージにUnauthorizedを返す' do
226 get :scroll_panels, :format => :json
227 response.message.should match(/Unauthorized/)
233 describe '自分のコミック一覧表示に於いて' do
235 @comic = FactoryGirl.create :comic, :author_id => @author.id
237 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
239 context 'パラメータpageについて' do
241 get :comics, :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 :comics, :page_size => 15
250 assigns(:page_size).should eq 15
252 it '省略されると@page_sizeにデフォルト値が入る' do
254 assigns(:page_size).should eq Author.default_comic_page_size
256 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
257 get :comics, :page_size => 1500
258 assigns(:page_size).should eq Author.comic_max_page_size
260 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
261 get :comics, :page_size => 0
262 assigns(:page_size).should eq Author.default_comic_page_size
265 context 'つつがなく終わるとき' do
266 it 'ステータスコード200 OKを返す' do
268 response.should be_success
270 it 'コミックモデルに一覧を問い合わせている' do
271 Comic.should_receive(:mylist).exactly(1)
274 it '@comicsにリストを取得している' do
276 assigns(:comics).should have_at_least(3).items
279 it '@paginateにページ制御を取得している' do
281 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
283 it 'comicsテンプレートを描画する' do
285 response.should render_template("comics")
290 get :comics, :format => :json
291 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
293 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
294 Comic.should_receive(:list_json_opt).exactly(1)
295 get :comics, :format => :json
297 it 'データがリスト構造になっている' do
298 get :comics, :format => :json
299 json = JSON.parse response.body
300 json.should have_at_least(3).items
302 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
303 get :comics, :format => :json
304 json = JSON.parse response.body
305 json.first.has_key?("title").should be_true
306 json.first.has_key?("visible").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 :comics, :format => :json
327 response.status.should eq 401
329 it '応答メッセージにUnauthorizedを返す' do
330 get :comics, :format => :json
331 response.message.should match(/Unauthorized/)
337 describe '自分のストーリー一覧表示に於いて' do
339 @comic = FactoryGirl.create :comic, :author_id => @author.id
340 @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
342 Story.stub(:mylist).and_return([@story, @story, @story])
344 context 'パラメータpageについて' do
346 get :stories, :page => 5
347 assigns(:page).should eq 5
349 it '省略されると@pageに1値が入る' do
351 assigns(:page).should eq 1
353 it '与えられたpage_sizeがセットされている' do
354 get :stories, :page_size => 15
355 assigns(:page_size).should eq 15
357 it '省略されると@page_sizeにデフォルト値が入る' do
359 assigns(:page_size).should eq Author.default_story_page_size
361 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
362 get :stories, :page_size => 1500
363 assigns(:page_size).should eq Author.story_max_page_size
365 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
366 get :stories, :page_size => 0
367 assigns(:page_size).should eq Author.default_story_page_size
370 context 'つつがなく終わるとき' do
371 it 'ステータスコード200 OKを返す' do
373 response.should be_success
375 it 'ストーリーモデルに一覧を問い合わせている' do
376 Story.should_receive(:mylist).exactly(1)
379 it '@storiesにリストを取得している' do
381 assigns(:stories).should have_at_least(3).items
384 it '@paginateにページ制御を取得している' do
386 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
388 it 'storiesテンプレートを描画する' do
390 response.should render_template("stories")
395 get :stories, :format => :json
396 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
398 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
399 Story.should_receive(:list_json_opt).exactly(1)
400 get :stories, :format => :json
402 it 'データがリスト構造になっている' do
403 get :stories, :format => :json
404 json = JSON.parse response.body
405 json.should have_at_least(3).items
407 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
408 get :stories, :format => :json
409 json = JSON.parse response.body
410 json.first.has_key?("comic_id").should be_true
411 json.first.has_key?("title").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 :stories, :format => :json
432 response.status.should eq 401
434 it '応答メッセージにUnauthorizedを返す' do
435 get :stories, :format => :json
436 response.message.should match(/Unauthorized/)
442 describe '自分のスト紙一覧表示に於いて' do
444 @comic = FactoryGirl.create :comic, :author_id => @author.id
445 @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
446 @sheet = FactoryGirl.create :sheet, :author_id => @author.id
447 @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
449 StorySheet.stub(:mylist).and_return([@story_sheet, @story_sheet, @story_sheet])
451 context 'パラメータpageについて' do
453 get :story_sheets, :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 :story_sheets, :page_size => 15
462 assigns(:page_size).should eq 15
464 it '省略されると@page_sizeにデフォルト値が入る' do
466 assigns(:page_size).should eq Author.default_story_sheet_page_size
468 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
469 get :story_sheets, :page_size => 1500
470 assigns(:page_size).should eq Author.story_sheet_max_page_size
472 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
473 get :story_sheets, :page_size => 0
474 assigns(:page_size).should eq Author.default_story_sheet_page_size
477 context 'つつがなく終わるとき' do
478 it 'ステータスコード200 OKを返す' do
480 response.should be_success
482 it 'スト紙モデルに一覧を問い合わせている' do
483 StorySheet.should_receive(:mylist).exactly(1)
486 it '@story_sheetsにリストを取得している' do
488 assigns(:story_sheets).should have_at_least(3).items
491 it '@paginateにページ制御を取得している' do
493 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
495 it 'story_sheetsテンプレートを描画する' do
497 response.should render_template("story_sheets")
502 get :story_sheets, :format => :json
503 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
505 it 'スト紙モデルにjson一覧出力オプションを問い合わせている' do
506 StorySheet.should_receive(:list_json_opt).exactly(1)
507 get :story_sheets, :format => :json
509 it 'データがリスト構造になっている' do
510 get :story_sheets, :format => :json
511 json = JSON.parse response.body
512 json.should have_at_least(3).items
514 it 'リストの先頭くらいはスト紙っぽいものであって欲しい' do
515 get :story_sheets, :format => :json
516 json = JSON.parse response.body
517 json.first.has_key?("story_id").should be_true
518 json.first.has_key?("sheet_id").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 :story_sheets, :format => :json
539 response.status.should eq 401
541 it '応答メッセージにUnauthorizedを返す' do
542 get :story_sheets, :format => :json
543 response.message.should match(/Unauthorized/)
549 describe '自分の用紙一覧表示に於いて' do
551 @sheet = FactoryGirl.create :sheet, :author_id => @author.id
553 Sheet.stub(:mylist).and_return([@sheet, @sheet, @sheet])
555 context 'パラメータpageについて' do
557 get :sheets, :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 :sheets, :page_size => 15
566 assigns(:page_size).should eq 15
568 it '省略されると@page_sizeにデフォルト値が入る' do
570 assigns(:page_size).should eq Author.default_sheet_page_size
572 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
573 get :sheets, :page_size => 1500
574 assigns(:page_size).should eq Author.sheet_max_page_size
576 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
577 get :sheets, :page_size => 0
578 assigns(:page_size).should eq Author.default_sheet_page_size
581 context 'つつがなく終わるとき' do
582 it 'ステータスコード200 OKを返す' do
584 response.should be_success
586 it '用紙モデルに一覧を問い合わせている' do
587 Sheet.should_receive(:mylist).exactly(1)
590 it '@sheetsにリストを取得している' do
592 assigns(:sheets).should have_at_least(3).items
595 it '@paginateにページ制御を取得している' do
597 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
599 it 'sheetsテンプレートを描画する' do
601 response.should render_template("sheets")
606 get :sheets, :format => :json
607 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
609 it '用紙モデルにjson一覧出力オプションを問い合わせている' do
610 Sheet.should_receive(:list_json_opt).exactly(1)
611 get :sheets, :format => :json
613 it 'データがリスト構造になっている' do
614 get :sheets, :format => :json
615 json = JSON.parse response.body
616 json.should have_at_least(3).items
618 it 'リストの先頭くらいは用紙っぽいものであって欲しい' do
619 get :sheets, :format => :json
620 json = JSON.parse response.body
621 json.first.has_key?("caption").should be_true
622 json.first.has_key?("visible").should be_true
626 context '作家権限がないとき' do
631 it 'ステータスコード302 Foundを返す' do
633 response.status.should eq 302
635 it 'サインインページへ遷移する' do
637 response.should redirect_to '/users/sign_in'
641 it 'ステータスコード401 Unauthorizedを返す' do
642 get :sheets, :format => :json
643 response.status.should eq 401
645 it '応答メッセージにUnauthorizedを返す' do
646 get :sheets, :format => :json
647 response.message.should match(/Unauthorized/)
653 describe '自分の紙コマ一覧表示に於いて' do
655 @sheet = FactoryGirl.create :sheet, :author_id => @user.author.id
656 @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
658 SheetPanel.stub(:mylist).and_return([@sheet_panel, @sheet_panel, @sheet_panel])
660 context 'パラメータpageについて' do
662 get :sheet_panels, :page => 5
663 assigns(:page).should eq 5
665 it '省略されると@pageに1値が入る' do
667 assigns(:page).should eq 1
669 it '与えられたpage_sizeがセットされている' do
670 get :sheet_panels, :page_size => 15
671 assigns(:page_size).should eq 15
673 it '省略されると@page_sizeにデフォルト値が入る' do
675 assigns(:page_size).should eq Author.default_sheet_panel_page_size
677 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
678 get :sheet_panels, :page_size => 1500
679 assigns(:page_size).should eq Author.sheet_panel_max_page_size
681 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
682 get :sheet_panels, :page_size => 0
683 assigns(:page_size).should eq Author.default_sheet_panel_page_size
686 context 'つつがなく終わるとき' do
687 it 'ステータスコード200 OKを返す' do
689 response.should be_success
691 it '紙コマモデルに一覧を問い合わせている' do
692 SheetPanel.should_receive(:mylist).exactly(1)
695 it '@sheet_panelsにリストを取得している' do
697 assigns(:sheet_panels).should have_at_least(3).items
700 it '@paginateにページ制御を取得している' do
702 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
704 it 'sheet_panelsテンプレートを描画する' do
706 response.should render_template("sheet_panels")
711 get :sheet_panels, :format => :json
712 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
714 it '紙コマモデルにjson一覧出力オプションを問い合わせている' do
715 SheetPanel.should_receive(:list_json_opt).exactly(1)
716 get :sheet_panels, :format => :json
718 it 'データがリスト構造になっている' do
719 get :sheet_panels, :format => :json
720 json = JSON.parse response.body
721 json.should have_at_least(3).items
723 it 'リストの先頭くらいは紙コマっぽいものであって欲しい' do
724 get :sheet_panels, :format => :json
725 json = JSON.parse response.body
726 json.first.has_key?("panel_id").should be_true
727 json.first.has_key?("sheet_id").should be_true
731 context '作家権限がないとき' do
736 it 'ステータスコード302 Foundを返す' do
738 response.status.should eq 302
740 it 'サインインページへ遷移する' do
742 response.should redirect_to '/users/sign_in'
746 it 'ステータスコード401 Unauthorizedを返す' do
747 get :sheet_panels, :format => :json
748 response.status.should eq 401
750 it '応答メッセージにUnauthorizedを返す' do
751 get :sheet_panels, :format => :json
752 response.message.should match(/Unauthorized/)
758 describe '自分のコマ一覧表示に於いて' do
760 @panel = FactoryGirl.create :panel, :author_id => @author.id
762 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
764 context 'パラメータpageについて' do
766 get :panels, :page => 5
767 assigns(:page).should eq 5
769 it '省略されると@pageに1値が入る' do
771 assigns(:page).should eq 1
773 it '与えられたpage_sizeがセットされている' do
774 get :panels, :page_size => 15
775 assigns(:page_size).should eq 15
777 it '省略されると@page_sizeにデフォルト値が入る' do
779 assigns(:page_size).should eq Author.default_panel_page_size
781 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
782 get :panels, :page_size => 1500
783 assigns(:page_size).should eq Author.panel_max_page_size
785 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
786 get :panels, :page_size => 0
787 assigns(:page_size).should eq Author.default_panel_page_size
790 context 'つつがなく終わるとき' do
791 it 'コマモデルに一覧を問い合わせている' do
792 Panel.should_receive(:mylist).exactly(1)
795 it '@panelsにリストを取得している' do
797 assigns(:panels).should have_at_least(3).items
800 it '@paginateにページ制御を取得している' do
802 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
804 it 'ステータスコード200 OKを返す' do
806 response.should be_success
808 it 'panelsテンプレートを描画する' do
810 response.should render_template("panels")
814 it 'ステータスコード200 OKを返す' do
815 get :panels, :format => :json
816 response.should be_success
819 get :panels, :format => :json
820 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
822 it 'コマモデルにコマリストのjson出力を問い合わせている' do
823 Panel.should_receive(:list_as_json_text).exactly(1)
824 get :panels, :format => :json
826 it 'データがリスト構造になっている' do
827 get :panels, :format => :json
828 json = JSON.parse response.body
829 json.should have_at_least(3).items
831 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
832 get :panels, :format => :json
833 json = JSON.parse response.body
834 json.first.has_key?("z").should be_true
838 context '作家権限がないとき' do
843 it 'ステータスコード302 Foundを返す' do
845 response.status.should eq 302
847 it 'サインインページへ遷移する' do
849 response.should redirect_to '/users/sign_in'
853 it 'ステータスコード401 Unauthorizedを返す' do
854 get :panels, :format => :json
855 response.status.should eq 401
857 it '応答メッセージにUnauthorizedを返す' do
858 get :panels, :format => :json
859 response.message.should match(/Unauthorized/)
865 describe '自分のコマ絵一覧表示に於いて' do
867 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
868 :width => @p.width, :height => @p.height
870 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
872 context 'パラメータpageについて' do
874 get :panel_pictures, :page => 5
875 assigns(:page).should eq 5
877 it '省略されると@pageに1値が入る' do
879 assigns(:page).should eq 1
881 it '与えられたpage_sizeがセットされている' do
882 get :panel_pictures, :page_size => 15
883 assigns(:page_size).should eq 15
885 it '省略されると@page_sizeにデフォルト値が入る' do
887 assigns(:page_size).should eq Author.default_panel_picture_page_size
889 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
890 get :panel_pictures, :page_size => 1500
891 assigns(:page_size).should eq Author.panel_picture_max_page_size
893 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
894 get :panel_pictures, :page_size => 0
895 assigns(:page_size).should eq Author.default_panel_picture_page_size
898 context 'つつがなく終わるとき' do
899 it 'ステータスコード200 OKを返す' do
900 response.should be_success
902 it 'コマ絵モデルに一覧を問い合わせている' do
903 PanelPicture.should_receive(:mylist).exactly(1)
906 it '@panel_picturesにリストを取得している' do
908 assigns(:panel_pictures).should have_at_least(3).items
911 it '@paginateにページ制御を取得している' do
913 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
915 it 'panel_picturesテンプレートを描画する' do
917 response.should render_template("panel_pictures")
922 get :panel_pictures, :format => :json
923 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
925 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
926 PanelPicture.should_receive(:list_json_opt).exactly(1)
927 get :panel_pictures, :format => :json
929 it 'データがリスト構造になっている' do
930 get :panel_pictures, :format => :json
931 json = JSON.parse response.body
932 json.should have_at_least(3).items
934 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
935 get :panel_pictures, :format => :json
936 json = JSON.parse response.body
937 json.first.has_key?("link").should be_true
938 json.first.has_key?("x").should be_true
939 json.first.has_key?("y").should be_true
943 context '作家権限がないとき' do
948 it 'ステータスコード302 Foundを返す' do
950 response.status.should eq 302
952 it 'サインインページへ遷移する' do
954 response.should redirect_to '/users/sign_in'
958 it 'ステータスコード401 Unauthorizedを返す' do
959 get :panel_pictures, :format => :json
960 response.status.should eq 401
962 it '応答メッセージにUnauthorizedを返す' do
963 get :panel_pictures, :format => :json
964 response.message.should match(/Unauthorized/)
970 describe '自分のフキダシ一覧表示に於いて' do
972 @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
973 @speech = @sb.build_speech(
974 FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
976 @balloon = @sb.build_balloon(
977 FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
982 SpeechBalloon.stub(:mylist).and_return([@sb, @sb, @sb])
984 context 'パラメータpageについて' do
986 get :speech_balloons, :page => 5
987 assigns(:page).should eq 5
989 it '省略されると@pageに1値が入る' do
991 assigns(:page).should eq 1
993 it '与えられたpage_sizeがセットされている' do
994 get :speech_balloons, :page_size => 15
995 assigns(:page_size).should eq 15
997 it '省略されると@page_sizeにデフォルト値が入る' do
999 assigns(:page_size).should eq Author.default_speech_balloon_page_size
1001 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1002 get :speech_balloons, :page_size => 1500
1003 assigns(:page_size).should eq Author.speech_balloon_max_page_size
1005 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1006 get :speech_balloons, :page_size => 0
1007 assigns(:page_size).should eq Author.default_speech_balloon_page_size
1010 context 'つつがなく終わるとき' do
1011 it 'ステータスコード200 OKを返す' do
1012 response.should be_success
1014 it 'フキダシモデルに一覧を問い合わせている' do
1015 SpeechBalloon.should_receive(:mylist).exactly(1)
1016 get :speech_balloons
1018 it '@speech_balloonsにリストを取得している' do
1019 get :speech_balloons
1020 assigns(:speech_balloons).should have_at_least(3).items
1023 it '@paginateにページ制御を取得している' do
1024 get :speech_balloons
1025 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1027 it 'speech_balloonsテンプレートを描画する' do
1028 get :speech_balloons
1029 response.should render_template("speech_balloons")
1034 get :speech_balloons, :format => :json
1035 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1037 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
1038 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
1039 get :speech_balloons, :format => :json
1041 it 'データがリスト構造になっている' do
1042 get :speech_balloons, :format => :json
1043 json = JSON.parse response.body
1044 json.should have_at_least(3).items
1046 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
1047 get :speech_balloons, :format => :json
1048 json = JSON.parse response.body
1049 json.first.has_key?("speech_balloon_template_id").should be_true
1050 json.first.has_key?("z").should be_true
1051 json.first.has_key?("t").should be_true
1055 context '作家権限がないとき' do
1060 it 'ステータスコード302 Foundを返す' do
1061 get :speech_balloons
1062 response.status.should eq 302
1064 it 'サインインページへ遷移する' do
1065 get :speech_balloons
1066 response.should redirect_to '/users/sign_in'
1070 it 'ステータスコード401 Unauthorizedを返す' do
1071 get :speech_balloons, :format => :json
1072 response.status.should eq 401
1074 it '応答メッセージにUnauthorizedを返す' do
1075 get :speech_balloons, :format => :json
1076 response.message.should match(/Unauthorized/)
1082 describe '自分のコマの絵地一覧表示に於いて' do
1084 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1086 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
1088 context 'パラメータpageについて' do
1090 get :ground_pictures, :page => 5
1091 assigns(:page).should eq 5
1093 it '省略されると@pageに1値が入る' do
1094 get :ground_pictures
1095 assigns(:page).should eq 1
1097 it '与えられたpage_sizeがセットされている' do
1098 get :ground_pictures, :page_size => 15
1099 assigns(:page_size).should eq 15
1101 it '省略されると@page_sizeにデフォルト値が入る' do
1102 get :ground_pictures
1103 assigns(:page_size).should eq Author.default_ground_picture_page_size
1105 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1106 get :ground_pictures, :page_size => 1500
1107 assigns(:page_size).should eq Author.ground_picture_max_page_size
1109 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1110 get :ground_pictures, :page_size => 0
1111 assigns(:page_size).should eq Author.default_ground_picture_page_size
1114 context 'つつがなく終わるとき' do
1115 it 'ステータスコード200 OKを返す' do
1116 get :ground_pictures
1117 response.should be_success
1119 it '絵地モデルに一覧を問い合わせている' do
1120 GroundPicture.should_receive(:mylist).exactly(1)
1121 get :ground_pictures
1123 it '@ground_picturesにリストを取得している' do
1124 get :ground_pictures
1125 assigns(:ground_pictures).should have_at_least(3).items
1128 it '@paginateにページ制御を取得している' do
1129 get :ground_pictures
1130 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1132 it 'ground_picturesテンプレートを描画する' do
1133 get :ground_pictures
1134 response.should render_template("ground_pictures")
1139 get :ground_pictures, :format => :json
1140 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1142 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
1143 GroundPicture.should_receive(:list_json_opt).exactly(1)
1144 get :ground_pictures, :format => :json
1146 it 'データがリスト構造になっている' do
1147 get :ground_pictures, :format => :json
1148 json = JSON.parse response.body
1149 json.should have_at_least(3).items
1151 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
1152 get :ground_pictures, :format => :json
1153 json = JSON.parse response.body
1154 json.first.has_key?("panel_id").should be_true
1155 json.first.has_key?("picture_id").should be_true
1156 json.first.has_key?("z").should be_true
1160 context '作家権限がないとき' do
1165 it 'ステータスコード302 Foundを返す' do
1166 get :ground_pictures
1167 response.status.should eq 302
1169 it 'サインインページへ遷移する' do
1170 get :ground_pictures
1171 response.should redirect_to '/users/sign_in'
1175 it 'ステータスコード401 Unauthorizedを返す' do
1176 get :ground_pictures, :format => :json
1177 response.status.should eq 401
1179 it '応答メッセージにUnauthorizedを返す' do
1180 get :ground_pictures, :format => :json
1181 response.message.should match(/Unauthorized/)
1187 describe '自分の色地一覧表示に於いて' do
1189 @gc = FactoryGirl.create :ground_color
1191 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
1193 context 'パラメータpageについて' do
1195 get :ground_colors, :page => 5
1196 assigns(:page).should eq 5
1198 it '省略されると@pageに1値が入る' do
1200 assigns(:page).should eq 1
1202 it '与えられたpage_sizeがセットされている' do
1203 get :ground_colors, :page_size => 15
1204 assigns(:page_size).should eq 15
1206 it '省略されると@page_sizeにデフォルト値が入る' do
1208 assigns(:page_size).should eq Author.default_ground_color_page_size
1210 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1211 get :ground_colors, :page_size => 1500
1212 assigns(:page_size).should eq Author.ground_color_max_page_size
1214 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1215 get :ground_colors, :page_size => 0
1216 assigns(:page_size).should eq Author.default_ground_color_page_size
1219 context 'つつがなく終わるとき' do
1220 it 'ステータスコード200 OKを返す' do
1222 response.should be_success
1224 it '色地モデルに一覧を問い合わせている' do
1225 GroundColor.should_receive(:mylist).exactly(1)
1228 it '@ground_colorsにリストを取得している' do
1230 assigns(:ground_colors).should have_at_least(3).items
1233 it '@paginateにページ制御を取得している' do
1235 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1237 it 'ground_colorsテンプレートを描画する' do
1239 response.should render_template("ground_colors")
1244 get :ground_colors, :format => :json
1245 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1247 it '色地モデルにjson一覧出力オプションを問い合わせている' do
1248 GroundColor.should_receive(:list_json_opt).exactly(1)
1249 get :ground_colors, :format => :json
1251 it 'データがリスト構造になっている' do
1252 get :ground_colors, :format => :json
1253 json = JSON.parse response.body
1254 json.should have_at_least(3).items
1256 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
1257 get :ground_colors, :format => :json
1258 json = JSON.parse response.body
1259 json.first.has_key?("panel_id").should be_true
1260 json.first.has_key?("code").should be_true
1261 json.first.has_key?("z").should be_true
1265 context '作家権限がないとき' do
1270 it 'ステータスコード302 Foundを返す' do
1272 response.status.should eq 302
1274 it 'サインインページへ遷移する' do
1276 response.should redirect_to '/users/sign_in'
1280 it 'ステータスコード401 Unauthorizedを返す' do
1281 get :ground_colors, :format => :json
1282 response.status.should eq 401
1284 it '応答メッセージにUnauthorizedを返す' do
1285 get :ground_colors, :format => :json
1286 response.message.should match(/Unauthorized/)
1292 describe '自分の素材一覧表示に於いて' do
1294 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1295 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1296 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1298 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
1300 context 'パラメータpageについて' do
1302 get :resource_pictures, :page => 5
1303 assigns(:page).should eq 5
1305 it '省略されると@pageに1値が入る' do
1306 get :resource_pictures
1307 assigns(:page).should eq 1
1309 it '与えられたpage_sizeがセットされている' do
1310 get :resource_pictures, :page_size => 15
1311 assigns(:page_size).should eq 15
1313 it '省略されると@page_sizeにデフォルト値が入る' do
1314 get :resource_pictures
1315 assigns(:page_size).should eq Author.default_resource_picture_page_size
1317 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1318 get :resource_pictures, :page_size => 1500
1319 assigns(:page_size).should eq Author.resource_picture_max_page_size
1321 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1322 get :resource_pictures, :page_size => 0
1323 assigns(:page_size).should eq Author.default_resource_picture_page_size
1326 context 'つつがなく終わるとき' do
1327 it 'ステータスコード200 OKを返す' do
1328 get :resource_pictures
1329 response.should be_success
1331 it '素材モデルに一覧を問い合わせている' do
1332 ResourcePicture.should_receive(:mylist).exactly(1)
1333 get :resource_pictures
1335 it '@resource_picturesにリストを取得している' do
1336 get :resource_pictures
1337 assigns(:resource_pictures).should have_at_least(3).items
1340 it '@paginateにページ制御を取得している' do
1341 get :resource_pictures
1342 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1344 it 'resource_picturesテンプレートを描画する' do
1345 get :resource_pictures
1346 response.should render_template("resource_pictures")
1351 get :resource_pictures, :format => :json
1352 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1354 it '素材モデルにjson一覧出力オプションを問い合わせている' do
1355 ResourcePicture.should_receive(:list_json_opt).exactly(1)
1356 get :resource_pictures, :format => :json
1358 it 'データがリスト構造になっている' do
1359 get :resource_pictures, :format => :json
1360 json = JSON.parse response.body
1361 json.should have_at_least(3).items
1363 it 'リストの先頭くらいは素材っぽいものであって欲しい' do
1364 get :resource_pictures, :format => :json
1365 json = JSON.parse response.body
1366 json.first.has_key?("original_picture_id").should be_true
1367 json.first.has_key?("license_id").should be_true
1371 context '作家権限がないとき' do
1376 it 'ステータスコード302 Foundを返す' do
1377 get :resource_pictures
1378 response.status.should eq 302
1380 it 'サインインページへ遷移する' do
1381 get :resource_pictures
1382 response.should redirect_to '/users/sign_in'
1386 it 'ステータスコード401 Unauthorizedを返す' do
1387 get :resource_pictures, :format => :json
1388 response.status.should eq 401
1390 it '応答メッセージにUnauthorizedを返す' do
1391 get :resource_pictures, :format => :json
1392 response.message.should match(/Unauthorized/)
1396 context '作家が絵師でないとき' do
1398 Author.any_instance.stub(:artist?).and_return(false)
1401 it 'ステータスコード302 Foundを返す' do
1402 get :resource_pictures
1403 response.status.should eq 302
1405 it '絵師登録ページへ遷移する' do
1406 get :resource_pictures
1407 response.should redirect_to new_artist_path
1411 it '例外403 forbiddenを返す' do
1413 get :resource_pictures, :format => :json
1414 }.should raise_error(ActiveRecord::Forbidden)
1421 describe '自分のスクロール一覧表示に於いて' do
1423 @scroll = FactoryGirl.create :scroll, :author_id => @author.id
1425 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
1427 context 'つつがなく終わるとき' do
1428 it 'ステータスコード200 OKを返す' do
1430 response.should be_success
1433 it 'scrollsテンプレートを描画する' do
1435 response.should render_template("scrolls")
1440 get :scrolls, :format => :json
1441 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1445 context '作家権限がないとき' do
1450 it 'ステータスコード302 Foundを返す' do
1452 response.status.should eq 302
1454 it 'サインインページへ遷移する' do
1456 response.should redirect_to '/users/sign_in'
1460 it 'ステータスコード401 Unauthorizedを返す' do
1461 get :scrolls, :format => :json
1462 response.status.should eq 401
1464 it '応答メッセージにUnauthorizedを返す' do
1465 get :scrolls, :format => :json
1466 response.message.should match(/Unauthorized/)
1472 describe '自分のコマ一覧表示に於いて' do
1474 @panel = FactoryGirl.create :panel, :author_id => @author.id
1476 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
1478 context 'つつがなく終わるとき' do
1480 it 'ステータスコード200 OKを返す' do
1482 response.should be_success
1484 it 'panelsテンプレートを描画する' do
1486 response.should render_template("panels")
1490 it 'ステータスコード200 OKを返す' do
1491 get :panels, :format => :json
1492 response.should be_success
1495 get :panels, :format => :json
1496 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1500 context '作家権限がないとき' do
1505 it 'ステータスコード302 Foundを返す' do
1507 response.status.should eq 302
1509 it 'サインインページへ遷移する' do
1511 response.should redirect_to '/users/sign_in'
1515 it 'ステータスコード401 Unauthorizedを返す' do
1516 get :panels, :format => :json
1517 response.status.should eq 401
1519 it '応答メッセージにUnauthorizedを返す' do
1520 get :panels, :format => :json
1521 response.message.should match(/Unauthorized/)
1527 describe '自分のコマ絵一覧表示に於いて' do
1529 @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
1530 :width => @p.width, :height => @p.height
1532 PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
1534 context 'つつがなく終わるとき' do
1535 it 'ステータスコード200 OKを返す' do
1537 response.should be_success
1540 it 'panel_picturesテンプレートを描画する' do
1542 response.should render_template("panel_pictures")
1547 get :panel_pictures, :format => :json
1548 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1552 context '作家権限がないとき' do
1557 it 'ステータスコード302 Foundを返す' do
1559 response.status.should eq 302
1561 it 'サインインページへ遷移する' do
1563 response.should redirect_to '/users/sign_in'
1567 it 'ステータスコード401 Unauthorizedを返す' do
1568 get :panel_pictures, :format => :json
1569 response.status.should eq 401
1571 it '応答メッセージにUnauthorizedを返す' do
1572 get :panel_pictures, :format => :json
1573 response.message.should match(/Unauthorized/)
1580 describe '自分のコマの絵地一覧表示に於いて' do
1582 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1584 GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
1586 context 'つつがなく終わるとき' do
1587 it 'ステータスコード200 OKを返す' do
1588 get :ground_pictures
1589 response.should be_success
1592 it 'ground_picturesテンプレートを描画する' do
1593 get :ground_pictures
1594 response.should render_template("ground_pictures")
1599 get :ground_pictures, :format => :json
1600 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1604 context '作家権限がないとき' do
1609 it 'ステータスコード302 Foundを返す' do
1610 get :ground_pictures
1611 response.status.should eq 302
1613 it 'サインインページへ遷移する' do
1614 get :ground_pictures
1615 response.should redirect_to '/users/sign_in'
1619 it 'ステータスコード401 Unauthorizedを返す' do
1620 get :ground_pictures, :format => :json
1621 response.status.should eq 401
1623 it '応答メッセージにUnauthorizedを返す' do
1624 get :ground_pictures, :format => :json
1625 response.message.should match(/Unauthorized/)
1631 describe '自分の色地一覧表示に於いて' do
1633 @gc = FactoryGirl.create :ground_color
1635 GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
1637 context 'つつがなく終わるとき' do
1638 it 'ステータスコード200 OKを返す' do
1640 response.should be_success
1643 it 'ground_colorsテンプレートを描画する' do
1645 response.should render_template("ground_colors")
1650 get :ground_colors, :format => :json
1651 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1655 context '作家権限がないとき' do
1660 it 'ステータスコード302 Foundを返す' do
1662 response.status.should eq 302
1664 it 'サインインページへ遷移する' do
1666 response.should redirect_to '/users/sign_in'
1670 it 'ステータスコード401 Unauthorizedを返す' do
1671 get :ground_colors, :format => :json
1672 response.status.should eq 401
1674 it '応答メッセージにUnauthorizedを返す' do
1675 get :ground_colors, :format => :json
1676 response.message.should match(/Unauthorized/)
1682 describe '自分の素材一覧表示に於いて' do
1684 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1685 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1686 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1688 ResourcePicture.stub(:mylist).and_return([@rp, @rp, @rp])
1690 context 'つつがなく終わるとき' do
1691 it 'ステータスコード200 OKを返す' do
1692 get :resource_pictures
1693 response.should be_success
1696 it 'resource_picturesテンプレートを描画する' do
1697 get :resource_pictures
1698 response.should render_template("resource_pictures")
1703 get :resource_pictures, :format => :json
1704 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1708 context '作家権限がないとき' do
1713 it 'ステータスコード302 Foundを返す' do
1714 get :resource_pictures
1715 response.status.should eq 302
1717 it 'サインインページへ遷移する' do
1718 get :resource_pictures
1719 response.should redirect_to '/users/sign_in'
1723 it 'ステータスコード401 Unauthorizedを返す' do
1724 get :resource_pictures, :format => :json
1725 response.status.should eq 401
1727 it '応答メッセージにUnauthorizedを返す' do
1728 get :resource_pictures, :format => :json
1729 response.message.should match(/Unauthorized/)
1733 context '作家が絵師でないとき' do
1738 it 'ステータスコード302 Foundを返す' do
1739 get :resource_pictures
1740 response.status.should eq 302
1742 it '絵師登録ページへ遷移する' do
1743 get :resource_pictures
1744 response.should redirect_to new_artist_path
1748 it '例外403 forbiddenを返す' do
1750 get :resource_pictures, :format => :json
1751 }.should raise_error(ActiveRecord::Forbidden)