1 # -*- encoding: utf-8 -*-
5 describe AuthorsController 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
19 if MagicNumber['run_mode'] == 1
20 describe '一覧表示に於いて' do
22 Author.stub(:list).and_return([@author, @author, @author])
26 it '与えられたpageがセットされている' do
27 get :index, :page => 5
28 assigns(:page).should eq 5
30 it '省略されると@pageに1値が入る' do
32 assigns(:page).should eq 1
34 it '与えられたpage_sizeがセットされている' do
35 get :index, :page_size => 15
36 assigns(:page_size).should eq 15
38 it '省略されると@page_sizeにデフォルト値が入る' do
40 assigns(:page_size).should eq Author.default_page_size
42 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
43 get :index, :page_size => 1500
44 assigns(:page_size).should eq Author.max_page_size
46 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
47 get :index, :page_size => 0
48 assigns(:page_size).should eq Author.default_page_size
51 context 'つつがなく終わるとき' do
52 it 'ステータスコード200 OKを返す' do
54 response.should be_success
56 it '作家モデルに一覧を問い合わせている' do
57 Author.should_receive(:list).exactly(1)
60 it '@authorsにリストを取得している' do
62 assigns(:authors).should have_at_least(3).items
65 it '@paginateにページ制御を取得している' do
67 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
69 it 'indexテンプレートを描画する' do
71 response.should render_template("index")
76 get :index, :format => :json
77 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
79 it '作家モデルにjson一覧出力オプションを問い合わせている' do
80 Author.should_receive(:list_json_opt).exactly(1)
81 get :index, :format => :json
83 it 'データがリスト構造になっている' do
84 get :index, :format => :json
85 json = JSON.parse response.body
86 json.should have_at_least(3).items
88 it 'リストの先頭くらいは作家っぽいものであって欲しい' do
89 get :index, :format => :json
90 json = JSON.parse response.body
91 json.first.has_key?("name").should be_true
92 json.first.has_key?("user_id").should be_true
96 context 'ユーザ権限がないとき' do
101 it 'ステータスコード302 Foundを返す' do
103 response.status.should eq 302
105 it 'サインインページへ遷移する' do
107 response.should redirect_to '/users/sign_in'
111 it 'ステータスコード401 Unauthorizedを返す' do
112 get :index, :format => :json
113 response.status.should eq 401
115 it '応答メッセージにUnauthorizedを返す' do
116 get :index, :format => :json
117 response.message.should match(/Unauthorized/)
121 context 'ユーザ権限はないが管理者権限があるとき' do
126 it 'ステータスコード200 OKを返す' do
128 response.should be_success
131 context 'ユーザだが作家登録していないとき' do
135 it 'ステータスコード200 OKを返す' do
137 response.should be_success
144 Author.stub(:show).and_return(@author)
147 context 'つつがなく終わるとき' do
148 it 'ステータスコード200 OKを返す' do
149 get :show, :id => @author.id
150 response.should be_success
152 it '作家モデルに単体取得を問い合わせている' do
153 Author.should_receive(:show).exactly(1)
156 #@authorだとログイン中のアカウントと干渉してしまう。
157 it '@auにアレを取得している' do
158 get :show, :id => @author.id
159 assigns(:au).should eq(@author)
162 it 'showテンプレートを描画する' do
163 get :show, :id => @author.id
164 response.should render_template("show")
169 get :show, :id => @author.id, :format => :json
170 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
172 it '作家モデルにjson単体出力オプションを問い合わせている' do
173 Author.should_receive(:show_json_opt).exactly(1)
174 get :show, :id => @author.id, :format => :json
177 get :show, :id => @author.id, :format => :json
178 json = JSON.parse response.body
179 json["name"].should match(/test/)
180 json["user_id"].should eq @author.user_id
184 context 'ユーザ権限がないとき' do
189 it 'ステータスコード302 Foundを返す' do
190 get :show, :id => @author.id
191 response.status.should eq 302
193 it 'サインインページへ遷移する' do
194 get :show, :id => @author.id
195 response.body.should redirect_to '/users/sign_in'
199 it 'ステータスコード401 Unauthorizedを返す' do
200 get :show, :id => @author.id, :format => :json
201 response.status.should eq 401
203 it '応答メッセージにUnauthorizedを返す' do
204 get :show, :id => @author.id, :format => :json
205 response.message.should match(/Unauthorized/)
209 context 'ユーザ権限はないが管理者権限があるとき' do
214 it 'ステータスコード200 OKを返す' do
215 get :show, :id => @author.id
216 response.should be_success
219 context 'ユーザだが作家登録していないとき' do
223 it 'ステータスコード200 OKを返す' do
224 get :show, :id => @author.id
225 response.should be_success
229 context '対象作家がないとき' do
231 it '例外404 not_foundを返す' do
234 }.should raise_error(ActiveRecord::RecordNotFound)
238 it '例外404 not_foundを返す' do
240 get :show, :id => 0, :format => :json
241 }.should raise_error(ActiveRecord::RecordNotFound)
248 describe '対象作家のスクロール一覧表示に於いて' do
250 @other_user = FactoryGirl.create( :user_yas)
251 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
252 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
253 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
254 Author.stub(:show).and_return(@other_author)
255 Scroll.stub(:himlist).and_return([@scroll, @scroll, @scroll])
258 context 'パラメータpageについて' do
260 get :scrolls, :id => @other_author.id, :page => 5
261 assigns(:page).should eq 5
263 it '省略されると@pageに1値が入る' do
264 get :scrolls, :id => @other_author.id
265 assigns(:page).should eq 1
267 it '与えられたpage_sizeがセットされている' do
268 get :scrolls, :id => @other_author.id, :page_size => 15
269 assigns(:page_size).should eq 15
271 it '省略されると@page_sizeにデフォルト値が入る' do
272 get :scrolls, :id => @other_author.id
273 assigns(:page_size).should eq Author.default_scroll_page_size
275 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
276 get :scrolls, :id => @other_author.id, :page_size => 1500
277 assigns(:page_size).should eq Author.scroll_max_page_size
279 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
280 get :scrolls, :id => @other_author.id, :page_size => 0
281 assigns(:page_size).should eq Author.default_scroll_page_size
284 context 'つつがなく終わるとき' do
285 it 'ステータスコード200 OKを返す' do
286 get :scrolls, :id => @other_author.id
287 response.should be_success
289 it '作家モデルに単体取得を問い合わせている' do
290 Author.should_receive(:show).exactly(1)
291 get :scrolls, :id => @other_author.id
293 it 'スクロールモデルに一覧を問い合わせている' do
294 Scroll.should_receive(:himlist).exactly(1)
295 get :scrolls, :id => @other_author.id
297 it '@scrollsにリストを取得している' do
298 get :scrolls, :id => @other_author.id
299 assigns(:scrolls).should have_at_least(3).items
302 it '@paginateにページ制御を取得している' do
303 get :scrolls, :id => @other_author.id
304 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
306 it 'scrollsテンプレートを描画する' do
307 get :scrolls, :id => @other_author.id
308 response.should render_template("scrolls")
313 get :scrolls, :id => @other_author.id, :format => :json
314 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
316 it 'スクロールモデルにjson一覧出力オプションを問い合わせている' do
317 Scroll.should_receive(:list_json_opt).exactly(1)
318 get :scrolls, :id => @other_author.id, :format => :json
320 it 'データがリスト構造になっている' do
321 get :scrolls, :id => @other_author.id, :format => :json
322 json = JSON.parse response.body
323 json.should have_at_least(3).items
325 it 'リストの先頭くらいはスクロールっぽいものであって欲しい' do
326 get :scrolls, :id => @other_author.id, :format => :json
327 json = JSON.parse response.body
328 json.first.has_key?("title").should be_true
329 json.first.has_key?("visible").should be_true
333 context 'ユーザ権限がないとき' do
338 it 'ステータスコード302 Foundを返す' do
339 get :scrolls, :id => @other_author.id
340 response.status.should eq 302
342 it 'サインインページへ遷移する' do
343 get :scrolls, :id => @other_author.id
344 response.should redirect_to '/users/sign_in'
348 it 'ステータスコード401 Unauthorizedを返す' do
349 get :scrolls, :id => @other_author.id, :format => :json
350 response.status.should eq 401
352 it '応答メッセージにUnauthorizedを返す' do
353 get :scrolls, :id => @other_author.id, :format => :json
354 response.message.should match(/Unauthorized/)
358 context 'ユーザ権限はないが管理者権限があるとき' do
363 it 'ステータスコード200 OKを返す' do
364 get :scrolls, :id => @other_author.id
365 response.should be_success
368 context 'ユーザだが作家登録していないとき' do
372 it 'ステータスコード200 OKを返す' do
373 get :scrolls, :id => @other_author.id
374 response.should be_success
379 describe '対象作家のスクコマ一覧表示に於いて' do
381 @other_user = FactoryGirl.create( :user_yas)
382 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
383 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
384 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
385 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
386 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_user.author.id
387 Author.stub(:show).and_return(@other_author)
388 ScrollPanel.stub(:himlist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
391 context 'パラメータpageについて' do
393 get :scroll_panels, :id => @other_author.id, :page => 5
394 assigns(:page).should eq 5
396 it '省略されると@pageに1値が入る' do
397 get :scroll_panels, :id => @other_author.id
398 assigns(:page).should eq 1
400 it '与えられたpage_sizeがセットされている' do
401 get :scroll_panels, :id => @other_author.id, :page_size => 15
402 assigns(:page_size).should eq 15
404 it '省略されると@page_sizeにデフォルト値が入る' do
405 get :scroll_panels, :id => @other_author.id
406 assigns(:page_size).should eq Author.default_scroll_panel_page_size
408 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
409 get :scroll_panels, :id => @other_author.id, :page_size => 1500
410 assigns(:page_size).should eq Author.scroll_panel_max_page_size
412 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
413 get :scroll_panels, :id => @other_author.id, :page_size => 0
414 assigns(:page_size).should eq Author.default_scroll_panel_page_size
417 context 'つつがなく終わるとき' do
418 it 'ステータスコード200 OKを返す' do
419 get :scroll_panels, :id => @other_author.id
420 response.should be_success
422 it '作家モデルに単体取得を問い合わせている' do
423 Author.should_receive(:show).exactly(1)
424 get :scroll_panels, :id => @other_author.id
426 it 'スクコマモデルに他作家のスクコマ一覧を問い合わせている' do
427 ScrollPanel.should_receive(:himlist).exactly(1)
428 get :scroll_panels, :id => @other_author.id
430 it '@scroll_panelsにリストを取得している' do
431 get :scroll_panels, :id => @other_author.id
432 assigns(:scroll_panels).should have_at_least(3).items
435 it '@paginateにページ制御を取得している' do
436 get :scroll_panels, :id => @other_author.id
437 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
439 it 'scroll_panelsテンプレートを描画する' do
440 get :scroll_panels, :id => @other_author.id
441 response.should render_template("scroll_panels")
446 get :scroll_panels, :id => @other_author.id, :format => :json
447 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
449 it 'スクコマモデルにjson一覧出力オプションを問い合わせている' do
450 ScrollPanel.should_receive(:list_json_opt).exactly(1)
451 get :scroll_panels, :id => @other_author.id, :format => :json
453 it 'データがリスト構造になっている' do
454 get :scroll_panels, :id => @other_author.id, :format => :json
455 json = JSON.parse response.body
456 json.should have_at_least(3).items
458 it 'リストの先頭くらいはスクコマっぽいものであって欲しい' do
459 get :scroll_panels, :id => @other_author.id, :format => :json
460 json = JSON.parse response.body
461 json.first.has_key?("panel_id").should be_true
462 json.first.has_key?("scroll_id").should be_true
463 json.first.has_key?("t").should be_true
467 context 'ユーザ権限がないとき' do
472 it 'ステータスコード302 Foundを返す' do
473 get :scroll_panels, :id => @other_author.id
474 response.status.should eq 302
476 it 'サインインページへ遷移する' do
477 get :scroll_panels, :id => @other_author.id
478 response.should redirect_to '/users/sign_in'
482 it 'ステータスコード401 Unauthorizedを返す' do
483 get :scroll_panels, :id => @other_author.id, :format => :json
484 response.status.should eq 401
486 it '応答メッセージにUnauthorizedを返す' do
487 get :scroll_panels, :id => @other_author.id, :format => :json
488 response.message.should match(/Unauthorized/)
492 context 'ユーザ権限はないが管理者権限があるとき' do
497 it 'ステータスコード200 OKを返す' do
498 get :scroll_panels, :id => @other_author.id
499 response.should be_success
502 context 'ユーザだが作家登録していないとき' do
506 it 'ステータスコード200 OKを返す' do
507 get :scroll_panels, :id => @other_author.id
508 response.should be_success
513 describe '対象作家のコミック一覧表示に於いて' do
515 @other_user = FactoryGirl.create( :user_yas)
516 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
517 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
518 @comic = FactoryGirl.create :comic, :author_id => @author.id
519 Author.stub(:show).and_return(@other_author)
520 Comic.stub(:himlist).and_return([@comic, @comic, @comic])
523 context 'パラメータpageについて' do
525 get :comics, :id => @other_author.id, :page => 5
526 assigns(:page).should eq 5
528 it '省略されると@pageに1値が入る' do
529 get :comics, :id => @other_author.id
530 assigns(:page).should eq 1
532 it '与えられたpage_sizeがセットされている' do
533 get :comics, :id => @other_author.id, :page_size => 15
534 assigns(:page_size).should eq 15
536 it '省略されると@page_sizeにデフォルト値が入る' do
537 get :comics, :id => @other_author.id
538 assigns(:page_size).should eq Author.default_comic_page_size
540 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
541 get :comics, :id => @other_author.id, :page_size => 1500
542 assigns(:page_size).should eq Author.comic_max_page_size
544 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
545 get :comics, :id => @other_author.id, :page_size => 0
546 assigns(:page_size).should eq Author.default_comic_page_size
549 context 'つつがなく終わるとき' do
550 it 'ステータスコード200 OKを返す' do
551 get :comics, :id => @other_author.id
552 response.should be_success
554 it '作家モデルに単体取得を問い合わせている' do
555 Author.should_receive(:show).exactly(1)
556 get :comics, :id => @other_author.id
558 it 'コミックモデルに一覧を問い合わせている' do
559 Comic.should_receive(:himlist).exactly(1)
560 get :comics, :id => @other_author.id
562 it '@comicsにリストを取得している' do
563 get :comics, :id => @other_author.id
564 assigns(:comics).should have_at_least(3).items
567 it '@paginateにページ制御を取得している' do
568 get :comics, :id => @other_author.id
569 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
571 it 'comicsテンプレートを描画する' do
572 get :comics, :id => @other_author.id
573 response.should render_template("comics")
578 get :comics, :id => @other_author.id, :format => :json
579 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
581 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
582 Comic.should_receive(:list_json_opt).exactly(1)
583 get :comics, :id => @other_author.id, :format => :json
585 it 'データがリスト構造になっている' do
586 get :comics, :id => @other_author.id, :format => :json
587 json = JSON.parse response.body
588 json.should have_at_least(3).items
590 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
591 get :comics, :id => @other_author.id, :format => :json
592 json = JSON.parse response.body
593 json.first.has_key?("title").should be_true
594 json.first.has_key?("visible").should be_true
598 context 'ユーザ権限がないとき' do
603 it 'ステータスコード302 Foundを返す' do
604 get :comics, :id => @other_author.id
605 response.status.should eq 302
607 it 'サインインページへ遷移する' do
608 get :comics, :id => @other_author.id
609 response.should redirect_to '/users/sign_in'
613 it 'ステータスコード401 Unauthorizedを返す' do
614 get :comics, :id => @other_author.id, :format => :json
615 response.status.should eq 401
617 it '応答メッセージにUnauthorizedを返す' do
618 get :comics, :id => @other_author.id, :format => :json
619 response.message.should match(/Unauthorized/)
623 context 'ユーザ権限はないが管理者権限があるとき' do
628 it 'ステータスコード200 OKを返す' do
629 get :comics, :id => @other_author.id
630 response.should be_success
633 context 'ユーザだが作家登録していないとき' do
637 it 'ステータスコード200 OKを返す' do
638 get :comics, :id => @other_author.id
639 response.should be_success
644 describe '対象作家のストーリー一覧表示に於いて' do
646 @other_user = FactoryGirl.create( :user_yas)
647 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
648 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
649 @comic = FactoryGirl.create :comic, :author_id => @author.id
650 @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
651 Author.stub(:show).and_return(@other_author)
652 Story.stub(:himlist).and_return([@story, @story, @story])
655 context 'パラメータpageについて' do
657 get :stories, :id => @other_author.id, :page => 5
658 assigns(:page).should eq 5
660 it '省略されると@pageに1値が入る' do
661 get :stories, :id => @other_author.id
662 assigns(:page).should eq 1
664 it '与えられたpage_sizeがセットされている' do
665 get :stories, :id => @other_author.id, :page_size => 15
666 assigns(:page_size).should eq 15
668 it '省略されると@page_sizeにデフォルト値が入る' do
669 get :stories, :id => @other_author.id
670 assigns(:page_size).should eq Author.default_story_page_size
672 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
673 get :stories, :id => @other_author.id, :page_size => 1500
674 assigns(:page_size).should eq Author.story_max_page_size
676 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
677 get :stories, :id => @other_author.id, :page_size => 0
678 assigns(:page_size).should eq Author.default_story_page_size
681 context 'つつがなく終わるとき' do
682 it 'ステータスコード200 OKを返す' do
683 get :stories, :id => @other_author.id
684 response.should be_success
686 it '作家モデルに単体取得を問い合わせている' do
687 Author.should_receive(:show).exactly(1)
688 get :stories, :id => @other_author.id
690 it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
691 Story.should_receive(:himlist).exactly(1)
692 get :stories, :id => @other_author.id
694 it '@storiesにリストを取得している' do
695 get :stories, :id => @other_author.id
696 assigns(:stories).should have_at_least(3).items
699 it '@paginateにページ制御を取得している' do
700 get :stories, :id => @other_author.id
701 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
703 it 'storiesテンプレートを描画する' do
704 get :stories, :id => @other_author.id
705 response.should render_template("stories")
710 get :stories, :id => @other_author.id, :format => :json
711 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
713 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
714 Story.should_receive(:list_json_opt).exactly(1)
715 get :stories, :id => @other_author.id, :format => :json
717 it 'データがリスト構造になっている' do
718 get :stories, :id => @other_author.id, :format => :json
719 json = JSON.parse response.body
720 json.should have_at_least(3).items
722 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
723 get :stories, :id => @other_author.id, :format => :json
724 json = JSON.parse response.body
725 json.first.has_key?("comic_id").should be_true
726 json.first.has_key?("title").should be_true
730 context 'ユーザ権限がないとき' do
735 it 'ステータスコード302 Foundを返す' do
736 get :stories, :id => @other_author.id
737 response.status.should eq 302
739 it 'サインインページへ遷移する' do
740 get :stories, :id => @other_author.id
741 response.should redirect_to '/users/sign_in'
745 it 'ステータスコード401 Unauthorizedを返す' do
746 get :stories, :id => @other_author.id, :format => :json
747 response.status.should eq 401
749 it '応答メッセージにUnauthorizedを返す' do
750 get :stories, :id => @other_author.id, :format => :json
751 response.message.should match(/Unauthorized/)
755 context 'ユーザ権限はないが管理者権限があるとき' do
760 it 'ステータスコード200 OKを返す' do
761 get :stories, :id => @other_author.id
762 response.should be_success
765 context 'ユーザだが作家登録していないとき' do
769 it 'ステータスコード200 OKを返す' do
770 get :stories, :id => @other_author.id
771 response.should be_success
776 describe '対象作家のスト紙一覧表示に於いて' do
778 @other_user = FactoryGirl.create( :user_yas)
779 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
780 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
781 @comic = FactoryGirl.create :comic, :author_id => @author.id
782 @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
783 @sheet = FactoryGirl.create :sheet, :author_id => @author.id
784 @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
785 Author.stub(:show).and_return(@other_author)
786 StorySheet.stub(:himlist).and_return([@story_sheet, @story_sheet, @story_sheet])
789 context 'パラメータpageについて' do
791 get :story_sheets, :id => @other_author.id, :page => 5
792 assigns(:page).should eq 5
794 it '省略されると@pageに1値が入る' do
795 get :story_sheets, :id => @other_author.id
796 assigns(:page).should eq 1
798 it '与えられたpage_sizeがセットされている' do
799 get :story_sheets, :id => @other_author.id, :page_size => 15
800 assigns(:page_size).should eq 15
802 it '省略されると@page_sizeにデフォルト値が入る' do
803 get :story_sheets, :id => @other_author.id
804 assigns(:page_size).should eq Author.default_story_sheet_page_size
806 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
807 get :story_sheets, :id => @other_author.id, :page_size => 1500
808 assigns(:page_size).should eq Author.story_sheet_max_page_size
810 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
811 get :story_sheets, :id => @other_author.id, :page_size => 0
812 assigns(:page_size).should eq Author.default_story_sheet_page_size
815 context 'つつがなく終わるとき' do
816 it 'ステータスコード200 OKを返す' do
817 get :story_sheets, :id => @other_author.id
818 response.should be_success
820 it '作家モデルに単体取得を問い合わせている' do
821 Author.should_receive(:show).exactly(1)
822 get :story_sheets, :id => @other_author.id
824 it 'スト紙モデルに他作家のスト紙一覧を問い合わせている' do
825 StorySheet.should_receive(:himlist).exactly(1)
826 get :story_sheets, :id => @other_author.id
828 it '@story_sheetsにリストを取得している' do
829 get :story_sheets, :id => @other_author.id
830 assigns(:story_sheets).should have_at_least(3).items
833 it '@paginateにページ制御を取得している' do
834 get :story_sheets, :id => @other_author.id
835 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
837 it 'story_sheetsテンプレートを描画する' do
838 get :story_sheets, :id => @other_author.id
839 response.should render_template("story_sheets")
844 get :story_sheets, :id => @other_author.id, :format => :json
845 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
847 it 'スト紙モデルにjson一覧出力オプションを問い合わせている' do
848 StorySheet.should_receive(:list_json_opt).exactly(1)
849 get :story_sheets, :id => @other_author.id, :format => :json
851 it 'データがリスト構造になっている' do
852 get :story_sheets, :id => @other_author.id, :format => :json
853 json = JSON.parse response.body
854 json.should have_at_least(3).items
856 it 'リストの先頭くらいはスト紙っぽいものであって欲しい' do
857 get :story_sheets, :id => @other_author.id, :format => :json
858 json = JSON.parse response.body
859 json.first.has_key?("story_id").should be_true
860 json.first.has_key?("sheet_id").should be_true
864 context 'ユーザ権限がないとき' do
869 it 'ステータスコード302 Foundを返す' do
870 get :story_sheets, :id => @other_author.id
871 response.status.should eq 302
873 it 'サインインページへ遷移する' do
874 get :story_sheets, :id => @other_author.id
875 response.should redirect_to '/users/sign_in'
879 it 'ステータスコード401 Unauthorizedを返す' do
880 get :story_sheets, :id => @other_author.id, :format => :json
881 response.status.should eq 401
883 it '応答メッセージにUnauthorizedを返す' do
884 get :story_sheets, :id => @other_author.id, :format => :json
885 response.message.should match(/Unauthorized/)
889 context 'ユーザ権限はないが管理者権限があるとき' do
894 it 'ステータスコード200 OKを返す' do
895 get :story_sheets, :id => @other_author.id
896 response.should be_success
899 context 'ユーザだが作家登録していないとき' do
903 it 'ステータスコード200 OKを返す' do
904 get :story_sheets, :id => @other_author.id
905 response.should be_success
910 describe '対象作家の用紙一覧表示に於いて' do
912 @other_user = FactoryGirl.create( :user_yas)
913 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
914 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
915 @sheet = FactoryGirl.create :sheet, :author_id => @other_user.author.id
916 Author.stub(:show).and_return(@other_author)
917 Sheet.stub(:himlist).and_return([@sheet, @sheet, @sheet])
920 context 'パラメータpageについて' do
922 get :sheets, :id => @other_author.id, :page => 5
923 assigns(:page).should eq 5
925 it '省略されると@pageに1値が入る' do
926 get :sheets, :id => @other_author.id
927 assigns(:page).should eq 1
929 it '与えられたpage_sizeがセットされている' do
930 get :sheets, :id => @other_author.id, :page_size => 15
931 assigns(:page_size).should eq 15
933 it '省略されると@page_sizeにデフォルト値が入る' do
934 get :sheets, :id => @other_author.id
935 assigns(:page_size).should eq Author.default_sheet_page_size
937 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
938 get :sheets, :id => @other_author.id, :page_size => 1500
939 assigns(:page_size).should eq Author.sheet_max_page_size
941 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
942 get :sheets, :id => @other_author.id, :page_size => 0
943 assigns(:page_size).should eq Author.default_sheet_page_size
946 context 'つつがなく終わるとき' do
947 it 'ステータスコード200 OKを返す' do
948 get :sheets, :id => @other_author.id
949 response.should be_success
951 it '作家モデルに単体取得を問い合わせている' do
952 Author.should_receive(:show).exactly(1)
953 get :sheets, :id => @other_author.id
955 it '用紙モデルに一覧を問い合わせている' do
956 Sheet.should_receive(:himlist).exactly(1)
957 get :sheets, :id => @other_author.id
959 it '@sheetsにリストを取得している' do
960 get :sheets, :id => @other_author.id
961 assigns(:sheets).should have_at_least(3).items
964 it '@paginateにページ制御を取得している' do
965 get :sheets, :id => @other_author.id
966 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
968 it 'sheetsテンプレートを描画する' do
969 get :sheets, :id => @other_author.id
970 response.should render_template("sheets")
975 get :sheets, :id => @other_author.id, :format => :json
976 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
978 it '用紙モデルにjson一覧出力オプションを問い合わせている' do
979 Sheet.should_receive(:list_json_opt).exactly(1)
980 get :sheets, :id => @other_author.id, :format => :json
982 it 'データがリスト構造になっている' do
983 get :sheets, :id => @other_author.id, :format => :json
984 json = JSON.parse response.body
985 json.should have_at_least(3).items
987 it 'リストの先頭くらいは用紙っぽいものであって欲しい' do
988 get :sheets, :id => @other_author.id, :format => :json
989 json = JSON.parse response.body
990 json.first.has_key?("caption").should be_true
991 json.first.has_key?("visible").should be_true
995 context 'ユーザ権限がないとき' do
1000 it 'ステータスコード302 Foundを返す' do
1001 get :sheets, :id => @other_author.id
1002 response.status.should eq 302
1004 it 'サインインページへ遷移する' do
1005 get :sheets, :id => @other_author.id
1006 response.should redirect_to '/users/sign_in'
1010 it 'ステータスコード401 Unauthorizedを返す' do
1011 get :sheets, :id => @other_author.id, :format => :json
1012 response.status.should eq 401
1014 it '応答メッセージにUnauthorizedを返す' do
1015 get :sheets, :id => @other_author.id, :format => :json
1016 response.message.should match(/Unauthorized/)
1020 context 'ユーザ権限はないが管理者権限があるとき' do
1025 it 'ステータスコード200 OKを返す' do
1026 get :sheets, :id => @other_author.id
1027 response.should be_success
1030 context 'ユーザだが作家登録していないとき' do
1034 it 'ステータスコード200 OKを返す' do
1035 get :sheets, :id => @other_author.id
1036 response.should be_success
1041 describe '対象作家の紙コマ一覧表示に於いて' do
1043 @other_user = FactoryGirl.create( :user_yas)
1044 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1045 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1046 @sheet = FactoryGirl.create :sheet, :author_id => @other_user.author.id
1047 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
1048 @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @other_user.author.id
1049 Author.stub(:show).and_return(@other_author)
1050 SheetPanel.stub(:himlist).and_return([@sheet_panel, @sheet_panel, @sheet_panel])
1053 context 'パラメータpageについて' do
1055 get :sheet_panels, :id => @other_author.id, :page => 5
1056 assigns(:page).should eq 5
1058 it '省略されると@pageに1値が入る' do
1059 get :sheet_panels, :id => @other_author.id
1060 assigns(:page).should eq 1
1062 it '与えられたpage_sizeがセットされている' do
1063 get :sheet_panels, :id => @other_author.id, :page_size => 15
1064 assigns(:page_size).should eq 15
1066 it '省略されると@page_sizeにデフォルト値が入る' do
1067 get :sheet_panels, :id => @other_author.id
1068 assigns(:page_size).should eq Author.default_sheet_panel_page_size
1070 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1071 get :sheet_panels, :id => @other_author.id, :page_size => 1500
1072 assigns(:page_size).should eq Author.sheet_panel_max_page_size
1074 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1075 get :sheet_panels, :id => @other_author.id, :page_size => 0
1076 assigns(:page_size).should eq Author.default_sheet_panel_page_size
1079 context 'つつがなく終わるとき' do
1080 it 'ステータスコード200 OKを返す' do
1081 get :sheet_panels, :id => @other_author.id
1082 response.should be_success
1084 it '作家モデルに単体取得を問い合わせている' do
1085 Author.should_receive(:show).exactly(1)
1086 get :sheet_panels, :id => @other_author.id
1088 it '紙コマモデルに他作家の紙コマ一覧を問い合わせている' do
1089 SheetPanel.should_receive(:himlist).exactly(1)
1090 get :sheet_panels, :id => @other_author.id
1092 it '@sheet_panelsにリストを取得している' do
1093 get :sheet_panels, :id => @other_author.id
1094 assigns(:sheet_panels).should have_at_least(3).items
1097 it '@paginateにページ制御を取得している' do
1098 get :sheet_panels, :id => @other_author.id
1099 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1101 it 'sheet_panelsテンプレートを描画する' do
1102 get :sheet_panels, :id => @other_author.id
1103 response.should render_template("sheet_panels")
1108 get :sheet_panels, :id => @other_author.id, :format => :json
1109 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1111 it '紙コマモデルにjson一覧出力オプションを問い合わせている' do
1112 SheetPanel.should_receive(:list_json_opt).exactly(1)
1113 get :sheet_panels, :id => @other_author.id, :format => :json
1115 it 'データがリスト構造になっている' do
1116 get :sheet_panels, :id => @other_author.id, :format => :json
1117 json = JSON.parse response.body
1118 json.should have_at_least(3).items
1120 it 'リストの先頭くらいは紙コマっぽいものであって欲しい' do
1121 get :sheet_panels, :id => @other_author.id, :format => :json
1122 json = JSON.parse response.body
1123 json.first.has_key?("panel_id").should be_true
1124 json.first.has_key?("sheet_id").should be_true
1125 json.first.has_key?("t").should be_true
1129 context 'ユーザ権限がないとき' do
1134 it 'ステータスコード302 Foundを返す' do
1135 get :sheet_panels, :id => @other_author.id
1136 response.status.should eq 302
1138 it 'サインインページへ遷移する' do
1139 get :sheet_panels, :id => @other_author.id
1140 response.should redirect_to '/users/sign_in'
1144 it 'ステータスコード401 Unauthorizedを返す' do
1145 get :sheet_panels, :id => @other_author.id, :format => :json
1146 response.status.should eq 401
1148 it '応答メッセージにUnauthorizedを返す' do
1149 get :sheet_panels, :id => @other_author.id, :format => :json
1150 response.message.should match(/Unauthorized/)
1154 context 'ユーザ権限はないが管理者権限があるとき' do
1159 it 'ステータスコード200 OKを返す' do
1160 get :sheet_panels, :id => @other_author.id
1161 response.should be_success
1164 context 'ユーザだが作家登録していないとき' do
1168 it 'ステータスコード200 OKを返す' do
1169 get :sheet_panels, :id => @other_author.id
1170 response.should be_success
1175 describe '対象作家のコマ一覧表示に於いて' do
1177 @other_user = FactoryGirl.create( :user_yas)
1178 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1179 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1180 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1181 Author.stub(:show).and_return(@other_author)
1182 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
1185 context 'パラメータpageについて' do
1187 get :panels, :id => @other_author.id, :page => 5
1188 assigns(:page).should eq 5
1190 it '省略されると@pageに1値が入る' do
1191 get :panels, :id => @other_author.id
1192 assigns(:page).should eq 1
1194 it '与えられたpage_sizeがセットされている' do
1195 get :panels, :id => @other_author.id, :page_size => 15
1196 assigns(:page_size).should eq 15
1198 it '省略されると@page_sizeにデフォルト値が入る' do
1199 get :panels, :id => @other_author.id
1200 assigns(:page_size).should eq Author.default_panel_page_size
1202 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1203 get :panels, :id => @other_author.id, :page_size => 1500
1204 assigns(:page_size).should eq Author.panel_max_page_size
1206 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1207 get :panels, :id => @other_author.id, :page_size => 0
1208 assigns(:page_size).should eq Author.default_panel_page_size
1211 context 'つつがなく終わるとき' do
1212 it 'ステータスコード200 OKを返す' do
1213 get :panels, :id => @other_author.id
1214 response.should be_success
1216 it '作家モデルに単体取得を問い合わせている' do
1217 Author.should_receive(:show).exactly(1)
1218 get :panels, :id => @other_author.id
1220 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
1221 Panel.should_receive(:himlist).exactly(1)
1222 get :panels, :id => @other_author.id
1224 it '@panelsにリストを取得している' do
1225 get :panels, :id => @other_author.id
1226 assigns(:panels).should have_at_least(3).items
1229 it '@paginateにページ制御を取得している' do
1230 get :panels, :id => @other_author.id
1231 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1233 it 'panelsテンプレートを描画する' do
1234 get :panels, :id => @other_author.id
1235 response.should render_template("panels")
1240 get :panels, :id => @other_author.id, :format => :json
1241 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1243 it 'コマモデルにコマリストのjson出力を問い合わせている' do
1244 Panel.should_receive(:list_as_json_text).exactly(1)
1245 get :panels, :id => @other_author.id, :format => :json
1247 it 'データがリスト構造になっている' do
1248 get :panels, :id => @other_author.id, :format => :json
1249 json = JSON.parse response.body
1250 json.should have_at_least(3).items
1252 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
1253 get :panels, :id => @other_author.id, :format => :json
1254 json = JSON.parse response.body
1255 json.first.has_key?("z").should be_true
1259 context 'ユーザ権限がないとき' do
1264 it 'ステータスコード302 Foundを返す' do
1265 get :panels, :id => @other_author.id
1266 response.status.should eq 302
1268 it 'サインインページへ遷移する' do
1269 get :panels, :id => @other_author.id
1270 response.should redirect_to '/users/sign_in'
1274 it 'ステータスコード401 Unauthorizedを返す' do
1275 get :panels, :id => @other_author.id, :format => :json
1276 response.status.should eq 401
1278 it '応答メッセージにUnauthorizedを返す' do
1279 get :panels, :id => @other_author.id, :format => :json
1280 response.message.should match(/Unauthorized/)
1284 context 'ユーザ権限はないが管理者権限があるとき' do
1289 it 'ステータスコード200 OKを返す' do
1290 get :panels, :id => @other_author.id
1291 response.should be_success
1294 context 'ユーザだが作家登録していないとき' do
1298 it 'ステータスコード200 OKを返す' do
1299 get :panels, :id => @other_author.id
1300 response.should be_success
1305 describe '対象作家のコマ絵一覧表示に於いて' do
1307 @other_user = FactoryGirl.create( :user_yas)
1308 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1309 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1310 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1311 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1312 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1313 @panel = FactoryGirl.create :panel, :author_id => @author.id
1314 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
1315 Author.stub(:show).and_return(@other_author)
1316 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
1319 context 'パラメータpageについて' do
1321 get :panel_pictures, :id => @other_author.id, :page => 5
1322 assigns(:page).should eq 5
1324 it '省略されると@pageに1値が入る' do
1325 get :panel_pictures, :id => @other_author.id
1326 assigns(:page).should eq 1
1328 it '与えられたpage_sizeがセットされている' do
1329 get :panel_pictures, :id => @other_author.id, :page_size => 15
1330 assigns(:page_size).should eq 15
1332 it '省略されると@page_sizeにデフォルト値が入る' do
1333 get :panel_pictures, :id => @other_author.id
1334 assigns(:page_size).should eq Author.default_panel_picture_page_size
1336 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1337 get :panel_pictures, :id => @other_author.id, :page_size => 1500
1338 assigns(:page_size).should eq Author.panel_picture_max_page_size
1340 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1341 get :panel_pictures, :id => @other_author.id, :page_size => 0
1342 assigns(:page_size).should eq Author.default_panel_picture_page_size
1345 context 'つつがなく終わるとき' do
1346 it 'ステータスコード200 OKを返す' do
1347 get :panel_pictures, :id => @other_author.id
1348 response.should be_success
1350 it '作家モデルに単体取得を問い合わせている' do
1351 Author.should_receive(:show).exactly(1)
1352 get :panel_pictures, :id => @other_author.id
1354 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
1355 PanelPicture.should_receive(:himlist).exactly(1)
1356 get :panel_pictures, :id => @other_author.id
1358 it '@panel_picturesにリストを取得している' do
1359 get :panel_pictures, :id => @other_author.id
1360 assigns(:panel_pictures).should have_at_least(3).items
1363 it '@paginateにページ制御を取得している' do
1364 get :panel_pictures, :id => @other_author.id
1365 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1367 it 'panel_picturesテンプレートを描画する' do
1368 get :panel_pictures, :id => @other_author.id
1369 response.should render_template("panel_pictures")
1374 get :panel_pictures, :id => @other_author.id, :format => :json
1375 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1377 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
1378 PanelPicture.should_receive(:list_json_opt).exactly(1)
1379 get :panel_pictures, :id => @other_author.id, :format => :json
1381 it 'データがリスト構造になっている' do
1382 get :panel_pictures, :id => @other_author.id, :format => :json
1383 json = JSON.parse response.body
1384 json.should have_at_least(3).items
1386 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
1387 get :panel_pictures, :id => @other_author.id, :format => :json
1388 json = JSON.parse response.body
1389 json.first.has_key?("link").should be_true
1390 json.first.has_key?("x").should be_true
1391 json.first.has_key?("y").should be_true
1395 context 'ユーザ権限がないとき' do
1400 it 'ステータスコード302 Foundを返す' do
1401 get :panel_pictures, :id => @other_author.id
1402 response.status.should eq 302
1404 it 'サインインページへ遷移する' do
1405 get :panel_pictures, :id => @other_author.id
1406 response.should redirect_to '/users/sign_in'
1410 it 'ステータスコード401 Unauthorizedを返す' do
1411 get :panel_pictures, :id => @other_author.id, :format => :json
1412 response.status.should eq 401
1414 it '応答メッセージにUnauthorizedを返す' do
1415 get :panel_pictures, :id => @other_author.id, :format => :json
1416 response.message.should match(/Unauthorized/)
1420 context 'ユーザ権限はないが管理者権限があるとき' do
1425 it 'ステータスコード200 OKを返す' do
1426 get :panel_pictures, :id => @other_author.id
1427 response.should be_success
1430 context 'ユーザだが作家登録していないとき' do
1434 it 'ステータスコード200 OKを返す' do
1435 get :panel_pictures, :id => @other_author.id
1436 response.should be_success
1441 describe '対象作家のフキダシ一覧表示に於いて' do
1443 @other_user = FactoryGirl.create( :user_yas)
1444 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1445 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1446 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1447 @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
1448 @speech = @sb.build_speech(
1449 FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
1451 @balloon = @sb.build_balloon(
1452 FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
1456 Author.stub(:show).and_return(@other_author)
1457 SpeechBalloon.stub(:himlist).and_return([@sb, @sb, @sb])
1460 context 'パラメータpageについて' do
1462 get :speech_balloons, :id => @other_author.id, :page => 5
1463 assigns(:page).should eq 5
1465 it '省略されると@pageに1値が入る' do
1466 get :speech_balloons, :id => @other_author.id
1467 assigns(:page).should eq 1
1469 it '与えられたpage_sizeがセットされている' do
1470 get :speech_balloons, :id => @other_author.id, :page_size => 15
1471 assigns(:page_size).should eq 15
1473 it '省略されると@page_sizeにデフォルト値が入る' do
1474 get :speech_balloons, :id => @other_author.id
1475 assigns(:page_size).should eq Author.default_speech_balloon_page_size
1477 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1478 get :speech_balloons, :id => @other_author.id, :page_size => 1500
1479 assigns(:page_size).should eq Author.speech_balloon_max_page_size
1481 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1482 get :speech_balloons, :id => @other_author.id, :page_size => 0
1483 assigns(:page_size).should eq Author.default_speech_balloon_page_size
1486 context 'つつがなく終わるとき' do
1487 it 'ステータスコード200 OKを返す' do
1488 get :speech_balloons, :id => @other_author.id
1489 response.should be_success
1491 it '作家モデルに単体取得を問い合わせている' do
1492 Author.should_receive(:show).exactly(1)
1493 get :speech_balloons, :id => @other_author.id
1495 it 'フキダシモデルに他作家のフキダシ一覧を問い合わせている' do
1496 SpeechBalloon.should_receive(:himlist).exactly(1)
1497 get :speech_balloons, :id => @other_author.id
1499 it '@speech_balloonsにリストを取得している' do
1500 get :speech_balloons, :id => @other_author.id
1501 assigns(:speech_balloons).should have_at_least(3).items
1504 it '@paginateにページ制御を取得している' do
1505 get :speech_balloons, :id => @other_author.id
1506 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1508 it 'speech_balloonsテンプレートを描画する' do
1509 get :speech_balloons, :id => @other_author.id
1510 response.should render_template("speech_balloons")
1515 get :speech_balloons, :id => @other_author.id, :format => :json
1516 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1518 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
1519 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
1520 get :speech_balloons, :id => @other_author.id, :format => :json
1522 it 'データがリスト構造になっている' do
1523 get :speech_balloons, :id => @other_author.id, :format => :json
1524 json = JSON.parse response.body
1525 json.should have_at_least(3).items
1527 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
1528 get :speech_balloons, :id => @other_author.id, :format => :json
1529 json = JSON.parse response.body
1530 json.first.has_key?("speech_balloon_template_id").should be_true
1531 json.first.has_key?("z").should be_true
1532 json.first.has_key?("t").should be_true
1536 context 'ユーザ権限がないとき' do
1541 it 'ステータスコード302 Foundを返す' do
1542 get :speech_balloons, :id => @other_author.id
1543 response.status.should eq 302
1545 it 'サインインページへ遷移する' do
1546 get :speech_balloons, :id => @other_author.id
1547 response.should redirect_to '/users/sign_in'
1551 it 'ステータスコード401 Unauthorizedを返す' do
1552 get :speech_balloons, :id => @other_author.id, :format => :json
1553 response.status.should eq 401
1555 it '応答メッセージにUnauthorizedを返す' do
1556 get :speech_balloons, :id => @other_author.id, :format => :json
1557 response.message.should match(/Unauthorized/)
1561 context 'ユーザ権限はないが管理者権限があるとき' do
1566 it 'ステータスコード200 OKを返す' do
1567 get :speech_balloons, :id => @other_author.id
1568 response.should be_success
1571 context 'ユーザだが作家登録していないとき' do
1575 it 'ステータスコード200 OKを返す' do
1576 get :speech_balloons, :id => @other_author.id
1577 response.should be_success
1582 describe '対象作家の絵地一覧表示に於いて' do
1584 @other_user = FactoryGirl.create( :user_yas)
1585 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1586 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1587 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1588 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1589 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1590 @panel = FactoryGirl.create :panel, :author_id => @author.id
1591 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1592 Author.stub(:show).and_return(@other_author)
1593 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1596 context 'パラメータpageについて' do
1598 get :ground_pictures, :id => @other_author.id, :page => 5
1599 assigns(:page).should eq 5
1601 it '省略されると@pageに1値が入る' do
1602 get :ground_pictures, :id => @other_author.id
1603 assigns(:page).should eq 1
1605 it '与えられたpage_sizeがセットされている' do
1606 get :ground_pictures, :id => @other_author.id, :page_size => 15
1607 assigns(:page_size).should eq 15
1609 it '省略されると@page_sizeにデフォルト値が入る' do
1610 get :ground_pictures, :id => @other_author.id
1611 assigns(:page_size).should eq Author.default_ground_picture_page_size
1613 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1614 get :ground_pictures, :id => @other_author.id, :page_size => 1500
1615 assigns(:page_size).should eq Author.ground_picture_max_page_size
1617 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1618 get :ground_pictures, :id => @other_author.id, :page_size => 0
1619 assigns(:page_size).should eq Author.default_ground_picture_page_size
1622 context 'つつがなく終わるとき' do
1623 it 'ステータスコード200 OKを返す' do
1624 get :ground_pictures, :id => @other_author.id
1625 response.should be_success
1627 it '作家モデルに単体取得を問い合わせている' do
1628 Author.should_receive(:show).exactly(1)
1629 get :ground_pictures, :id => @other_author.id
1631 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
1632 GroundPicture.should_receive(:himlist).exactly(1)
1633 get :ground_pictures, :id => @other_author.id
1635 it '@ground_picturesにリストを取得している' do
1636 get :ground_pictures, :id => @other_author.id
1637 assigns(:ground_pictures).should have_at_least(3).items
1640 it '@paginateにページ制御を取得している' do
1641 get :ground_pictures, :id => @other_author.id
1642 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1644 it 'ground_picturesテンプレートを描画する' do
1645 get :ground_pictures, :id => @other_author.id
1646 response.should render_template("ground_pictures")
1651 get :ground_pictures, :id => @other_author.id, :format => :json
1652 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1654 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
1655 GroundPicture.should_receive(:list_json_opt).exactly(1)
1656 get :ground_pictures, :id => @other_author.id, :format => :json
1658 it 'データがリスト構造になっている' do
1659 get :ground_pictures, :id => @other_author.id, :format => :json
1660 json = JSON.parse response.body
1661 json.should have_at_least(3).items
1663 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
1664 get :ground_pictures, :id => @other_author.id, :format => :json
1665 json = JSON.parse response.body
1666 json.first.has_key?("panel_id").should be_true
1667 json.first.has_key?("picture_id").should be_true
1668 json.first.has_key?("z").should be_true
1672 context 'ユーザ権限がないとき' do
1677 it 'ステータスコード302 Foundを返す' do
1678 get :ground_pictures, :id => @other_author.id
1679 response.status.should eq 302
1681 it 'サインインページへ遷移する' do
1682 get :ground_pictures, :id => @other_author.id
1683 response.should redirect_to '/users/sign_in'
1687 it 'ステータスコード401 Unauthorizedを返す' do
1688 get :ground_pictures, :id => @other_author.id, :format => :json
1689 response.status.should eq 401
1691 it '応答メッセージにUnauthorizedを返す' do
1692 get :ground_pictures, :id => @other_author.id, :format => :json
1693 response.message.should match(/Unauthorized/)
1697 context 'ユーザ権限はないが管理者権限があるとき' do
1702 it 'ステータスコード200 OKを返す' do
1703 get :ground_pictures, :id => @other_author.id
1704 response.should be_success
1707 context 'ユーザだが作家登録していないとき' do
1711 it 'ステータスコード200 OKを返す' do
1712 get :ground_pictures, :id => @other_author.id
1713 response.should be_success
1718 describe '対象作家の色地一覧表示に於いて' do
1720 @other_user = FactoryGirl.create( :user_yas)
1721 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1722 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1723 @gc = FactoryGirl.create :ground_color
1724 @panel = FactoryGirl.create :panel, :author_id => @author.id
1725 Author.stub(:show).and_return(@other_author)
1726 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1729 context 'パラメータpageについて' do
1731 get :ground_colors, :id => @other_author.id, :page => 5
1732 assigns(:page).should eq 5
1734 it '省略されると@pageに1値が入る' do
1735 get :ground_colors, :id => @other_author.id
1736 assigns(:page).should eq 1
1738 it '与えられたpage_sizeがセットされている' do
1739 get :ground_colors, :id => @other_author.id, :page_size => 15
1740 assigns(:page_size).should eq 15
1742 it '省略されると@page_sizeにデフォルト値が入る' do
1743 get :ground_colors, :id => @other_author.id
1744 assigns(:page_size).should eq Author.default_ground_color_page_size
1746 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1747 get :ground_colors, :id => @other_author.id, :page_size => 1500
1748 assigns(:page_size).should eq Author.ground_color_max_page_size
1750 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1751 get :ground_colors, :id => @other_author.id, :page_size => 0
1752 assigns(:page_size).should eq Author.ground_color_page_size
1755 context 'つつがなく終わるとき' do
1756 it 'ステータスコード200 OKを返す' do
1757 get :ground_colors, :id => @other_author.id
1758 response.should be_success
1760 it '作家モデルに単体取得を問い合わせている' do
1761 Author.should_receive(:show).exactly(1)
1762 get :ground_colors, :id => @other_author.id
1764 it '色地モデルに他作家の色地一覧を問い合わせている' do
1765 GroundColor.should_receive(:himlist).exactly(1)
1766 get :ground_colors, :id => @other_author.id
1768 it '@ground_colorsにリストを取得している' do
1769 get :ground_colors, :id => @other_author.id
1770 assigns(:ground_colors).should have_at_least(3).items
1773 it '@paginateにページ制御を取得している' do
1774 get :ground_colors, :id => @other_author.id
1775 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1777 it 'ground_colorsテンプレートを描画する' do
1778 get :ground_colors, :id => @other_author.id
1779 response.should render_template("ground_colors")
1784 get :ground_colors, :id => @other_author.id, :format => :json
1785 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1787 it '色地モデルにjson一覧出力オプションを問い合わせている' do
1788 GroundColor.should_receive(:list_json_opt).exactly(1)
1789 get :ground_colors, :id => @other_author.id, :format => :json
1791 it 'データがリスト構造になっている' do
1792 get :ground_colors, :id => @other_author.id, :format => :json
1793 json = JSON.parse response.body
1794 json.should have_at_least(3).items
1796 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
1797 get :ground_colors, :id => @other_author.id, :format => :json
1798 json = JSON.parse response.body
1799 json.first.has_key?("panel_id").should be_true
1800 json.first.has_key?("code").should be_true
1801 json.first.has_key?("z").should be_true
1805 context 'ユーザ権限がないとき' do
1810 it 'ステータスコード302 Foundを返す' do
1811 get :ground_colors, :id => @other_author.id
1812 response.status.should eq 302
1814 it 'サインインページへ遷移する' do
1815 get :ground_colors, :id => @other_author.id
1816 response.should redirect_to '/users/sign_in'
1820 it 'ステータスコード401 Unauthorizedを返す' do
1821 get :ground_colors, :id => @other_author.id, :format => :json
1822 response.status.should eq 401
1824 it '応答メッセージにUnauthorizedを返す' do
1825 get :ground_colors, :id => @other_author.id, :format => :json
1826 response.message.should match(/Unauthorized/)
1830 context 'ユーザ権限はないが管理者権限があるとき' do
1835 it 'ステータスコード200 OKを返す' do
1836 get :ground_colors, :id => @other_author.id
1837 response.should be_success
1840 context 'ユーザだが作家登録していないとき' do
1844 it 'ステータスコード200 OKを返す' do
1845 get :ground_colors, :id => @other_author.id
1846 response.should be_success
1851 describe '作家数取得に於いて' do
1853 Author.should_receive(:visible_count).and_return(3)
1856 context 'つつがなく終わるとき' do
1857 it 'ステータスコード200 OKを返す' do
1858 get :count, :format => :json
1859 response.should be_success
1863 get :count, :format => :json
1864 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1866 it 'データがHash構造になっていて作家数が3である' do
1867 get :count, :format => :json
1868 json = JSON.parse response.body
1869 json["count"].should == 3
1875 describe '新規作成フォーム表示に於いて' do
1877 @new_user = FactoryGirl.create( :user_yas)
1880 context 'つつがなく終わるとき' do
1881 it 'ステータスコード200 OKを返す' do
1883 response.should be_success
1885 it '@auに新規データを用意している' do
1887 assigns(:au).should be_a_new(Author)
1889 it '作家モデルにデフォルト値補充を依頼している' do
1890 Author.any_instance.should_receive(:supply_default).exactly(1)
1894 it 'newテンプレートを描画する' do
1896 response.should render_template("new")
1900 it 'new.jsテンプレートを描画する' do
1901 get :new, :format => :js
1902 response.should render_template("new")
1907 get :new, :format => :json
1908 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1910 it '作家モデルにjson単体出力オプションを問い合わせている' do
1911 Author.should_receive(:show_json_opt).exactly(1)
1912 get :new, :format => :json
1916 context 'ユーザ権限がないとき' do
1921 it 'ステータスコード302 Foundを返す' do
1923 response.status.should eq 302
1925 it 'サインインページへ遷移する' do
1927 response.body.should redirect_to '/users/sign_in'
1931 it 'ステータスコード401 Unauthorizedを返す' do
1932 get :new, :format => :js
1933 response.status.should eq 401
1935 it '応答メッセージにUnauthorizedを返す' do
1936 get :new, :format => :js
1937 response.message.should match(/Unauthorized/)
1941 it 'ステータスコード401 Unauthorizedを返す' do
1942 get :new, :format => :json
1943 response.status.should eq 401
1945 it '応答メッセージにUnauthorizedを返す' do
1946 get :new, :format => :json
1947 response.message.should match(/Unauthorized/)
1951 context 'ユーザ権限はないが管理者権限があるとき' do
1957 it 'ステータスコード302 Foundを返す' do
1959 response.status.should eq 302
1961 it 'サインインページへ遷移する' do
1963 response.body.should redirect_to '/users/sign_in'
1967 context 'ユーザだが作家登録していないとき' do
1971 it 'ステータスコード200 OKを返す' do
1973 response.should be_success
1978 describe '新規作成に於いて' do
1980 @new_user = FactoryGirl.create( :user_yas)
1982 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1984 context '事前チェックしておく' do
1985 it '作家モデルにデフォルト値補充を依頼している' do
1986 Author.any_instance.should_receive(:supply_default).exactly(1)
1987 post :create, :author => @attr
1989 it '作家モデルにカラム値復元を依頼している' do
1990 Author.any_instance.should_receive(:attributes=).exactly(1)
1991 post :create, :author => @attr
1993 it '作家モデルに上書き補充を依頼している' do
1994 Author.any_instance.should_receive(:overwrite).exactly(1)
1995 post :create, :author => @attr
1998 Author.any_instance.should_receive(:save).exactly(1)
1999 post :create, :author => @attr
2002 context 'つつがなく終わるとき' do
2003 it "@auに作成された作家を保持していて、それがDBにある" do
2004 post :create, :author => @attr
2005 assigns(:au).should be_a(Author)
2006 assigns(:au).should be_persisted
2009 it 'ステータスコード302 Foundを返す' do
2010 Author.any_instance.stub(:save).and_return(true)
2011 post :create, :author => @attr
2012 response.status.should eq 302
2015 # Author.any_instance.stub(:save).and_return(true)
2016 post :create, :author => @attr
2017 response.should redirect_to(root_path)
2021 it 'ステータスコード200 OKを返す' do
2022 # Author.any_instance.stub(:save).and_return(true)
2023 post :create, :author => @attr, :format => :json
2024 response.should be_success
2026 it '作成された作家をjsonデータで返す' do
2027 post :create, :author => @attr, :format => :json
2028 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2030 it '作家モデルにjson単体出力オプションを問い合わせている' do
2031 Author.should_receive(:show_json_opt).exactly(1)
2032 post :create, :author => @attr, :format => :json
2034 it 'データがアレになっている' do
2035 post :create, :author => @attr, :format => :json
2036 json = JSON.parse response.body
2037 json["name"].should match(/ken/)
2041 context 'ユーザ権限がないとき' do
2046 it 'ステータスコード302 Foundを返す' do
2047 post :create, :author => @attr
2048 response.status.should eq 302
2050 it 'サインインページへ遷移する' do
2051 post :create, :author => @attr
2052 response.body.should redirect_to '/users/sign_in'
2056 it 'ステータスコード401 Unauthorizedを返す' do
2057 post :create, :author => @attr, :format => :json
2058 response.status.should eq 401
2060 it '応答メッセージにUnauthorizedを返す' do
2061 post :create, :author => @attr, :format => :json
2062 response.message.should match(/Unauthorized/)
2066 context 'ユーザ権限はないが管理者権限があるとき' do
2072 it 'ステータスコード302 Foundを返す' do
2073 post :create, :author => @attr
2074 response.status.should eq 302
2076 it 'サインインページへ遷移する' do
2077 post :create, :author => @attr
2078 response.body.should redirect_to '/users/sign_in'
2082 context '検証、保存に失敗した' do
2084 Author.any_instance.stub(:save).and_return(false)
2086 it "未保存の作家を保持している" do
2087 post :create, :author => @attr
2088 assigns(:au).should be_a_new(Author)
2091 it 'ステータスコード200 OKを返す' do
2092 post :create, :author => @attr
2093 response.status.should eq 200
2096 post :create, :author => @attr
2097 response.should render_template("new")
2101 it 'ステータスコード422 unprocessable_entity を返す' do
2102 post :create, :author => @attr, :format => :json
2103 response.status.should eq 422
2105 it '応答メッセージUnprocessable Entityを返す' do
2106 post :create, :author => @attr, :format => :json
2107 response.message.should match(/Unprocessable/)
2113 describe '編集フォーム表示に於いて' do
2116 Author.stub(:edit).and_return(@author)
2118 context 'つつがなく終わるとき' do
2119 it 'ステータスコード200 OKを返す' do
2120 get :edit, :id => @author.id
2121 response.should be_success
2123 it '作家モデルに編集取得を問い合わせている' do
2124 Author.should_receive(:edit).exactly(1)
2125 get :edit, :id => @author.id
2127 #@authorだとログイン中のアカウントと干渉してしまう。
2128 it '@auにデータを用意している' do
2129 get :edit, :id => @author.id
2130 assigns(:au).should eq @author
2133 it 'editテンプレートを描画する' do
2134 get :edit, :id => @author.id
2135 response.should render_template("edit")
2139 it 'edit.jsテンプレートを描画する' do
2140 get :edit, :id => @author.id, :format => :js
2141 response.should render_template("edit")
2145 context 'ユーザ権限がないとき' do
2150 it 'ステータスコード302 Foundを返す' do
2151 get :edit, :id => @author.id
2152 response.status.should eq 302
2154 it 'サインインページへ遷移する' do
2155 get :edit, :id => @author.id
2156 response.body.should redirect_to '/users/sign_in'
2160 it 'ステータスコード401 Unauthorizedを返す' do
2161 get :edit, :id => @author.id, :format => :js
2162 response.status.should eq 401
2164 it '応答メッセージにUnauthorizedを返す' do
2165 get :edit, :id => @author.id, :format => :js
2166 response.message.should match(/Unauthorized/)
2170 context 'ユーザ権限はないが管理者権限があるとき' do
2176 it 'ステータスコード302 Foundを返す' do
2177 get :edit, :id => @author.id
2178 response.status.should eq 302
2180 it 'サインインページへ遷移する' do
2181 get :edit, :id => @author.id
2182 response.body.should redirect_to '/users/sign_in'
2186 context 'ユーザだが作家登録していないとき' do
2188 @other_user = FactoryGirl.create( :user_yas)
2189 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2193 it 'ステータスコード302 Foundを返す' do
2194 get :edit, :id => @other_author.id
2195 response.status.should eq 302
2197 it '作家登録ページへ遷移する' do
2198 get :edit, :id => @other_author.id
2199 response.body.should redirect_to new_author_path
2205 describe '更新に於いて' do
2207 @attr = @author.attributes
2208 @attr['name'] = 'ryu'
2211 context '事前チェックしておく' do
2212 it '作家モデルに編集取得を問い合わせている' do
2213 Author.stub(:edit).with(any_args()).and_return @author
2214 Author.should_receive(:edit).exactly(1)
2215 put :update, :id => @author.id, :author => @attr
2217 it 'モデルにpostデータ転送を依頼する' do
2218 Author.any_instance.stub(:attributes=).with(any_args)
2219 Author.any_instance.should_receive(:attributes=).exactly(1)
2220 put :update, :id => @author.id, :author => @attr
2222 it 'モデルに上書き補充を依頼する' do
2223 Author.any_instance.stub(:overwrite).with(any_args)
2224 Author.any_instance.should_receive(:overwrite).exactly(1)
2225 put :update, :id => @author.id, :author => @attr
2228 Author.any_instance.stub(:save).with(any_args).and_return true
2229 Author.any_instance.should_receive(:save).exactly(1)
2230 put :update, :id => @author.id, :author => @attr
2232 it '@auにアレを取得している' do
2233 put :update, :id => @author.id, :author => @attr
2234 assigns(:au).should eq @author
2237 context 'つつがなく終わるとき' do
2239 put :update, :id => @author.id, :author => @attr
2240 Author.find(@author.id).name.should eq 'ryu'
2243 it 'ステータスコード302 Foundを返す' do
2244 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2245 put :update, :id => @author.id, :author => @attr
2246 response.status.should eq 302
2249 put :update, :id => @author.id, :author => @attr
2250 response.should redirect_to('/home/configure')
2254 it 'ステータスコード200 OKを返す' do
2255 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2256 put :update, :id => @author.id, :author => @attr, :format => :json
2257 response.should be_success
2259 it 'ページ本体は特に返さない' do
2260 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2261 put :update, :id => @author.id, :author => @attr, :format => :json
2262 response.body.should match /./
2266 context 'ユーザ権限がないとき' do
2271 it 'ステータスコード302 Foundを返す' do
2272 put :update, :id => @author.id, :author => @attr
2273 response.status.should eq 302
2275 it 'サインインページへ遷移する' do
2276 put :update, :id => @author.id, :author => @attr
2277 response.body.should redirect_to '/users/sign_in'
2281 it '応答メッセージにUnauthorizedを返す' do
2282 put :update, :id => @author.id, :author => @attr, :format => :json
2283 response.message.should match(/Unauthorized/)
2287 context 'ユーザ権限はないが管理者権限があるとき' do
2293 it 'ステータスコード302 Foundを返す' do
2294 put :update, :id => @author.id, :author => @attr
2295 response.status.should eq 302
2297 it 'サインインページへ遷移する' do
2298 put :update, :id => @author.id, :author => @attr
2299 response.body.should redirect_to '/users/sign_in'
2303 context 'ユーザだが作家登録していないとき' do
2305 @other_user = FactoryGirl.create( :user_yas)
2306 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2310 it 'ステータスコード302 Foundを返す' do
2311 get :update, :id => @other_author.id
2312 response.status.should eq 302
2314 it '作家登録ページへ遷移する' do
2315 get :update, :id => @other_author.id
2316 response.body.should redirect_to new_author_path
2320 context '検証、保存に失敗したとき' do
2322 Author.any_instance.stub(:save).and_return(false)
2325 it 'ステータスコード200 Okを返す' do
2326 put :update, :id => @author.id, :author => @attr
2327 response.status.should eq 200
2330 put :update, :id => @author.id, :author => @attr
2331 response.should render_template("edit")
2335 it 'ステータスコード422 unprocessable_entity を返す' do
2336 Author.any_instance.stub(:save).and_return(false)
2337 put :update, :id => @author.id, :author => @attr, :format => :json
2338 response.status.should eq 422
2340 it '応答メッセージUnprocessable Entityを返す' do
2341 put :update, :id => @author.id, :author => @attr, :format => :json
2342 response.message.should match(/Unprocessable/)
2349 describe '一覧表示に於いて' do
2351 Author.stub(:list).and_return([@author, @author, @author])
2354 context 'つつがなく終わるとき' do
2355 it 'ステータスコード200 OKを返す' do
2357 response.should be_success
2360 it 'indexテンプレートを描画する' do
2362 response.should render_template("index")
2367 get :index, :format => :json
2368 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2372 context 'ユーザ権限がないとき' do
2376 it 'ステータスコード200 OKを返す' do
2378 response.should be_success
2381 it 'indexテンプレートを描画する' do
2383 response.should render_template("index")
2388 get :index, :format => :json
2389 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2395 describe '閲覧に於いて' do
2397 Author.stub(:show).and_return(@author)
2400 context 'つつがなく終わるとき' do
2401 it 'ステータスコード200 OKを返す' do
2402 get :show, :id => @author.id
2403 response.should be_success
2406 it 'showテンプレートを描画する' do
2407 get :show, :id => @author.id
2408 response.should render_template("show")
2413 get :show, :id => @author.id, :format => :json
2414 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2418 context 'ユーザ権限がないとき' do
2422 it 'ステータスコード200 OKを返す' do
2423 get :show, :id => @author.id
2424 response.should be_success
2427 it 'showテンプレートを描画する' do
2428 get :show, :id => @author.id
2429 response.should render_template("show")
2434 get :show, :id => @author.id, :format => :json
2435 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2441 describe '対象作家のスクロール一覧表示に於いて' do
2443 @other_user = FactoryGirl.create( :user_yas)
2444 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2445 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2446 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
2447 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
2450 context 'つつがなく終わるとき' do
2451 it 'ステータスコード200 OKを返す' do
2452 get :scrolls, :id => @other_author.id
2453 response.should be_success
2456 it 'scrollテンプレートを描画する' do
2457 get :scrolls, :id => @other_author.id
2458 response.should render_template("scroll")
2463 get :scrolls, :id => @other_author.id, :format => :json
2464 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2468 context 'ユーザ権限がないとき' do
2472 it 'ステータスコード200 OKを返す' do
2473 get :scrolls, :id => @other_author.id
2474 response.should be_success
2477 it 'scrollsテンプレートを描画する' do
2478 get :scrolls, :id => @other_author.id
2479 response.should render_template("scrolls")
2484 get :scrolls, :id => @other_author.id, :format => :json
2485 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2491 describe '対象作家のスクコマ一覧表示に於いて' do
2493 @other_user = FactoryGirl.create( :user_yas)
2494 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2495 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2496 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
2497 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
2498 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id
2499 ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
2502 context 'つつがなく終わるとき' do
2503 it 'ステータスコード200 OKを返す' do
2504 get :scroll_panels, :id => @other_author.id
2505 response.should be_success
2508 it 'scroll_panelsテンプレートを描画する' do
2509 get :scroll_panels, :id => @other_author.id
2510 response.should render_template("scroll_panels")
2515 get :scroll_panels, :id => @other_author.id, :format => :json
2516 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2520 context 'ユーザ権限がないとき' do
2524 it 'ステータスコード200 OKを返す' do
2525 get :scroll_panels, :id => @other_author.id
2526 response.should be_success
2529 it 'scroll_panelsテンプレートを描画する' do
2530 get :scroll_panels, :id => @other_author.id
2531 response.should render_template("scroll_panels")
2536 get :scroll_panels, :id => @other_author.id, :format => :json
2537 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2543 describe '対象作家のコマ一覧表示に於いて' do
2545 @other_user = FactoryGirl.create( :user_yas)
2546 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2547 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2548 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
2549 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
2552 context 'つつがなく終わるとき' do
2553 it 'ステータスコード200 OKを返す' do
2554 get :panels, :id => @other_author.id
2555 response.should be_success
2558 it 'panelsテンプレートを描画する' do
2559 get :panels, :id => @other_author.id
2560 response.should render_template("panels")
2565 get :panels, :id => @other_author.id, :format => :json
2566 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2570 context 'ユーザ権限がないとき' do
2574 it 'ステータスコード200 OKを返す' do
2575 get :panels, :id => @other_author.id
2576 response.should be_success
2579 it 'panelsテンプレートを描画する' do
2580 get :panels, :id => @other_author.id
2581 response.should render_template("panels")
2586 get :panels, :id => @other_author.id, :format => :json
2587 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2593 describe '対象作家のコマ絵一覧表示に於いて' do
2595 @other_user = FactoryGirl.create( :user_yas)
2596 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2597 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2598 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
2599 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
2600 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
2601 @panel = FactoryGirl.create :panel, :author_id => @author.id
2602 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
2603 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
2606 context 'つつがなく終わるとき' do
2607 it 'ステータスコード200 OKを返す' do
2608 get :panel_pictures, :id => @other_author.id
2609 response.should be_success
2612 it 'panel_picturesテンプレートを描画する' do
2613 get :panel_pictures, :id => @other_author.id
2614 response.should render_template("panel_pictures")
2619 get :panel_pictures, :id => @other_author.id, :format => :json
2620 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2624 context 'ユーザ権限がないとき' do
2628 it 'ステータスコード200 OKを返す' do
2629 get :panel_pictures, :id => @other_author.id
2630 response.should be_success
2633 it 'panel_picturesテンプレートを描画する' do
2634 get :panel_pictures, :id => @other_author.id
2635 response.should render_template("panel_pictures")
2640 get :panel_pictures, :id => @other_author.id, :format => :json
2641 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2647 describe '対象作家の絵地一覧表示に於いて' do
2649 @other_user = FactoryGirl.create( :user_yas)
2650 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2651 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2652 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
2653 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
2654 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
2655 @panel = FactoryGirl.create :panel, :author_id => @author.id
2656 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
2657 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
2660 context 'つつがなく終わるとき' do
2661 it 'ステータスコード200 OKを返す' do
2662 get :ground_pictures, :id => @other_author.id
2663 response.should be_success
2666 it 'ground_picturesテンプレートを描画する' do
2667 get :ground_pictures, :id => @other_author.id
2668 response.should render_template("ground_pictures")
2673 get :ground_pictures, :id => @other_author.id, :format => :json
2674 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2678 context 'ユーザ権限がないとき' do
2683 it 'ground_picturesテンプレートを描画する' do
2684 get :ground_pictures, :id => @other_author.id
2685 response.should render_template("ground_pictures")
2690 get :ground_pictures, :id => @other_author.id, :format => :json
2691 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2697 describe '対象作家の色地一覧表示に於いて' do
2699 @other_user = FactoryGirl.create( :user_yas)
2700 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2701 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2702 @gc = FactoryGirl.create :ground_color
2703 @panel = FactoryGirl.create :panel, :author_id => @author.id
2704 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
2707 context 'つつがなく終わるとき' do
2708 it 'ステータスコード200 OKを返す' do
2709 get :ground_colors, :id => @other_author.id
2710 response.should be_success
2713 it 'ground_colorsテンプレートを描画する' do
2714 get :ground_colors, :id => @other_author.id
2715 response.should render_template("ground_colors")
2720 get :ground_colors, :id => @other_author.id, :format => :json
2721 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2725 context 'ユーザ権限がないとき' do
2730 it 'ground_colorsテンプレートを描画する' do
2731 get :ground_colors, :id => @other_author.id
2732 response.should render_template("ground_colors")
2737 get :ground_colors, :id => @other_author.id, :format => :json
2738 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2744 describe '作家数取得に於いて' do
2746 Author.should_receive(:visible_count).and_return(3)
2749 context 'つつがなく終わるとき' do
2750 it 'ステータスコード200 OKを返す' do
2751 get :count, :format => :json
2752 response.should be_success
2756 get :count, :format => :json
2757 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2763 describe '新規作成フォーム表示に於いて' do
2765 @new_user = FactoryGirl.create( :user_yas)
2768 context 'つつがなく終わるとき' do
2769 it 'ステータスコード200 OKを返す' do
2771 response.should be_success
2774 it 'newテンプレートを描画する' do
2776 response.should render_template("new")
2780 it 'new.jsテンプレートを描画する' do
2781 get :new, :format => :js
2782 response.should render_template("new")
2787 get :new, :format => :json
2788 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2792 context 'ユーザ権限がないとき' do
2797 it 'ステータスコード302 Foundを返す' do
2799 response.status.should eq 302
2801 it 'サインインページへ遷移する' do
2803 response.body.should redirect_to '/users/sign_in'
2807 it 'ステータスコード401 Unauthorizedを返す' do
2808 get :new, :format => :js
2809 response.status.should eq 401
2811 it '応答メッセージにUnauthorizedを返す' do
2812 get :new, :format => :js
2813 response.message.should match(/Unauthorized/)
2817 it 'ステータスコード401 Unauthorizedを返す' do
2818 get :new, :format => :json
2819 response.status.should eq 401
2821 it '応答メッセージにUnauthorizedを返す' do
2822 get :new, :format => :json
2823 response.message.should match(/Unauthorized/)
2829 describe '新規作成に於いて' do
2831 @new_user = FactoryGirl.create( :user_yas)
2833 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
2835 context 'つつがなく終わるとき' do
2837 it 'ステータスコード302 Foundを返す' do
2838 Author.any_instance.stub(:save).and_return(true)
2839 post :create, :author => @attr
2840 response.status.should eq 302
2843 # Author.any_instance.stub(:save).and_return(true)
2844 post :create, :author => @attr
2845 response.should redirect_to(root_path)
2849 it 'ステータスコード200 OKを返す' do
2850 # Author.any_instance.stub(:save).and_return(true)
2851 post :create, :author => @attr, :format => :json
2852 response.should be_success
2856 context 'ユーザ権限がないとき' do
2861 it 'ステータスコード302 Foundを返す' do
2862 post :create, :author => @attr
2863 response.status.should eq 302
2865 it 'サインインページへ遷移する' do
2866 post :create, :author => @attr
2867 response.body.should redirect_to '/users/sign_in'
2871 it 'ステータスコード401 Unauthorizedを返す' do
2872 post :create, :author => @attr, :format => :json
2873 response.status.should eq 401
2875 it '応答メッセージにUnauthorizedを返す' do
2876 post :create, :author => @attr, :format => :json
2877 response.message.should match(/Unauthorized/)
2883 describe '編集フォーム表示に於いて' do
2886 Author.stub(:edit).and_return(@author)
2888 context 'つつがなく終わるとき' do
2889 it 'ステータスコード200 OKを返す' do
2890 get :edit, :id => @author.id
2891 response.should be_success
2894 it 'editテンプレートを描画する' do
2895 get :edit, :id => @author.id
2896 response.should render_template("edit")
2900 it 'edit.jsテンプレートを描画する' do
2901 get :edit, :id => @author.id, :format => :js
2902 response.should render_template("edit")
2906 context 'ユーザ権限がないとき' do
2911 it 'ステータスコード302 Foundを返す' do
2912 get :edit, :id => @author.id
2913 response.status.should eq 302
2915 it 'サインインページへ遷移する' do
2916 get :edit, :id => @author.id
2917 response.body.should redirect_to '/users/sign_in'
2921 it 'ステータスコード401 Unauthorizedを返す' do
2922 get :edit, :id => @author.id, :format => :js
2923 response.status.should eq 401
2925 it '応答メッセージにUnauthorizedを返す' do
2926 get :edit, :id => @author.id, :format => :js
2927 response.message.should match(/Unauthorized/)
2933 describe '更新に於いて' do
2935 @attr = @author.attributes
2936 @attr['name'] = 'ryu'
2939 context 'つつがなく終わるとき' do
2941 put :update, :id => @author.id, :author => @attr
2942 Author.find(@author.id).name.should eq 'ryu'
2945 it 'ステータスコード302 Foundを返す' do
2946 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2947 put :update, :id => @author.id, :author => @attr
2948 response.status.should eq 302
2951 put :update, :id => @author.id, :author => @attr
2952 response.should redirect_to('/home/configure')
2956 it 'ステータスコード200 OKを返す' do
2957 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2958 put :update, :id => @author.id, :author => @attr, :format => :json
2959 response.should be_success
2961 it 'ページ本体は特に返さない' do
2962 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2963 put :update, :id => @author.id, :author => @attr, :format => :json
2964 response.body.should match /./
2968 context 'ユーザ権限がないとき' do
2972 it 'ステータスコード302 Foundを返す' do
2973 put :update, :id => @author.id, :author => @attr
2974 response.status.should eq 302
2977 it 'サインインページへ遷移する' do
2978 put :update, :id => @author.id, :author => @attr
2979 response.body.should redirect_to '/users/sign_in'
2983 it '応答メッセージにUnauthorizedを返す' do
2984 put :update, :id => @author.id, :author => @attr, :format => :json
2985 response.message.should match(/Unauthorized/)