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 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
519 Author.stub(:show).and_return(@other_author)
520 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
523 context 'パラメータpageについて' do
525 get :panels, :id => @other_author.id, :page => 5
526 assigns(:page).should eq 5
528 it '省略されると@pageに1値が入る' do
529 get :panels, :id => @other_author.id
530 assigns(:page).should eq 1
532 it '与えられたpage_sizeがセットされている' do
533 get :panels, :id => @other_author.id, :page_size => 15
534 assigns(:page_size).should eq 15
536 it '省略されると@page_sizeにデフォルト値が入る' do
537 get :panels, :id => @other_author.id
538 assigns(:page_size).should eq Author.default_panel_page_size
540 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
541 get :panels, :id => @other_author.id, :page_size => 1500
542 assigns(:page_size).should eq Author.panel_max_page_size
544 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
545 get :panels, :id => @other_author.id, :page_size => 0
546 assigns(:page_size).should eq Author.default_panel_page_size
549 context 'つつがなく終わるとき' do
550 it 'ステータスコード200 OKを返す' do
551 get :panels, :id => @other_author.id
552 response.should be_success
554 it '作家モデルに単体取得を問い合わせている' do
555 Author.should_receive(:show).exactly(1)
556 get :panels, :id => @other_author.id
558 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
559 Panel.should_receive(:himlist).exactly(1)
560 get :panels, :id => @other_author.id
562 it '@panelsにリストを取得している' do
563 get :panels, :id => @other_author.id
564 assigns(:panels).should have_at_least(3).items
567 it '@paginateにページ制御を取得している' do
568 get :panels, :id => @other_author.id
569 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
571 it 'panelsテンプレートを描画する' do
572 get :panels, :id => @other_author.id
573 response.should render_template("panels")
578 get :panels, :id => @other_author.id, :format => :json
579 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
581 it 'コマモデルにコマリストのjson出力を問い合わせている' do
582 Panel.should_receive(:list_as_json_text).exactly(1)
583 get :panels, :id => @other_author.id, :format => :json
585 it 'データがリスト構造になっている' do
586 get :panels, :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 :panels, :id => @other_author.id, :format => :json
592 json = JSON.parse response.body
593 json.first.has_key?("z").should be_true
597 context 'ユーザ権限がないとき' do
602 it 'ステータスコード302 Foundを返す' do
603 get :panels, :id => @other_author.id
604 response.status.should eq 302
606 it 'サインインページへ遷移する' do
607 get :panels, :id => @other_author.id
608 response.should redirect_to '/users/sign_in'
612 it 'ステータスコード401 Unauthorizedを返す' do
613 get :panels, :id => @other_author.id, :format => :json
614 response.status.should eq 401
616 it '応答メッセージにUnauthorizedを返す' do
617 get :panels, :id => @other_author.id, :format => :json
618 response.message.should match(/Unauthorized/)
622 context 'ユーザ権限はないが管理者権限があるとき' do
627 it 'ステータスコード200 OKを返す' do
628 get :panels, :id => @other_author.id
629 response.should be_success
632 context 'ユーザだが作家登録していないとき' do
636 it 'ステータスコード200 OKを返す' do
637 get :panels, :id => @other_author.id
638 response.should be_success
643 describe '対象作家のコマ絵一覧表示に於いて' do
645 @other_user = FactoryGirl.create( :user_yas)
646 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
647 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
648 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
649 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
650 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
651 @panel = FactoryGirl.create :panel, :author_id => @author.id
652 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
653 Author.stub(:show).and_return(@other_author)
654 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
657 context 'パラメータpageについて' do
659 get :panel_pictures, :id => @other_author.id, :page => 5
660 assigns(:page).should eq 5
662 it '省略されると@pageに1値が入る' do
663 get :panel_pictures, :id => @other_author.id
664 assigns(:page).should eq 1
666 it '与えられたpage_sizeがセットされている' do
667 get :panel_pictures, :id => @other_author.id, :page_size => 15
668 assigns(:page_size).should eq 15
670 it '省略されると@page_sizeにデフォルト値が入る' do
671 get :panel_pictures, :id => @other_author.id
672 assigns(:page_size).should eq Author.default_panel_picture_page_size
674 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
675 get :panel_pictures, :id => @other_author.id, :page_size => 1500
676 assigns(:page_size).should eq Author.panel_picture_max_page_size
678 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
679 get :panel_pictures, :id => @other_author.id, :page_size => 0
680 assigns(:page_size).should eq Author.default_panel_picture_page_size
683 context 'つつがなく終わるとき' do
684 it 'ステータスコード200 OKを返す' do
685 get :panel_pictures, :id => @other_author.id
686 response.should be_success
688 it '作家モデルに単体取得を問い合わせている' do
689 Author.should_receive(:show).exactly(1)
690 get :panel_pictures, :id => @other_author.id
692 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
693 PanelPicture.should_receive(:himlist).exactly(1)
694 get :panel_pictures, :id => @other_author.id
696 it '@panel_picturesにリストを取得している' do
697 get :panel_pictures, :id => @other_author.id
698 assigns(:panel_pictures).should have_at_least(3).items
701 it '@paginateにページ制御を取得している' do
702 get :panel_pictures, :id => @other_author.id
703 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
705 it 'panel_picturesテンプレートを描画する' do
706 get :panel_pictures, :id => @other_author.id
707 response.should render_template("panel_pictures")
712 get :panel_pictures, :id => @other_author.id, :format => :json
713 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
715 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
716 PanelPicture.should_receive(:list_json_opt).exactly(1)
717 get :panel_pictures, :id => @other_author.id, :format => :json
719 it 'データがリスト構造になっている' do
720 get :panel_pictures, :id => @other_author.id, :format => :json
721 json = JSON.parse response.body
722 json.should have_at_least(3).items
724 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
725 get :panel_pictures, :id => @other_author.id, :format => :json
726 json = JSON.parse response.body
727 json.first.has_key?("link").should be_true
728 json.first.has_key?("x").should be_true
729 json.first.has_key?("y").should be_true
733 context 'ユーザ権限がないとき' do
738 it 'ステータスコード302 Foundを返す' do
739 get :panel_pictures, :id => @other_author.id
740 response.status.should eq 302
742 it 'サインインページへ遷移する' do
743 get :panel_pictures, :id => @other_author.id
744 response.should redirect_to '/users/sign_in'
748 it 'ステータスコード401 Unauthorizedを返す' do
749 get :panel_pictures, :id => @other_author.id, :format => :json
750 response.status.should eq 401
752 it '応答メッセージにUnauthorizedを返す' do
753 get :panel_pictures, :id => @other_author.id, :format => :json
754 response.message.should match(/Unauthorized/)
758 context 'ユーザ権限はないが管理者権限があるとき' do
763 it 'ステータスコード200 OKを返す' do
764 get :panel_pictures, :id => @other_author.id
765 response.should be_success
768 context 'ユーザだが作家登録していないとき' do
772 it 'ステータスコード200 OKを返す' do
773 get :panel_pictures, :id => @other_author.id
774 response.should be_success
779 describe '対象作家のフキダシ一覧表示に於いて' do
781 @other_user = FactoryGirl.create( :user_yas)
782 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
783 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
784 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
785 @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
786 @speech = @sb.build_speech(
787 FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
789 @balloon = @sb.build_balloon(
790 FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
794 Author.stub(:show).and_return(@other_author)
795 SpeechBalloon.stub(:himlist).and_return([@sb, @sb, @sb])
798 context 'パラメータpageについて' do
800 get :speech_balloons, :id => @other_author.id, :page => 5
801 assigns(:page).should eq 5
803 it '省略されると@pageに1値が入る' do
804 get :speech_balloons, :id => @other_author.id
805 assigns(:page).should eq 1
807 it '与えられたpage_sizeがセットされている' do
808 get :speech_balloons, :id => @other_author.id, :page_size => 15
809 assigns(:page_size).should eq 15
811 it '省略されると@page_sizeにデフォルト値が入る' do
812 get :speech_balloons, :id => @other_author.id
813 assigns(:page_size).should eq Author.default_speech_balloon_page_size
815 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
816 get :speech_balloons, :id => @other_author.id, :page_size => 1500
817 assigns(:page_size).should eq Author.speech_balloon_max_page_size
819 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
820 get :speech_balloons, :id => @other_author.id, :page_size => 0
821 assigns(:page_size).should eq Author.default_speech_balloon_page_size
824 context 'つつがなく終わるとき' do
825 it 'ステータスコード200 OKを返す' do
826 get :speech_balloons, :id => @other_author.id
827 response.should be_success
829 it '作家モデルに単体取得を問い合わせている' do
830 Author.should_receive(:show).exactly(1)
831 get :speech_balloons, :id => @other_author.id
833 it 'フキダシモデルに他作家のフキダシ一覧を問い合わせている' do
834 SpeechBalloon.should_receive(:himlist).exactly(1)
835 get :speech_balloons, :id => @other_author.id
837 it '@speech_balloonsにリストを取得している' do
838 get :speech_balloons, :id => @other_author.id
839 assigns(:speech_balloons).should have_at_least(3).items
842 it '@paginateにページ制御を取得している' do
843 get :speech_balloons, :id => @other_author.id
844 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
846 it 'speech_balloonsテンプレートを描画する' do
847 get :speech_balloons, :id => @other_author.id
848 response.should render_template("speech_balloons")
853 get :speech_balloons, :id => @other_author.id, :format => :json
854 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
856 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
857 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
858 get :speech_balloons, :id => @other_author.id, :format => :json
860 it 'データがリスト構造になっている' do
861 get :speech_balloons, :id => @other_author.id, :format => :json
862 json = JSON.parse response.body
863 json.should have_at_least(3).items
865 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
866 get :speech_balloons, :id => @other_author.id, :format => :json
867 json = JSON.parse response.body
868 json.first.has_key?("speech_balloon_template_id").should be_true
869 json.first.has_key?("z").should be_true
870 json.first.has_key?("t").should be_true
874 context 'ユーザ権限がないとき' do
879 it 'ステータスコード302 Foundを返す' do
880 get :speech_balloons, :id => @other_author.id
881 response.status.should eq 302
883 it 'サインインページへ遷移する' do
884 get :speech_balloons, :id => @other_author.id
885 response.should redirect_to '/users/sign_in'
889 it 'ステータスコード401 Unauthorizedを返す' do
890 get :speech_balloons, :id => @other_author.id, :format => :json
891 response.status.should eq 401
893 it '応答メッセージにUnauthorizedを返す' do
894 get :speech_balloons, :id => @other_author.id, :format => :json
895 response.message.should match(/Unauthorized/)
899 context 'ユーザ権限はないが管理者権限があるとき' do
904 it 'ステータスコード200 OKを返す' do
905 get :speech_balloons, :id => @other_author.id
906 response.should be_success
909 context 'ユーザだが作家登録していないとき' do
913 it 'ステータスコード200 OKを返す' do
914 get :speech_balloons, :id => @other_author.id
915 response.should be_success
920 describe '対象作家の絵地一覧表示に於いて' do
922 @other_user = FactoryGirl.create( :user_yas)
923 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
924 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
925 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
926 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
927 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
928 @panel = FactoryGirl.create :panel, :author_id => @author.id
929 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
930 Author.stub(:show).and_return(@other_author)
931 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
934 context 'パラメータpageについて' do
936 get :ground_pictures, :id => @other_author.id, :page => 5
937 assigns(:page).should eq 5
939 it '省略されると@pageに1値が入る' do
940 get :ground_pictures, :id => @other_author.id
941 assigns(:page).should eq 1
943 it '与えられたpage_sizeがセットされている' do
944 get :ground_pictures, :id => @other_author.id, :page_size => 15
945 assigns(:page_size).should eq 15
947 it '省略されると@page_sizeにデフォルト値が入る' do
948 get :ground_pictures, :id => @other_author.id
949 assigns(:page_size).should eq Author.default_ground_picture_page_size
951 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
952 get :ground_pictures, :id => @other_author.id, :page_size => 1500
953 assigns(:page_size).should eq Author.ground_picture_max_page_size
955 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
956 get :ground_pictures, :id => @other_author.id, :page_size => 0
957 assigns(:page_size).should eq Author.default_ground_picture_page_size
960 context 'つつがなく終わるとき' do
961 it 'ステータスコード200 OKを返す' do
962 get :ground_pictures, :id => @other_author.id
963 response.should be_success
965 it '作家モデルに単体取得を問い合わせている' do
966 Author.should_receive(:show).exactly(1)
967 get :ground_pictures, :id => @other_author.id
969 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
970 GroundPicture.should_receive(:himlist).exactly(1)
971 get :ground_pictures, :id => @other_author.id
973 it '@ground_picturesにリストを取得している' do
974 get :ground_pictures, :id => @other_author.id
975 assigns(:ground_pictures).should have_at_least(3).items
978 it '@paginateにページ制御を取得している' do
979 get :ground_pictures, :id => @other_author.id
980 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
982 it 'ground_picturesテンプレートを描画する' do
983 get :ground_pictures, :id => @other_author.id
984 response.should render_template("ground_pictures")
989 get :ground_pictures, :id => @other_author.id, :format => :json
990 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
992 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
993 GroundPicture.should_receive(:list_json_opt).exactly(1)
994 get :ground_pictures, :id => @other_author.id, :format => :json
996 it 'データがリスト構造になっている' do
997 get :ground_pictures, :id => @other_author.id, :format => :json
998 json = JSON.parse response.body
999 json.should have_at_least(3).items
1001 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
1002 get :ground_pictures, :id => @other_author.id, :format => :json
1003 json = JSON.parse response.body
1004 json.first.has_key?("panel_id").should be_true
1005 json.first.has_key?("picture_id").should be_true
1006 json.first.has_key?("z").should be_true
1010 context 'ユーザ権限がないとき' do
1015 it 'ステータスコード302 Foundを返す' do
1016 get :ground_pictures, :id => @other_author.id
1017 response.status.should eq 302
1019 it 'サインインページへ遷移する' do
1020 get :ground_pictures, :id => @other_author.id
1021 response.should redirect_to '/users/sign_in'
1025 it 'ステータスコード401 Unauthorizedを返す' do
1026 get :ground_pictures, :id => @other_author.id, :format => :json
1027 response.status.should eq 401
1029 it '応答メッセージにUnauthorizedを返す' do
1030 get :ground_pictures, :id => @other_author.id, :format => :json
1031 response.message.should match(/Unauthorized/)
1035 context 'ユーザ権限はないが管理者権限があるとき' do
1040 it 'ステータスコード200 OKを返す' do
1041 get :ground_pictures, :id => @other_author.id
1042 response.should be_success
1045 context 'ユーザだが作家登録していないとき' do
1049 it 'ステータスコード200 OKを返す' do
1050 get :ground_pictures, :id => @other_author.id
1051 response.should be_success
1056 describe '対象作家の色地一覧表示に於いて' do
1058 @other_user = FactoryGirl.create( :user_yas)
1059 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1060 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1061 @gc = FactoryGirl.create :ground_color
1062 @panel = FactoryGirl.create :panel, :author_id => @author.id
1063 Author.stub(:show).and_return(@other_author)
1064 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1067 context 'パラメータpageについて' do
1069 get :ground_colors, :id => @other_author.id, :page => 5
1070 assigns(:page).should eq 5
1072 it '省略されると@pageに1値が入る' do
1073 get :ground_colors, :id => @other_author.id
1074 assigns(:page).should eq 1
1076 it '与えられたpage_sizeがセットされている' do
1077 get :ground_colors, :id => @other_author.id, :page_size => 15
1078 assigns(:page_size).should eq 15
1080 it '省略されると@page_sizeにデフォルト値が入る' do
1081 get :ground_colors, :id => @other_author.id
1082 assigns(:page_size).should eq Author.default_ground_color_page_size
1084 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1085 get :ground_colors, :id => @other_author.id, :page_size => 1500
1086 assigns(:page_size).should eq Author.ground_color_max_page_size
1088 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1089 get :ground_colors, :id => @other_author.id, :page_size => 0
1090 assigns(:page_size).should eq Author.ground_color_page_size
1093 context 'つつがなく終わるとき' do
1094 it 'ステータスコード200 OKを返す' do
1095 get :ground_colors, :id => @other_author.id
1096 response.should be_success
1098 it '作家モデルに単体取得を問い合わせている' do
1099 Author.should_receive(:show).exactly(1)
1100 get :ground_colors, :id => @other_author.id
1102 it '色地モデルに他作家の色地一覧を問い合わせている' do
1103 GroundColor.should_receive(:himlist).exactly(1)
1104 get :ground_colors, :id => @other_author.id
1106 it '@ground_colorsにリストを取得している' do
1107 get :ground_colors, :id => @other_author.id
1108 assigns(:ground_colors).should have_at_least(3).items
1111 it '@paginateにページ制御を取得している' do
1112 get :ground_colors, :id => @other_author.id
1113 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1115 it 'ground_colorsテンプレートを描画する' do
1116 get :ground_colors, :id => @other_author.id
1117 response.should render_template("ground_colors")
1122 get :ground_colors, :id => @other_author.id, :format => :json
1123 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1125 it '色地モデルにjson一覧出力オプションを問い合わせている' do
1126 GroundColor.should_receive(:list_json_opt).exactly(1)
1127 get :ground_colors, :id => @other_author.id, :format => :json
1129 it 'データがリスト構造になっている' do
1130 get :ground_colors, :id => @other_author.id, :format => :json
1131 json = JSON.parse response.body
1132 json.should have_at_least(3).items
1134 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
1135 get :ground_colors, :id => @other_author.id, :format => :json
1136 json = JSON.parse response.body
1137 json.first.has_key?("panel_id").should be_true
1138 json.first.has_key?("code").should be_true
1139 json.first.has_key?("z").should be_true
1143 context 'ユーザ権限がないとき' do
1148 it 'ステータスコード302 Foundを返す' do
1149 get :ground_colors, :id => @other_author.id
1150 response.status.should eq 302
1152 it 'サインインページへ遷移する' do
1153 get :ground_colors, :id => @other_author.id
1154 response.should redirect_to '/users/sign_in'
1158 it 'ステータスコード401 Unauthorizedを返す' do
1159 get :ground_colors, :id => @other_author.id, :format => :json
1160 response.status.should eq 401
1162 it '応答メッセージにUnauthorizedを返す' do
1163 get :ground_colors, :id => @other_author.id, :format => :json
1164 response.message.should match(/Unauthorized/)
1168 context 'ユーザ権限はないが管理者権限があるとき' do
1173 it 'ステータスコード200 OKを返す' do
1174 get :ground_colors, :id => @other_author.id
1175 response.should be_success
1178 context 'ユーザだが作家登録していないとき' do
1182 it 'ステータスコード200 OKを返す' do
1183 get :ground_colors, :id => @other_author.id
1184 response.should be_success
1189 describe '作家数取得に於いて' do
1191 Author.should_receive(:visible_count).and_return(3)
1194 context 'つつがなく終わるとき' do
1195 it 'ステータスコード200 OKを返す' do
1196 get :count, :format => :json
1197 response.should be_success
1201 get :count, :format => :json
1202 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1204 it 'データがHash構造になっていて作家数が3である' do
1205 get :count, :format => :json
1206 json = JSON.parse response.body
1207 json["count"].should == 3
1213 describe '新規作成フォーム表示に於いて' do
1215 @new_user = FactoryGirl.create( :user_yas)
1218 context 'つつがなく終わるとき' do
1219 it 'ステータスコード200 OKを返す' do
1221 response.should be_success
1223 it '@auに新規データを用意している' do
1225 assigns(:au).should be_a_new(Author)
1227 it '作家モデルにデフォルト値補充を依頼している' do
1228 Author.any_instance.should_receive(:supply_default).exactly(1)
1232 it 'newテンプレートを描画する' do
1234 response.should render_template("new")
1238 it 'new.jsテンプレートを描画する' do
1239 get :new, :format => :js
1240 response.should render_template("new")
1245 get :new, :format => :json
1246 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1248 it '作家モデルにjson単体出力オプションを問い合わせている' do
1249 Author.should_receive(:show_json_opt).exactly(1)
1250 get :new, :format => :json
1254 context 'ユーザ権限がないとき' do
1259 it 'ステータスコード302 Foundを返す' do
1261 response.status.should eq 302
1263 it 'サインインページへ遷移する' do
1265 response.body.should redirect_to '/users/sign_in'
1269 it 'ステータスコード401 Unauthorizedを返す' do
1270 get :new, :format => :js
1271 response.status.should eq 401
1273 it '応答メッセージにUnauthorizedを返す' do
1274 get :new, :format => :js
1275 response.message.should match(/Unauthorized/)
1279 it 'ステータスコード401 Unauthorizedを返す' do
1280 get :new, :format => :json
1281 response.status.should eq 401
1283 it '応答メッセージにUnauthorizedを返す' do
1284 get :new, :format => :json
1285 response.message.should match(/Unauthorized/)
1289 context 'ユーザ権限はないが管理者権限があるとき' do
1295 it 'ステータスコード302 Foundを返す' do
1297 response.status.should eq 302
1299 it 'サインインページへ遷移する' do
1301 response.body.should redirect_to '/users/sign_in'
1305 context 'ユーザだが作家登録していないとき' do
1309 it 'ステータスコード200 OKを返す' do
1311 response.should be_success
1316 describe '新規作成に於いて' do
1318 @new_user = FactoryGirl.create( :user_yas)
1320 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1322 context '事前チェックしておく' do
1323 it '作家モデルにデフォルト値補充を依頼している' do
1324 Author.any_instance.should_receive(:supply_default).exactly(1)
1325 post :create, :author => @attr
1327 it '作家モデルにカラム値復元を依頼している' do
1328 Author.any_instance.should_receive(:attributes=).exactly(1)
1329 post :create, :author => @attr
1331 it '作家モデルに上書き補充を依頼している' do
1332 Author.any_instance.should_receive(:overwrite).exactly(1)
1333 post :create, :author => @attr
1336 Author.any_instance.should_receive(:save).exactly(1)
1337 post :create, :author => @attr
1340 context 'つつがなく終わるとき' do
1341 it "@auに作成された作家を保持していて、それがDBにある" do
1342 post :create, :author => @attr
1343 assigns(:au).should be_a(Author)
1344 assigns(:au).should be_persisted
1347 it 'ステータスコード302 Foundを返す' do
1348 Author.any_instance.stub(:save).and_return(true)
1349 post :create, :author => @attr
1350 response.status.should eq 302
1353 # Author.any_instance.stub(:save).and_return(true)
1354 post :create, :author => @attr
1355 response.should redirect_to(root_path)
1359 it 'ステータスコード200 OKを返す' do
1360 # Author.any_instance.stub(:save).and_return(true)
1361 post :create, :author => @attr, :format => :json
1362 response.should be_success
1364 it '作成された作家をjsonデータで返す' do
1365 post :create, :author => @attr, :format => :json
1366 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1368 it '作家モデルにjson単体出力オプションを問い合わせている' do
1369 Author.should_receive(:show_json_opt).exactly(1)
1370 post :create, :author => @attr, :format => :json
1372 it 'データがアレになっている' do
1373 post :create, :author => @attr, :format => :json
1374 json = JSON.parse response.body
1375 json["name"].should match(/ken/)
1379 context 'ユーザ権限がないとき' do
1384 it 'ステータスコード302 Foundを返す' do
1385 post :create, :author => @attr
1386 response.status.should eq 302
1388 it 'サインインページへ遷移する' do
1389 post :create, :author => @attr
1390 response.body.should redirect_to '/users/sign_in'
1394 it 'ステータスコード401 Unauthorizedを返す' do
1395 post :create, :author => @attr, :format => :json
1396 response.status.should eq 401
1398 it '応答メッセージにUnauthorizedを返す' do
1399 post :create, :author => @attr, :format => :json
1400 response.message.should match(/Unauthorized/)
1404 context 'ユーザ権限はないが管理者権限があるとき' do
1410 it 'ステータスコード302 Foundを返す' do
1411 post :create, :author => @attr
1412 response.status.should eq 302
1414 it 'サインインページへ遷移する' do
1415 post :create, :author => @attr
1416 response.body.should redirect_to '/users/sign_in'
1420 context '検証、保存に失敗した' do
1422 Author.any_instance.stub(:save).and_return(false)
1424 it "未保存の作家を保持している" do
1425 post :create, :author => @attr
1426 assigns(:au).should be_a_new(Author)
1429 it 'ステータスコード200 OKを返す' do
1430 post :create, :author => @attr
1431 response.status.should eq 200
1434 post :create, :author => @attr
1435 response.should render_template("new")
1439 it 'ステータスコード422 unprocessable_entity を返す' do
1440 post :create, :author => @attr, :format => :json
1441 response.status.should eq 422
1443 it '応答メッセージUnprocessable Entityを返す' do
1444 post :create, :author => @attr, :format => :json
1445 response.message.should match(/Unprocessable/)
1451 describe '編集フォーム表示に於いて' do
1454 Author.stub(:edit).and_return(@author)
1456 context 'つつがなく終わるとき' do
1457 it 'ステータスコード200 OKを返す' do
1458 get :edit, :id => @author.id
1459 response.should be_success
1461 it '作家モデルに編集取得を問い合わせている' do
1462 Author.should_receive(:edit).exactly(1)
1463 get :edit, :id => @author.id
1465 #@authorだとログイン中のアカウントと干渉してしまう。
1466 it '@auにデータを用意している' do
1467 get :edit, :id => @author.id
1468 assigns(:au).should eq @author
1471 it 'editテンプレートを描画する' do
1472 get :edit, :id => @author.id
1473 response.should render_template("edit")
1477 it 'edit.jsテンプレートを描画する' do
1478 get :edit, :id => @author.id, :format => :js
1479 response.should render_template("edit")
1483 context 'ユーザ権限がないとき' do
1488 it 'ステータスコード302 Foundを返す' do
1489 get :edit, :id => @author.id
1490 response.status.should eq 302
1492 it 'サインインページへ遷移する' do
1493 get :edit, :id => @author.id
1494 response.body.should redirect_to '/users/sign_in'
1498 it 'ステータスコード401 Unauthorizedを返す' do
1499 get :edit, :id => @author.id, :format => :js
1500 response.status.should eq 401
1502 it '応答メッセージにUnauthorizedを返す' do
1503 get :edit, :id => @author.id, :format => :js
1504 response.message.should match(/Unauthorized/)
1508 context 'ユーザ権限はないが管理者権限があるとき' do
1514 it 'ステータスコード302 Foundを返す' do
1515 get :edit, :id => @author.id
1516 response.status.should eq 302
1518 it 'サインインページへ遷移する' do
1519 get :edit, :id => @author.id
1520 response.body.should redirect_to '/users/sign_in'
1524 context 'ユーザだが作家登録していないとき' do
1526 @other_user = FactoryGirl.create( :user_yas)
1527 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1531 it 'ステータスコード302 Foundを返す' do
1532 get :edit, :id => @other_author.id
1533 response.status.should eq 302
1535 it '作家登録ページへ遷移する' do
1536 get :edit, :id => @other_author.id
1537 response.body.should redirect_to new_author_path
1543 describe '更新に於いて' do
1545 @attr = @author.attributes
1546 @attr['name'] = 'ryu'
1549 context '事前チェックしておく' do
1550 it '作家モデルに編集取得を問い合わせている' do
1551 Author.stub(:edit).with(any_args()).and_return @author
1552 Author.should_receive(:edit).exactly(1)
1553 put :update, :id => @author.id, :author => @attr
1555 it 'モデルにpostデータ転送を依頼する' do
1556 Author.any_instance.stub(:attributes=).with(any_args)
1557 Author.any_instance.should_receive(:attributes=).exactly(1)
1558 put :update, :id => @author.id, :author => @attr
1560 it 'モデルに上書き補充を依頼する' do
1561 Author.any_instance.stub(:overwrite).with(any_args)
1562 Author.any_instance.should_receive(:overwrite).exactly(1)
1563 put :update, :id => @author.id, :author => @attr
1566 Author.any_instance.stub(:save).with(any_args).and_return true
1567 Author.any_instance.should_receive(:save).exactly(1)
1568 put :update, :id => @author.id, :author => @attr
1570 it '@auにアレを取得している' do
1571 put :update, :id => @author.id, :author => @attr
1572 assigns(:au).should eq @author
1575 context 'つつがなく終わるとき' do
1577 put :update, :id => @author.id, :author => @attr
1578 Author.find(@author.id).name.should eq 'ryu'
1581 it 'ステータスコード302 Foundを返す' do
1582 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1583 put :update, :id => @author.id, :author => @attr
1584 response.status.should eq 302
1587 put :update, :id => @author.id, :author => @attr
1588 response.should redirect_to('/home/configure')
1592 it 'ステータスコード200 OKを返す' do
1593 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1594 put :update, :id => @author.id, :author => @attr, :format => :json
1595 response.should be_success
1597 it 'ページ本体は特に返さない' do
1598 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1599 put :update, :id => @author.id, :author => @attr, :format => :json
1600 response.body.should match /./
1604 context 'ユーザ権限がないとき' do
1609 it 'ステータスコード302 Foundを返す' do
1610 put :update, :id => @author.id, :author => @attr
1611 response.status.should eq 302
1613 it 'サインインページへ遷移する' do
1614 put :update, :id => @author.id, :author => @attr
1615 response.body.should redirect_to '/users/sign_in'
1619 it '応答メッセージにUnauthorizedを返す' do
1620 put :update, :id => @author.id, :author => @attr, :format => :json
1621 response.message.should match(/Unauthorized/)
1625 context 'ユーザ権限はないが管理者権限があるとき' do
1631 it 'ステータスコード302 Foundを返す' do
1632 put :update, :id => @author.id, :author => @attr
1633 response.status.should eq 302
1635 it 'サインインページへ遷移する' do
1636 put :update, :id => @author.id, :author => @attr
1637 response.body.should redirect_to '/users/sign_in'
1641 context 'ユーザだが作家登録していないとき' do
1643 @other_user = FactoryGirl.create( :user_yas)
1644 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1648 it 'ステータスコード302 Foundを返す' do
1649 get :update, :id => @other_author.id
1650 response.status.should eq 302
1652 it '作家登録ページへ遷移する' do
1653 get :update, :id => @other_author.id
1654 response.body.should redirect_to new_author_path
1658 context '検証、保存に失敗したとき' do
1660 Author.any_instance.stub(:save).and_return(false)
1663 it 'ステータスコード200 Okを返す' do
1664 put :update, :id => @author.id, :author => @attr
1665 response.status.should eq 200
1668 put :update, :id => @author.id, :author => @attr
1669 response.should render_template("edit")
1673 it 'ステータスコード422 unprocessable_entity を返す' do
1674 Author.any_instance.stub(:save).and_return(false)
1675 put :update, :id => @author.id, :author => @attr, :format => :json
1676 response.status.should eq 422
1678 it '応答メッセージUnprocessable Entityを返す' do
1679 put :update, :id => @author.id, :author => @attr, :format => :json
1680 response.message.should match(/Unprocessable/)
1687 describe '一覧表示に於いて' do
1689 Author.stub(:list).and_return([@author, @author, @author])
1692 context 'つつがなく終わるとき' do
1693 it 'ステータスコード200 OKを返す' do
1695 response.should be_success
1698 it 'indexテンプレートを描画する' do
1700 response.should render_template("index")
1705 get :index, :format => :json
1706 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1710 context 'ユーザ権限がないとき' do
1714 it 'ステータスコード200 OKを返す' do
1716 response.should be_success
1719 it 'indexテンプレートを描画する' do
1721 response.should render_template("index")
1726 get :index, :format => :json
1727 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1733 describe '閲覧に於いて' do
1735 Author.stub(:show).and_return(@author)
1738 context 'つつがなく終わるとき' do
1739 it 'ステータスコード200 OKを返す' do
1740 get :show, :id => @author.id
1741 response.should be_success
1744 it 'showテンプレートを描画する' do
1745 get :show, :id => @author.id
1746 response.should render_template("show")
1751 get :show, :id => @author.id, :format => :json
1752 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1756 context 'ユーザ権限がないとき' do
1760 it 'ステータスコード200 OKを返す' do
1761 get :show, :id => @author.id
1762 response.should be_success
1765 it 'showテンプレートを描画する' do
1766 get :show, :id => @author.id
1767 response.should render_template("show")
1772 get :show, :id => @author.id, :format => :json
1773 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1779 describe '対象作家のコミック一覧表示に於いて' do
1781 @other_user = FactoryGirl.create( :user_yas)
1782 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1783 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1784 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
1785 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
1788 context 'つつがなく終わるとき' do
1789 it 'ステータスコード200 OKを返す' do
1790 get :scrolls, :id => @other_author.id
1791 response.should be_success
1794 it 'scrollテンプレートを描画する' do
1795 get :scrolls, :id => @other_author.id
1796 response.should render_template("scroll")
1801 get :scrolls, :id => @other_author.id, :format => :json
1802 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1806 context 'ユーザ権限がないとき' do
1810 it 'ステータスコード200 OKを返す' do
1811 get :scrolls, :id => @other_author.id
1812 response.should be_success
1815 it 'scrollsテンプレートを描画する' do
1816 get :scrolls, :id => @other_author.id
1817 response.should render_template("scrolls")
1822 get :scrolls, :id => @other_author.id, :format => :json
1823 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1829 describe '対象作家のストーリー一覧表示に於いて' do
1831 @other_user = FactoryGirl.create( :user_yas)
1832 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1833 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1834 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
1835 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1836 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id
1837 ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
1840 context 'つつがなく終わるとき' do
1841 it 'ステータスコード200 OKを返す' do
1842 get :scroll_panels, :id => @other_author.id
1843 response.should be_success
1846 it 'scroll_panelsテンプレートを描画する' do
1847 get :scroll_panels, :id => @other_author.id
1848 response.should render_template("scroll_panels")
1853 get :scroll_panels, :id => @other_author.id, :format => :json
1854 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1858 context 'ユーザ権限がないとき' do
1862 it 'ステータスコード200 OKを返す' do
1863 get :scroll_panels, :id => @other_author.id
1864 response.should be_success
1867 it 'scroll_panelsテンプレートを描画する' do
1868 get :scroll_panels, :id => @other_author.id
1869 response.should render_template("scroll_panels")
1874 get :scroll_panels, :id => @other_author.id, :format => :json
1875 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1881 describe '対象作家のコマ一覧表示に於いて' do
1883 @other_user = FactoryGirl.create( :user_yas)
1884 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1885 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1886 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1887 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
1890 context 'つつがなく終わるとき' do
1891 it 'ステータスコード200 OKを返す' do
1892 get :panels, :id => @other_author.id
1893 response.should be_success
1896 it 'panelsテンプレートを描画する' do
1897 get :panels, :id => @other_author.id
1898 response.should render_template("panels")
1903 get :panels, :id => @other_author.id, :format => :json
1904 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1908 context 'ユーザ権限がないとき' do
1912 it 'ステータスコード200 OKを返す' do
1913 get :panels, :id => @other_author.id
1914 response.should be_success
1917 it 'panelsテンプレートを描画する' do
1918 get :panels, :id => @other_author.id
1919 response.should render_template("panels")
1924 get :panels, :id => @other_author.id, :format => :json
1925 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1931 describe '対象作家のコマ絵一覧表示に於いて' do
1933 @other_user = FactoryGirl.create( :user_yas)
1934 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1935 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1936 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1937 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1938 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1939 @panel = FactoryGirl.create :panel, :author_id => @author.id
1940 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
1941 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
1944 context 'つつがなく終わるとき' do
1945 it 'ステータスコード200 OKを返す' do
1946 get :panel_pictures, :id => @other_author.id
1947 response.should be_success
1950 it 'panel_picturesテンプレートを描画する' do
1951 get :panel_pictures, :id => @other_author.id
1952 response.should render_template("panel_pictures")
1957 get :panel_pictures, :id => @other_author.id, :format => :json
1958 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1962 context 'ユーザ権限がないとき' do
1966 it 'ステータスコード200 OKを返す' do
1967 get :panel_pictures, :id => @other_author.id
1968 response.should be_success
1971 it 'panel_picturesテンプレートを描画する' do
1972 get :panel_pictures, :id => @other_author.id
1973 response.should render_template("panel_pictures")
1978 get :panel_pictures, :id => @other_author.id, :format => :json
1979 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1985 describe '対象作家の絵地一覧表示に於いて' do
1987 @other_user = FactoryGirl.create( :user_yas)
1988 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1989 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1990 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1991 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1992 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1993 @panel = FactoryGirl.create :panel, :author_id => @author.id
1994 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1995 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1998 context 'つつがなく終わるとき' do
1999 it 'ステータスコード200 OKを返す' do
2000 get :ground_pictures, :id => @other_author.id
2001 response.should be_success
2004 it 'ground_picturesテンプレートを描画する' do
2005 get :ground_pictures, :id => @other_author.id
2006 response.should render_template("ground_pictures")
2011 get :ground_pictures, :id => @other_author.id, :format => :json
2012 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2016 context 'ユーザ権限がないとき' do
2021 it 'ground_picturesテンプレートを描画する' do
2022 get :ground_pictures, :id => @other_author.id
2023 response.should render_template("ground_pictures")
2028 get :ground_pictures, :id => @other_author.id, :format => :json
2029 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2035 describe '対象作家の色地一覧表示に於いて' do
2037 @other_user = FactoryGirl.create( :user_yas)
2038 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2039 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2040 @gc = FactoryGirl.create :ground_color
2041 @panel = FactoryGirl.create :panel, :author_id => @author.id
2042 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
2045 context 'つつがなく終わるとき' do
2046 it 'ステータスコード200 OKを返す' do
2047 get :ground_colors, :id => @other_author.id
2048 response.should be_success
2051 it 'ground_colorsテンプレートを描画する' do
2052 get :ground_colors, :id => @other_author.id
2053 response.should render_template("ground_colors")
2058 get :ground_colors, :id => @other_author.id, :format => :json
2059 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2063 context 'ユーザ権限がないとき' do
2068 it 'ground_colorsテンプレートを描画する' do
2069 get :ground_colors, :id => @other_author.id
2070 response.should render_template("ground_colors")
2075 get :ground_colors, :id => @other_author.id, :format => :json
2076 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2082 describe '作家数取得に於いて' do
2084 Author.should_receive(:visible_count).and_return(3)
2087 context 'つつがなく終わるとき' do
2088 it 'ステータスコード200 OKを返す' do
2089 get :count, :format => :json
2090 response.should be_success
2094 get :count, :format => :json
2095 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2101 describe '新規作成フォーム表示に於いて' do
2103 @new_user = FactoryGirl.create( :user_yas)
2106 context 'つつがなく終わるとき' do
2107 it 'ステータスコード200 OKを返す' do
2109 response.should be_success
2112 it 'newテンプレートを描画する' do
2114 response.should render_template("new")
2118 it 'new.jsテンプレートを描画する' do
2119 get :new, :format => :js
2120 response.should render_template("new")
2125 get :new, :format => :json
2126 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2130 context 'ユーザ権限がないとき' do
2135 it 'ステータスコード302 Foundを返す' do
2137 response.status.should eq 302
2139 it 'サインインページへ遷移する' do
2141 response.body.should redirect_to '/users/sign_in'
2145 it 'ステータスコード401 Unauthorizedを返す' do
2146 get :new, :format => :js
2147 response.status.should eq 401
2149 it '応答メッセージにUnauthorizedを返す' do
2150 get :new, :format => :js
2151 response.message.should match(/Unauthorized/)
2155 it 'ステータスコード401 Unauthorizedを返す' do
2156 get :new, :format => :json
2157 response.status.should eq 401
2159 it '応答メッセージにUnauthorizedを返す' do
2160 get :new, :format => :json
2161 response.message.should match(/Unauthorized/)
2167 describe '新規作成に於いて' do
2169 @new_user = FactoryGirl.create( :user_yas)
2171 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
2173 context 'つつがなく終わるとき' do
2175 it 'ステータスコード302 Foundを返す' do
2176 Author.any_instance.stub(:save).and_return(true)
2177 post :create, :author => @attr
2178 response.status.should eq 302
2181 # Author.any_instance.stub(:save).and_return(true)
2182 post :create, :author => @attr
2183 response.should redirect_to(root_path)
2187 it 'ステータスコード200 OKを返す' do
2188 # Author.any_instance.stub(:save).and_return(true)
2189 post :create, :author => @attr, :format => :json
2190 response.should be_success
2194 context 'ユーザ権限がないとき' do
2199 it 'ステータスコード302 Foundを返す' do
2200 post :create, :author => @attr
2201 response.status.should eq 302
2203 it 'サインインページへ遷移する' do
2204 post :create, :author => @attr
2205 response.body.should redirect_to '/users/sign_in'
2209 it 'ステータスコード401 Unauthorizedを返す' do
2210 post :create, :author => @attr, :format => :json
2211 response.status.should eq 401
2213 it '応答メッセージにUnauthorizedを返す' do
2214 post :create, :author => @attr, :format => :json
2215 response.message.should match(/Unauthorized/)
2221 describe '編集フォーム表示に於いて' do
2224 Author.stub(:edit).and_return(@author)
2226 context 'つつがなく終わるとき' do
2227 it 'ステータスコード200 OKを返す' do
2228 get :edit, :id => @author.id
2229 response.should be_success
2232 it 'editテンプレートを描画する' do
2233 get :edit, :id => @author.id
2234 response.should render_template("edit")
2238 it 'edit.jsテンプレートを描画する' do
2239 get :edit, :id => @author.id, :format => :js
2240 response.should render_template("edit")
2244 context 'ユーザ権限がないとき' do
2249 it 'ステータスコード302 Foundを返す' do
2250 get :edit, :id => @author.id
2251 response.status.should eq 302
2253 it 'サインインページへ遷移する' do
2254 get :edit, :id => @author.id
2255 response.body.should redirect_to '/users/sign_in'
2259 it 'ステータスコード401 Unauthorizedを返す' do
2260 get :edit, :id => @author.id, :format => :js
2261 response.status.should eq 401
2263 it '応答メッセージにUnauthorizedを返す' do
2264 get :edit, :id => @author.id, :format => :js
2265 response.message.should match(/Unauthorized/)
2271 describe '更新に於いて' do
2273 @attr = @author.attributes
2274 @attr['name'] = 'ryu'
2277 context 'つつがなく終わるとき' do
2279 put :update, :id => @author.id, :author => @attr
2280 Author.find(@author.id).name.should eq 'ryu'
2283 it 'ステータスコード302 Foundを返す' do
2284 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2285 put :update, :id => @author.id, :author => @attr
2286 response.status.should eq 302
2289 put :update, :id => @author.id, :author => @attr
2290 response.should redirect_to('/home/configure')
2294 it 'ステータスコード200 OKを返す' do
2295 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2296 put :update, :id => @author.id, :author => @attr, :format => :json
2297 response.should be_success
2299 it 'ページ本体は特に返さない' do
2300 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2301 put :update, :id => @author.id, :author => @attr, :format => :json
2302 response.body.should match /./
2306 context 'ユーザ権限がないとき' do
2310 it 'ステータスコード302 Foundを返す' do
2311 put :update, :id => @author.id, :author => @attr
2312 response.status.should eq 302
2315 it 'サインインページへ遷移する' do
2316 put :update, :id => @author.id, :author => @attr
2317 response.body.should redirect_to '/users/sign_in'
2321 it '応答メッセージにUnauthorizedを返す' do
2322 put :update, :id => @author.id, :author => @attr, :format => :json
2323 response.message.should match(/Unauthorized/)