1 # -*- encoding: utf-8 -*-
5 describe AuthorsController do
7 @admin =FactoryGirl.create :admin
8 @sp = FactoryGirl.create :system_picture
9 @lg = FactoryGirl.create :license_group
10 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
11 @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'
12 @writing_format = FactoryGirl.create :writing_format
13 @user = FactoryGirl.create( :user_yas)
14 @author = FactoryGirl.create :author, :user_id => @user.id
15 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
18 if MagicNumber['run_mode'] == 1
19 describe '一覧表示に於いて' do
21 Author.stub(:list).and_return([@author, @author, @author])
25 it '与えられたpageがセットされている' do
26 get :index, :page => 5
27 assigns(:page).should eq 5
29 it '省略されると@pageに1値が入る' do
31 assigns(:page).should eq 1
33 it '与えられたpage_sizeがセットされている' do
34 get :index, :page_size => 15
35 assigns(:page_size).should eq 15
37 it '省略されると@page_sizeにデフォルト値が入る' do
39 assigns(:page_size).should eq Author.default_page_size
41 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
42 get :index, :page_size => 1500
43 assigns(:page_size).should eq Author.max_page_size
45 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
46 get :index, :page_size => 0
47 assigns(:page_size).should eq Author.default_page_size
50 context 'つつがなく終わるとき' do
51 it 'ステータスコード200 OKを返す' do
53 response.should be_success
55 it '作家モデルに一覧を問い合わせている' do
56 Author.should_receive(:list).exactly(1)
59 it '@authorsにリストを取得している' do
61 assigns(:authors).should have_at_least(3).items
64 it '@paginateにページ制御を取得している' do
66 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
68 it 'indexテンプレートを描画する' do
70 response.should render_template("index")
75 get :index, :format => :json
76 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
78 it '作家モデルにjson一覧出力オプションを問い合わせている' do
79 Author.should_receive(:list_json_opt).exactly(1)
80 get :index, :format => :json
82 it 'データがリスト構造になっている' do
83 get :index, :format => :json
84 json = JSON.parse response.body
85 json.should have_at_least(3).items
87 it 'リストの先頭くらいは作家っぽいものであって欲しい' do
88 get :index, :format => :json
89 json = JSON.parse response.body
90 json.first.has_key?("name").should be_true
91 json.first.has_key?("user_id").should be_true
95 context 'ユーザ権限がないとき' do
100 it 'ステータスコード302 Foundを返す' do
102 response.status.should eq 302
104 it 'サインインページへ遷移する' do
106 response.should redirect_to '/users/sign_in'
110 it 'ステータスコード401 Unauthorizedを返す' do
111 get :index, :format => :json
112 response.status.should eq 401
114 it '応答メッセージにUnauthorizedを返す' do
115 get :index, :format => :json
116 response.message.should match(/Unauthorized/)
120 context 'ユーザ権限はないが管理者権限があるとき' do
125 it 'ステータスコード200 OKを返す' do
127 response.should be_success
130 context 'ユーザだが作家登録していないとき' do
134 it 'ステータスコード200 OKを返す' do
136 response.should be_success
143 Author.stub(:show).and_return(@author)
146 context 'つつがなく終わるとき' do
147 it 'ステータスコード200 OKを返す' do
148 get :show, :id => @author.id
149 response.should be_success
151 it '作家モデルに単体取得を問い合わせている' do
152 Author.should_receive(:show).exactly(1)
155 #@authorだとログイン中のアカウントと干渉してしまう。
156 it '@auにアレを取得している' do
157 get :show, :id => @author.id
158 assigns(:au).should eq(@author)
161 it 'showテンプレートを描画する' do
162 get :show, :id => @author.id
163 response.should render_template("show")
168 get :show, :id => @author.id, :format => :json
169 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
171 it '作家モデルにjson単体出力オプションを問い合わせている' do
172 Author.should_receive(:show_json_opt).exactly(1)
173 get :show, :id => @author.id, :format => :json
176 get :show, :id => @author.id, :format => :json
177 json = JSON.parse response.body
178 json["name"].should match(/test/)
179 json["user_id"].should eq @author.user_id
183 context 'ユーザ権限がないとき' do
188 it 'ステータスコード302 Foundを返す' do
189 get :show, :id => @author.id
190 response.status.should eq 302
192 it 'サインインページへ遷移する' do
193 get :show, :id => @author.id
194 response.body.should redirect_to '/users/sign_in'
198 it 'ステータスコード401 Unauthorizedを返す' do
199 get :show, :id => @author.id, :format => :json
200 response.status.should eq 401
202 it '応答メッセージにUnauthorizedを返す' do
203 get :show, :id => @author.id, :format => :json
204 response.message.should match(/Unauthorized/)
208 context 'ユーザ権限はないが管理者権限があるとき' do
213 it 'ステータスコード200 OKを返す' do
214 get :show, :id => @author.id
215 response.should be_success
218 context 'ユーザだが作家登録していないとき' do
222 it 'ステータスコード200 OKを返す' do
223 get :show, :id => @author.id
224 response.should be_success
228 context '対象作家がないとき' do
230 it '例外404 not_foundを返す' do
233 }.should raise_error(ActiveRecord::RecordNotFound)
237 it '例外404 not_foundを返す' do
239 get :show, :id => 0, :format => :json
240 }.should raise_error(ActiveRecord::RecordNotFound)
247 describe '対象作家のコミック一覧表示に於いて' do
249 @other_user = FactoryGirl.create( :user_yas)
250 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
251 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
252 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
253 Author.stub(:show).and_return(@other_author)
254 Scroll.stub(:himlist).and_return([@scroll, @scroll, @scroll])
257 context 'パラメータpageについて' do
259 get :scrolls, :id => @other_author.id, :page => 5
260 assigns(:page).should eq 5
262 it '省略されると@pageに1値が入る' do
263 get :scrolls, :id => @other_author.id
264 assigns(:page).should eq 1
266 it '与えられたpage_sizeがセットされている' do
267 get :scrolls, :id => @other_author.id, :page_size => 15
268 assigns(:page_size).should eq 15
270 it '省略されると@page_sizeにデフォルト値が入る' do
271 get :scrolls, :id => @other_author.id
272 assigns(:page_size).should eq Author.default_scroll_page_size
274 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
275 get :scrolls, :id => @other_author.id, :page_size => 1500
276 assigns(:page_size).should eq Author.scroll_max_page_size
278 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
279 get :scrolls, :id => @other_author.id, :page_size => 0
280 assigns(:page_size).should eq Author.default_scroll_page_size
283 context 'つつがなく終わるとき' do
284 it 'ステータスコード200 OKを返す' do
285 get :scrolls, :id => @other_author.id
286 response.should be_success
288 it '作家モデルに単体取得を問い合わせている' do
289 Author.should_receive(:show).exactly(1)
290 get :scrolls, :id => @other_author.id
292 it 'コミックモデルに一覧を問い合わせている' do
293 Scroll.should_receive(:himlist).exactly(1)
294 get :scrolls, :id => @other_author.id
296 it '@scrollsにリストを取得している' do
297 get :scrolls, :id => @other_author.id
298 assigns(:scrolls).should have_at_least(3).items
301 it '@paginateにページ制御を取得している' do
302 get :scrolls, :id => @other_author.id
303 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
305 it 'scrollsテンプレートを描画する' do
306 get :scrolls, :id => @other_author.id
307 response.should render_template("scrolls")
312 get :scrolls, :id => @other_author.id, :format => :json
313 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
315 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
316 Scroll.should_receive(:list_json_opt).exactly(1)
317 get :scrolls, :id => @other_author.id, :format => :json
319 it 'データがリスト構造になっている' do
320 get :scrolls, :id => @other_author.id, :format => :json
321 json = JSON.parse response.body
322 json.should have_at_least(3).items
324 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
325 get :scrolls, :id => @other_author.id, :format => :json
326 json = JSON.parse response.body
327 json.first.has_key?("title").should be_true
328 json.first.has_key?("visible").should be_true
332 context 'ユーザ権限がないとき' do
337 it 'ステータスコード302 Foundを返す' do
338 get :scrolls, :id => @other_author.id
339 response.status.should eq 302
341 it 'サインインページへ遷移する' do
342 get :scrolls, :id => @other_author.id
343 response.should redirect_to '/users/sign_in'
347 it 'ステータスコード401 Unauthorizedを返す' do
348 get :scrolls, :id => @other_author.id, :format => :json
349 response.status.should eq 401
351 it '応答メッセージにUnauthorizedを返す' do
352 get :scrolls, :id => @other_author.id, :format => :json
353 response.message.should match(/Unauthorized/)
357 context 'ユーザ権限はないが管理者権限があるとき' do
362 it 'ステータスコード200 OKを返す' do
363 get :scrolls, :id => @other_author.id
364 response.should be_success
367 context 'ユーザだが作家登録していないとき' do
371 it 'ステータスコード200 OKを返す' do
372 get :scrolls, :id => @other_author.id
373 response.should be_success
378 describe '対象作家のストーリー一覧表示に於いて' do
380 @other_user = FactoryGirl.create( :user_yas)
381 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
382 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
383 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
384 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
385 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_user.author.id
386 Author.stub(:show).and_return(@other_author)
387 ScrollPanel.stub(:himlist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
390 context 'パラメータpageについて' do
392 get :scroll_panels, :id => @other_author.id, :page => 5
393 assigns(:page).should eq 5
395 it '省略されると@pageに1値が入る' do
396 get :scroll_panels, :id => @other_author.id
397 assigns(:page).should eq 1
399 it '与えられたpage_sizeがセットされている' do
400 get :scroll_panels, :id => @other_author.id, :page_size => 15
401 assigns(:page_size).should eq 15
403 it '省略されると@page_sizeにデフォルト値が入る' do
404 get :scroll_panels, :id => @other_author.id
405 assigns(:page_size).should eq Author.default_scroll_panel_page_size
407 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
408 get :scroll_panels, :id => @other_author.id, :page_size => 1500
409 assigns(:page_size).should eq Author.scroll_panel_max_page_size
411 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
412 get :scroll_panels, :id => @other_author.id, :page_size => 0
413 assigns(:page_size).should eq Author.default_scroll_panel_page_size
416 context 'つつがなく終わるとき' do
417 it 'ステータスコード200 OKを返す' do
418 get :scroll_panels, :id => @other_author.id
419 response.should be_success
421 it '作家モデルに単体取得を問い合わせている' do
422 Author.should_receive(:show).exactly(1)
423 get :scroll_panels, :id => @other_author.id
425 it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
426 ScrollPanel.should_receive(:himlist).exactly(1)
427 get :scroll_panels, :id => @other_author.id
429 it '@scroll_panelsにリストを取得している' do
430 get :scroll_panels, :id => @other_author.id
431 assigns(:scroll_panels).should have_at_least(3).items
434 it '@paginateにページ制御を取得している' do
435 get :scroll_panels, :id => @other_author.id
436 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
438 it 'scroll_panelsテンプレートを描画する' do
439 get :scroll_panels, :id => @other_author.id
440 response.should render_template("scroll_panels")
445 get :scroll_panels, :id => @other_author.id, :format => :json
446 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
448 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
449 ScrollPanel.should_receive(:list_json_opt).exactly(1)
450 get :scroll_panels, :id => @other_author.id, :format => :json
452 it 'データがリスト構造になっている' do
453 get :scroll_panels, :id => @other_author.id, :format => :json
454 json = JSON.parse response.body
455 json.should have_at_least(3).items
457 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
458 get :scroll_panels, :id => @other_author.id, :format => :json
459 json = JSON.parse response.body
460 json.first.has_key?("panel_id").should be_true
461 json.first.has_key?("scroll_id").should be_true
462 json.first.has_key?("t").should be_true
466 context 'ユーザ権限がないとき' do
471 it 'ステータスコード302 Foundを返す' do
472 get :scroll_panels, :id => @other_author.id
473 response.status.should eq 302
475 it 'サインインページへ遷移する' do
476 get :scroll_panels, :id => @other_author.id
477 response.should redirect_to '/users/sign_in'
481 it 'ステータスコード401 Unauthorizedを返す' do
482 get :scroll_panels, :id => @other_author.id, :format => :json
483 response.status.should eq 401
485 it '応答メッセージにUnauthorizedを返す' do
486 get :scroll_panels, :id => @other_author.id, :format => :json
487 response.message.should match(/Unauthorized/)
491 context 'ユーザ権限はないが管理者権限があるとき' do
496 it 'ステータスコード200 OKを返す' do
497 get :scroll_panels, :id => @other_author.id
498 response.should be_success
501 context 'ユーザだが作家登録していないとき' do
505 it 'ステータスコード200 OKを返す' do
506 get :scroll_panels, :id => @other_author.id
507 response.should be_success
512 describe '対象作家のコマ一覧表示に於いて' do
514 @other_user = FactoryGirl.create( :user_yas)
515 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
516 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
517 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
518 Author.stub(:show).and_return(@other_author)
519 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
522 context 'パラメータpageについて' do
524 get :panels, :id => @other_author.id, :page => 5
525 assigns(:page).should eq 5
527 it '省略されると@pageに1値が入る' do
528 get :panels, :id => @other_author.id
529 assigns(:page).should eq 1
531 it '与えられたpage_sizeがセットされている' do
532 get :panels, :id => @other_author.id, :page_size => 15
533 assigns(:page_size).should eq 15
535 it '省略されると@page_sizeにデフォルト値が入る' do
536 get :panels, :id => @other_author.id
537 assigns(:page_size).should eq Author.default_panel_page_size
539 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
540 get :panels, :id => @other_author.id, :page_size => 1500
541 assigns(:page_size).should eq Author.panel_max_page_size
543 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
544 get :panels, :id => @other_author.id, :page_size => 0
545 assigns(:page_size).should eq Author.default_panel_page_size
548 context 'つつがなく終わるとき' do
549 it 'ステータスコード200 OKを返す' do
550 get :panels, :id => @other_author.id
551 response.should be_success
553 it '作家モデルに単体取得を問い合わせている' do
554 Author.should_receive(:show).exactly(1)
555 get :panels, :id => @other_author.id
557 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
558 Panel.should_receive(:himlist).exactly(1)
559 get :panels, :id => @other_author.id
561 it '@panelsにリストを取得している' do
562 get :panels, :id => @other_author.id
563 assigns(:panels).should have_at_least(3).items
566 it '@paginateにページ制御を取得している' do
567 get :panels, :id => @other_author.id
568 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
570 it 'panelsテンプレートを描画する' do
571 get :panels, :id => @other_author.id
572 response.should render_template("panels")
577 get :panels, :id => @other_author.id, :format => :json
578 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
580 it 'コマモデルにコマリストのjson出力を問い合わせている' do
581 Panel.should_receive(:list_as_json_text).exactly(1)
582 get :panels, :id => @other_author.id, :format => :json
584 it 'データがリスト構造になっている' do
585 get :panels, :id => @other_author.id, :format => :json
586 json = JSON.parse response.body
587 json.should have_at_least(3).items
589 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
590 get :panels, :id => @other_author.id, :format => :json
591 json = JSON.parse response.body
592 json.first.has_key?("z").should be_true
596 context 'ユーザ権限がないとき' do
601 it 'ステータスコード302 Foundを返す' do
602 get :panels, :id => @other_author.id
603 response.status.should eq 302
605 it 'サインインページへ遷移する' do
606 get :panels, :id => @other_author.id
607 response.should redirect_to '/users/sign_in'
611 it 'ステータスコード401 Unauthorizedを返す' do
612 get :panels, :id => @other_author.id, :format => :json
613 response.status.should eq 401
615 it '応答メッセージにUnauthorizedを返す' do
616 get :panels, :id => @other_author.id, :format => :json
617 response.message.should match(/Unauthorized/)
621 context 'ユーザ権限はないが管理者権限があるとき' do
626 it 'ステータスコード200 OKを返す' do
627 get :panels, :id => @other_author.id
628 response.should be_success
631 context 'ユーザだが作家登録していないとき' do
635 it 'ステータスコード200 OKを返す' do
636 get :panels, :id => @other_author.id
637 response.should be_success
642 describe '対象作家のコマ絵一覧表示に於いて' do
644 @other_user = FactoryGirl.create( :user_yas)
645 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
646 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
647 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
648 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
649 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
650 @panel = FactoryGirl.create :panel, :author_id => @author.id
651 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
652 Author.stub(:show).and_return(@other_author)
653 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
656 context 'パラメータpageについて' do
658 get :panel_pictures, :id => @other_author.id, :page => 5
659 assigns(:page).should eq 5
661 it '省略されると@pageに1値が入る' do
662 get :panel_pictures, :id => @other_author.id
663 assigns(:page).should eq 1
665 it '与えられたpage_sizeがセットされている' do
666 get :panel_pictures, :id => @other_author.id, :page_size => 15
667 assigns(:page_size).should eq 15
669 it '省略されると@page_sizeにデフォルト値が入る' do
670 get :panel_pictures, :id => @other_author.id
671 assigns(:page_size).should eq Author.default_panel_picture_page_size
673 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
674 get :panel_pictures, :id => @other_author.id, :page_size => 1500
675 assigns(:page_size).should eq Author.panel_picture_max_page_size
677 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
678 get :panel_pictures, :id => @other_author.id, :page_size => 0
679 assigns(:page_size).should eq Author.default_panel_picture_page_size
682 context 'つつがなく終わるとき' do
683 it 'ステータスコード200 OKを返す' do
684 get :panel_pictures, :id => @other_author.id
685 response.should be_success
687 it '作家モデルに単体取得を問い合わせている' do
688 Author.should_receive(:show).exactly(1)
689 get :panel_pictures, :id => @other_author.id
691 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
692 PanelPicture.should_receive(:himlist).exactly(1)
693 get :panel_pictures, :id => @other_author.id
695 it '@panel_picturesにリストを取得している' do
696 get :panel_pictures, :id => @other_author.id
697 assigns(:panel_pictures).should have_at_least(3).items
700 it '@paginateにページ制御を取得している' do
701 get :panel_pictures, :id => @other_author.id
702 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
704 it 'panel_picturesテンプレートを描画する' do
705 get :panel_pictures, :id => @other_author.id
706 response.should render_template("panel_pictures")
711 get :panel_pictures, :id => @other_author.id, :format => :json
712 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
714 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
715 PanelPicture.should_receive(:list_json_opt).exactly(1)
716 get :panel_pictures, :id => @other_author.id, :format => :json
718 it 'データがリスト構造になっている' do
719 get :panel_pictures, :id => @other_author.id, :format => :json
720 json = JSON.parse response.body
721 json.should have_at_least(3).items
723 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
724 get :panel_pictures, :id => @other_author.id, :format => :json
725 json = JSON.parse response.body
726 json.first.has_key?("link").should be_true
727 json.first.has_key?("x").should be_true
728 json.first.has_key?("y").should be_true
732 context 'ユーザ権限がないとき' do
737 it 'ステータスコード302 Foundを返す' do
738 get :panel_pictures, :id => @other_author.id
739 response.status.should eq 302
741 it 'サインインページへ遷移する' do
742 get :panel_pictures, :id => @other_author.id
743 response.should redirect_to '/users/sign_in'
747 it 'ステータスコード401 Unauthorizedを返す' do
748 get :panel_pictures, :id => @other_author.id, :format => :json
749 response.status.should eq 401
751 it '応答メッセージにUnauthorizedを返す' do
752 get :panel_pictures, :id => @other_author.id, :format => :json
753 response.message.should match(/Unauthorized/)
757 context 'ユーザ権限はないが管理者権限があるとき' do
762 it 'ステータスコード200 OKを返す' do
763 get :panel_pictures, :id => @other_author.id
764 response.should be_success
767 context 'ユーザだが作家登録していないとき' do
771 it 'ステータスコード200 OKを返す' do
772 get :panel_pictures, :id => @other_author.id
773 response.should be_success
778 describe '対象作家のフキダシ一覧表示に於いて' do
780 @other_user = FactoryGirl.create( :user_yas)
781 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
782 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
783 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
784 @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
785 @speech = @sb.build_speech(
786 FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
788 @balloon = @sb.build_balloon(
789 FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
793 Author.stub(:show).and_return(@other_author)
794 SpeechBalloon.stub(:himlist).and_return([@sb, @sb, @sb])
797 context 'パラメータpageについて' do
799 get :speech_balloons, :id => @other_author.id, :page => 5
800 assigns(:page).should eq 5
802 it '省略されると@pageに1値が入る' do
803 get :speech_balloons, :id => @other_author.id
804 assigns(:page).should eq 1
806 it '与えられたpage_sizeがセットされている' do
807 get :speech_balloons, :id => @other_author.id, :page_size => 15
808 assigns(:page_size).should eq 15
810 it '省略されると@page_sizeにデフォルト値が入る' do
811 get :speech_balloons, :id => @other_author.id
812 assigns(:page_size).should eq Author.default_speech_balloon_page_size
814 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
815 get :speech_balloons, :id => @other_author.id, :page_size => 1500
816 assigns(:page_size).should eq Author.speech_balloon_max_page_size
818 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
819 get :speech_balloons, :id => @other_author.id, :page_size => 0
820 assigns(:page_size).should eq Author.default_speech_balloon_page_size
823 context 'つつがなく終わるとき' do
824 it 'ステータスコード200 OKを返す' do
825 get :speech_balloons, :id => @other_author.id
826 response.should be_success
828 it '作家モデルに単体取得を問い合わせている' do
829 Author.should_receive(:show).exactly(1)
830 get :speech_balloons, :id => @other_author.id
832 it 'フキダシモデルに他作家のフキダシ一覧を問い合わせている' do
833 SpeechBalloon.should_receive(:himlist).exactly(1)
834 get :speech_balloons, :id => @other_author.id
836 it '@speech_balloonsにリストを取得している' do
837 get :speech_balloons, :id => @other_author.id
838 assigns(:speech_balloons).should have_at_least(3).items
841 it '@paginateにページ制御を取得している' do
842 get :speech_balloons, :id => @other_author.id
843 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
845 it 'speech_balloonsテンプレートを描画する' do
846 get :speech_balloons, :id => @other_author.id
847 response.should render_template("speech_balloons")
852 get :speech_balloons, :id => @other_author.id, :format => :json
853 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
855 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
856 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
857 get :speech_balloons, :id => @other_author.id, :format => :json
859 it 'データがリスト構造になっている' do
860 get :speech_balloons, :id => @other_author.id, :format => :json
861 json = JSON.parse response.body
862 json.should have_at_least(3).items
864 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
865 get :speech_balloons, :id => @other_author.id, :format => :json
866 json = JSON.parse response.body
867 json.first.has_key?("speech_balloon_template_id").should be_true
868 json.first.has_key?("z").should be_true
869 json.first.has_key?("t").should be_true
873 context 'ユーザ権限がないとき' do
878 it 'ステータスコード302 Foundを返す' do
879 get :speech_balloons, :id => @other_author.id
880 response.status.should eq 302
882 it 'サインインページへ遷移する' do
883 get :speech_balloons, :id => @other_author.id
884 response.should redirect_to '/users/sign_in'
888 it 'ステータスコード401 Unauthorizedを返す' do
889 get :speech_balloons, :id => @other_author.id, :format => :json
890 response.status.should eq 401
892 it '応答メッセージにUnauthorizedを返す' do
893 get :speech_balloons, :id => @other_author.id, :format => :json
894 response.message.should match(/Unauthorized/)
898 context 'ユーザ権限はないが管理者権限があるとき' do
903 it 'ステータスコード200 OKを返す' do
904 get :speech_balloons, :id => @other_author.id
905 response.should be_success
908 context 'ユーザだが作家登録していないとき' do
912 it 'ステータスコード200 OKを返す' do
913 get :speech_balloons, :id => @other_author.id
914 response.should be_success
919 describe '対象作家の絵地一覧表示に於いて' do
921 @other_user = FactoryGirl.create( :user_yas)
922 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
923 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
924 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
925 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
926 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
927 @panel = FactoryGirl.create :panel, :author_id => @author.id
928 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
929 Author.stub(:show).and_return(@other_author)
930 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
933 context 'パラメータpageについて' do
935 get :ground_pictures, :id => @other_author.id, :page => 5
936 assigns(:page).should eq 5
938 it '省略されると@pageに1値が入る' do
939 get :ground_pictures, :id => @other_author.id
940 assigns(:page).should eq 1
942 it '与えられたpage_sizeがセットされている' do
943 get :ground_pictures, :id => @other_author.id, :page_size => 15
944 assigns(:page_size).should eq 15
946 it '省略されると@page_sizeにデフォルト値が入る' do
947 get :ground_pictures, :id => @other_author.id
948 assigns(:page_size).should eq Author.default_ground_picture_page_size
950 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
951 get :ground_pictures, :id => @other_author.id, :page_size => 1500
952 assigns(:page_size).should eq Author.ground_picture_max_page_size
954 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
955 get :ground_pictures, :id => @other_author.id, :page_size => 0
956 assigns(:page_size).should eq Author.default_ground_picture_page_size
959 context 'つつがなく終わるとき' do
960 it 'ステータスコード200 OKを返す' do
961 get :ground_pictures, :id => @other_author.id
962 response.should be_success
964 it '作家モデルに単体取得を問い合わせている' do
965 Author.should_receive(:show).exactly(1)
966 get :ground_pictures, :id => @other_author.id
968 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
969 GroundPicture.should_receive(:himlist).exactly(1)
970 get :ground_pictures, :id => @other_author.id
972 it '@ground_picturesにリストを取得している' do
973 get :ground_pictures, :id => @other_author.id
974 assigns(:ground_pictures).should have_at_least(3).items
977 it '@paginateにページ制御を取得している' do
978 get :ground_pictures, :id => @other_author.id
979 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
981 it 'ground_picturesテンプレートを描画する' do
982 get :ground_pictures, :id => @other_author.id
983 response.should render_template("ground_pictures")
988 get :ground_pictures, :id => @other_author.id, :format => :json
989 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
991 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
992 GroundPicture.should_receive(:list_json_opt).exactly(1)
993 get :ground_pictures, :id => @other_author.id, :format => :json
995 it 'データがリスト構造になっている' do
996 get :ground_pictures, :id => @other_author.id, :format => :json
997 json = JSON.parse response.body
998 json.should have_at_least(3).items
1000 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
1001 get :ground_pictures, :id => @other_author.id, :format => :json
1002 json = JSON.parse response.body
1003 json.first.has_key?("panel_id").should be_true
1004 json.first.has_key?("picture_id").should be_true
1005 json.first.has_key?("z").should be_true
1009 context 'ユーザ権限がないとき' do
1014 it 'ステータスコード302 Foundを返す' do
1015 get :ground_pictures, :id => @other_author.id
1016 response.status.should eq 302
1018 it 'サインインページへ遷移する' do
1019 get :ground_pictures, :id => @other_author.id
1020 response.should redirect_to '/users/sign_in'
1024 it 'ステータスコード401 Unauthorizedを返す' do
1025 get :ground_pictures, :id => @other_author.id, :format => :json
1026 response.status.should eq 401
1028 it '応答メッセージにUnauthorizedを返す' do
1029 get :ground_pictures, :id => @other_author.id, :format => :json
1030 response.message.should match(/Unauthorized/)
1034 context 'ユーザ権限はないが管理者権限があるとき' do
1039 it 'ステータスコード200 OKを返す' do
1040 get :ground_pictures, :id => @other_author.id
1041 response.should be_success
1044 context 'ユーザだが作家登録していないとき' do
1048 it 'ステータスコード200 OKを返す' do
1049 get :ground_pictures, :id => @other_author.id
1050 response.should be_success
1055 describe '対象作家の色地一覧表示に於いて' do
1057 @other_user = FactoryGirl.create( :user_yas)
1058 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1059 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1060 @gc = FactoryGirl.create :ground_color
1061 @panel = FactoryGirl.create :panel, :author_id => @author.id
1062 Author.stub(:show).and_return(@other_author)
1063 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1066 context 'パラメータpageについて' do
1068 get :ground_colors, :id => @other_author.id, :page => 5
1069 assigns(:page).should eq 5
1071 it '省略されると@pageに1値が入る' do
1072 get :ground_colors, :id => @other_author.id
1073 assigns(:page).should eq 1
1075 it '与えられたpage_sizeがセットされている' do
1076 get :ground_colors, :id => @other_author.id, :page_size => 15
1077 assigns(:page_size).should eq 15
1079 it '省略されると@page_sizeにデフォルト値が入る' do
1080 get :ground_colors, :id => @other_author.id
1081 assigns(:page_size).should eq Author.default_ground_color_page_size
1083 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1084 get :ground_colors, :id => @other_author.id, :page_size => 1500
1085 assigns(:page_size).should eq Author.ground_color_max_page_size
1087 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1088 get :ground_colors, :id => @other_author.id, :page_size => 0
1089 assigns(:page_size).should eq Author.ground_color_page_size
1092 context 'つつがなく終わるとき' do
1093 it 'ステータスコード200 OKを返す' do
1094 get :ground_colors, :id => @other_author.id
1095 response.should be_success
1097 it '作家モデルに単体取得を問い合わせている' do
1098 Author.should_receive(:show).exactly(1)
1099 get :ground_colors, :id => @other_author.id
1101 it '色地モデルに他作家の色地一覧を問い合わせている' do
1102 GroundColor.should_receive(:himlist).exactly(1)
1103 get :ground_colors, :id => @other_author.id
1105 it '@ground_colorsにリストを取得している' do
1106 get :ground_colors, :id => @other_author.id
1107 assigns(:ground_colors).should have_at_least(3).items
1110 it '@paginateにページ制御を取得している' do
1111 get :ground_colors, :id => @other_author.id
1112 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1114 it 'ground_colorsテンプレートを描画する' do
1115 get :ground_colors, :id => @other_author.id
1116 response.should render_template("ground_colors")
1121 get :ground_colors, :id => @other_author.id, :format => :json
1122 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1124 it '色地モデルにjson一覧出力オプションを問い合わせている' do
1125 GroundColor.should_receive(:list_json_opt).exactly(1)
1126 get :ground_colors, :id => @other_author.id, :format => :json
1128 it 'データがリスト構造になっている' do
1129 get :ground_colors, :id => @other_author.id, :format => :json
1130 json = JSON.parse response.body
1131 json.should have_at_least(3).items
1133 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
1134 get :ground_colors, :id => @other_author.id, :format => :json
1135 json = JSON.parse response.body
1136 json.first.has_key?("panel_id").should be_true
1137 json.first.has_key?("code").should be_true
1138 json.first.has_key?("z").should be_true
1142 context 'ユーザ権限がないとき' do
1147 it 'ステータスコード302 Foundを返す' do
1148 get :ground_colors, :id => @other_author.id
1149 response.status.should eq 302
1151 it 'サインインページへ遷移する' do
1152 get :ground_colors, :id => @other_author.id
1153 response.should redirect_to '/users/sign_in'
1157 it 'ステータスコード401 Unauthorizedを返す' do
1158 get :ground_colors, :id => @other_author.id, :format => :json
1159 response.status.should eq 401
1161 it '応答メッセージにUnauthorizedを返す' do
1162 get :ground_colors, :id => @other_author.id, :format => :json
1163 response.message.should match(/Unauthorized/)
1167 context 'ユーザ権限はないが管理者権限があるとき' do
1172 it 'ステータスコード200 OKを返す' do
1173 get :ground_colors, :id => @other_author.id
1174 response.should be_success
1177 context 'ユーザだが作家登録していないとき' do
1181 it 'ステータスコード200 OKを返す' do
1182 get :ground_colors, :id => @other_author.id
1183 response.should be_success
1188 describe '作家数取得に於いて' do
1190 Author.should_receive(:visible_count).and_return(3)
1193 context 'つつがなく終わるとき' do
1194 it 'ステータスコード200 OKを返す' do
1195 get :count, :format => :json
1196 response.should be_success
1200 get :count, :format => :json
1201 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1203 it 'データがHash構造になっていて作家数が3である' do
1204 get :count, :format => :json
1205 json = JSON.parse response.body
1206 json["count"].should == 3
1212 describe '新規作成フォーム表示に於いて' do
1214 @new_user = FactoryGirl.create( :user_yas)
1217 context 'つつがなく終わるとき' do
1218 it 'ステータスコード200 OKを返す' do
1220 response.should be_success
1222 it '@auに新規データを用意している' do
1224 assigns(:au).should be_a_new(Author)
1226 it '作家モデルにデフォルト値補充を依頼している' do
1227 Author.any_instance.should_receive(:supply_default).exactly(1)
1231 it 'newテンプレートを描画する' do
1233 response.should render_template("new")
1237 it 'new.jsテンプレートを描画する' do
1238 get :new, :format => :js
1239 response.should render_template("new")
1244 get :new, :format => :json
1245 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1247 it '作家モデルにjson単体出力オプションを問い合わせている' do
1248 Author.should_receive(:show_json_opt).exactly(1)
1249 get :new, :format => :json
1253 context 'ユーザ権限がないとき' do
1258 it 'ステータスコード302 Foundを返す' do
1260 response.status.should eq 302
1262 it 'サインインページへ遷移する' do
1264 response.body.should redirect_to '/users/sign_in'
1268 it 'ステータスコード401 Unauthorizedを返す' do
1269 get :new, :format => :js
1270 response.status.should eq 401
1272 it '応答メッセージにUnauthorizedを返す' do
1273 get :new, :format => :js
1274 response.message.should match(/Unauthorized/)
1278 it 'ステータスコード401 Unauthorizedを返す' do
1279 get :new, :format => :json
1280 response.status.should eq 401
1282 it '応答メッセージにUnauthorizedを返す' do
1283 get :new, :format => :json
1284 response.message.should match(/Unauthorized/)
1288 context 'ユーザ権限はないが管理者権限があるとき' do
1294 it 'ステータスコード302 Foundを返す' do
1296 response.status.should eq 302
1298 it 'サインインページへ遷移する' do
1300 response.body.should redirect_to '/users/sign_in'
1304 context 'ユーザだが作家登録していないとき' do
1308 it 'ステータスコード200 OKを返す' do
1310 response.should be_success
1315 describe '新規作成に於いて' do
1317 @new_user = FactoryGirl.create( :user_yas)
1319 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1321 context '事前チェックしておく' do
1322 it '作家モデルにデフォルト値補充を依頼している' do
1323 Author.any_instance.should_receive(:supply_default).exactly(1)
1324 post :create, :author => @attr
1326 it '作家モデルにカラム値復元を依頼している' do
1327 Author.any_instance.should_receive(:attributes=).exactly(1)
1328 post :create, :author => @attr
1330 it '作家モデルに上書き補充を依頼している' do
1331 Author.any_instance.should_receive(:overwrite).exactly(1)
1332 post :create, :author => @attr
1335 Author.any_instance.should_receive(:save).exactly(1)
1336 post :create, :author => @attr
1339 context 'つつがなく終わるとき' do
1340 it "@auに作成された作家を保持していて、それがDBにある" do
1341 post :create, :author => @attr
1342 assigns(:au).should be_a(Author)
1343 assigns(:au).should be_persisted
1346 it 'ステータスコード302 Foundを返す' do
1347 Author.any_instance.stub(:save).and_return(true)
1348 post :create, :author => @attr
1349 response.status.should eq 302
1352 # Author.any_instance.stub(:save).and_return(true)
1353 post :create, :author => @attr
1354 response.should redirect_to(root_path)
1358 it 'ステータスコード200 OKを返す' do
1359 # Author.any_instance.stub(:save).and_return(true)
1360 post :create, :author => @attr, :format => :json
1361 response.should be_success
1363 it '作成された作家をjsonデータで返す' do
1364 post :create, :author => @attr, :format => :json
1365 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1367 it '作家モデルにjson単体出力オプションを問い合わせている' do
1368 Author.should_receive(:show_json_opt).exactly(1)
1369 post :create, :author => @attr, :format => :json
1371 it 'データがアレになっている' do
1372 post :create, :author => @attr, :format => :json
1373 json = JSON.parse response.body
1374 json["name"].should match(/ken/)
1378 context 'ユーザ権限がないとき' do
1383 it 'ステータスコード302 Foundを返す' do
1384 post :create, :author => @attr
1385 response.status.should eq 302
1387 it 'サインインページへ遷移する' do
1388 post :create, :author => @attr
1389 response.body.should redirect_to '/users/sign_in'
1393 it 'ステータスコード401 Unauthorizedを返す' do
1394 post :create, :author => @attr, :format => :json
1395 response.status.should eq 401
1397 it '応答メッセージにUnauthorizedを返す' do
1398 post :create, :author => @attr, :format => :json
1399 response.message.should match(/Unauthorized/)
1403 context 'ユーザ権限はないが管理者権限があるとき' do
1409 it 'ステータスコード302 Foundを返す' do
1410 post :create, :author => @attr
1411 response.status.should eq 302
1413 it 'サインインページへ遷移する' do
1414 post :create, :author => @attr
1415 response.body.should redirect_to '/users/sign_in'
1419 context '検証、保存に失敗した' do
1421 Author.any_instance.stub(:save).and_return(false)
1423 it "未保存の作家を保持している" do
1424 post :create, :author => @attr
1425 assigns(:au).should be_a_new(Author)
1428 it 'ステータスコード200 OKを返す' do
1429 post :create, :author => @attr
1430 response.status.should eq 200
1433 post :create, :author => @attr
1434 response.should render_template("new")
1438 it 'ステータスコード422 unprocessable_entity を返す' do
1439 post :create, :author => @attr, :format => :json
1440 response.status.should eq 422
1442 it '応答メッセージUnprocessable Entityを返す' do
1443 post :create, :author => @attr, :format => :json
1444 response.message.should match(/Unprocessable/)
1450 describe '編集フォーム表示に於いて' do
1453 Author.stub(:edit).and_return(@author)
1455 context 'つつがなく終わるとき' do
1456 it 'ステータスコード200 OKを返す' do
1457 get :edit, :id => @author.id
1458 response.should be_success
1460 it '作家モデルに編集取得を問い合わせている' do
1461 Author.should_receive(:edit).exactly(1)
1462 get :edit, :id => @author.id
1464 #@authorだとログイン中のアカウントと干渉してしまう。
1465 it '@auにデータを用意している' do
1466 get :edit, :id => @author.id
1467 assigns(:au).should eq @author
1470 it 'editテンプレートを描画する' do
1471 get :edit, :id => @author.id
1472 response.should render_template("edit")
1476 it 'edit.jsテンプレートを描画する' do
1477 get :edit, :id => @author.id, :format => :js
1478 response.should render_template("edit")
1482 context 'ユーザ権限がないとき' do
1487 it 'ステータスコード302 Foundを返す' do
1488 get :edit, :id => @author.id
1489 response.status.should eq 302
1491 it 'サインインページへ遷移する' do
1492 get :edit, :id => @author.id
1493 response.body.should redirect_to '/users/sign_in'
1497 it 'ステータスコード401 Unauthorizedを返す' do
1498 get :edit, :id => @author.id, :format => :js
1499 response.status.should eq 401
1501 it '応答メッセージにUnauthorizedを返す' do
1502 get :edit, :id => @author.id, :format => :js
1503 response.message.should match(/Unauthorized/)
1507 context 'ユーザ権限はないが管理者権限があるとき' do
1513 it 'ステータスコード302 Foundを返す' do
1514 get :edit, :id => @author.id
1515 response.status.should eq 302
1517 it 'サインインページへ遷移する' do
1518 get :edit, :id => @author.id
1519 response.body.should redirect_to '/users/sign_in'
1523 context 'ユーザだが作家登録していないとき' do
1525 @other_user = FactoryGirl.create( :user_yas)
1526 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1530 it 'ステータスコード302 Foundを返す' do
1531 get :edit, :id => @other_author.id
1532 response.status.should eq 302
1534 it '作家登録ページへ遷移する' do
1535 get :edit, :id => @other_author.id
1536 response.body.should redirect_to new_author_path
1542 describe '更新に於いて' do
1544 @attr = @author.attributes
1545 @attr['name'] = 'ryu'
1548 context '事前チェックしておく' do
1549 it '作家モデルに編集取得を問い合わせている' do
1550 Author.stub(:edit).with(any_args()).and_return @author
1551 Author.should_receive(:edit).exactly(1)
1552 put :update, :id => @author.id, :author => @attr
1554 it 'モデルにpostデータ転送を依頼する' do
1555 Author.any_instance.stub(:attributes=).with(any_args)
1556 Author.any_instance.should_receive(:attributes=).exactly(1)
1557 put :update, :id => @author.id, :author => @attr
1559 it 'モデルに上書き補充を依頼する' do
1560 Author.any_instance.stub(:overwrite).with(any_args)
1561 Author.any_instance.should_receive(:overwrite).exactly(1)
1562 put :update, :id => @author.id, :author => @attr
1565 Author.any_instance.stub(:save).with(any_args).and_return true
1566 Author.any_instance.should_receive(:save).exactly(1)
1567 put :update, :id => @author.id, :author => @attr
1569 it '@auにアレを取得している' do
1570 put :update, :id => @author.id, :author => @attr
1571 assigns(:au).should eq @author
1574 context 'つつがなく終わるとき' do
1576 put :update, :id => @author.id, :author => @attr
1577 Author.find(@author.id).name.should eq 'ryu'
1580 it 'ステータスコード302 Foundを返す' do
1581 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1582 put :update, :id => @author.id, :author => @attr
1583 response.status.should eq 302
1586 put :update, :id => @author.id, :author => @attr
1587 response.should redirect_to('/home/configure')
1591 it 'ステータスコード200 OKを返す' do
1592 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1593 put :update, :id => @author.id, :author => @attr, :format => :json
1594 response.should be_success
1596 it 'ページ本体は特に返さない' do
1597 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1598 put :update, :id => @author.id, :author => @attr, :format => :json
1599 response.body.should match /./
1603 context 'ユーザ権限がないとき' do
1608 it 'ステータスコード302 Foundを返す' do
1609 put :update, :id => @author.id, :author => @attr
1610 response.status.should eq 302
1612 it 'サインインページへ遷移する' do
1613 put :update, :id => @author.id, :author => @attr
1614 response.body.should redirect_to '/users/sign_in'
1618 it '応答メッセージにUnauthorizedを返す' do
1619 put :update, :id => @author.id, :author => @attr, :format => :json
1620 response.message.should match(/Unauthorized/)
1624 context 'ユーザ権限はないが管理者権限があるとき' do
1630 it 'ステータスコード302 Foundを返す' do
1631 put :update, :id => @author.id, :author => @attr
1632 response.status.should eq 302
1634 it 'サインインページへ遷移する' do
1635 put :update, :id => @author.id, :author => @attr
1636 response.body.should redirect_to '/users/sign_in'
1640 context 'ユーザだが作家登録していないとき' do
1642 @other_user = FactoryGirl.create( :user_yas)
1643 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1647 it 'ステータスコード302 Foundを返す' do
1648 get :update, :id => @other_author.id
1649 response.status.should eq 302
1651 it '作家登録ページへ遷移する' do
1652 get :update, :id => @other_author.id
1653 response.body.should redirect_to new_author_path
1657 context '検証、保存に失敗したとき' do
1659 Author.any_instance.stub(:save).and_return(false)
1662 it 'ステータスコード200 Okを返す' do
1663 put :update, :id => @author.id, :author => @attr
1664 response.status.should eq 200
1667 put :update, :id => @author.id, :author => @attr
1668 response.should render_template("edit")
1672 it 'ステータスコード422 unprocessable_entity を返す' do
1673 Author.any_instance.stub(:save).and_return(false)
1674 put :update, :id => @author.id, :author => @attr, :format => :json
1675 response.status.should eq 422
1677 it '応答メッセージUnprocessable Entityを返す' do
1678 put :update, :id => @author.id, :author => @attr, :format => :json
1679 response.message.should match(/Unprocessable/)
1686 describe '一覧表示に於いて' do
1688 Author.stub(:list).and_return([@author, @author, @author])
1691 context 'つつがなく終わるとき' do
1692 it 'ステータスコード200 OKを返す' do
1694 response.should be_success
1697 it 'indexテンプレートを描画する' do
1699 response.should render_template("index")
1704 get :index, :format => :json
1705 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1709 context 'ユーザ権限がないとき' do
1713 it 'ステータスコード200 OKを返す' do
1715 response.should be_success
1718 it 'indexテンプレートを描画する' do
1720 response.should render_template("index")
1725 get :index, :format => :json
1726 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1732 describe '閲覧に於いて' do
1734 Author.stub(:show).and_return(@author)
1737 context 'つつがなく終わるとき' do
1738 it 'ステータスコード200 OKを返す' do
1739 get :show, :id => @author.id
1740 response.should be_success
1743 it 'showテンプレートを描画する' do
1744 get :show, :id => @author.id
1745 response.should render_template("show")
1750 get :show, :id => @author.id, :format => :json
1751 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1755 context 'ユーザ権限がないとき' do
1759 it 'ステータスコード200 OKを返す' do
1760 get :show, :id => @author.id
1761 response.should be_success
1764 it 'showテンプレートを描画する' do
1765 get :show, :id => @author.id
1766 response.should render_template("show")
1771 get :show, :id => @author.id, :format => :json
1772 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1778 describe '対象作家のコミック一覧表示に於いて' do
1780 @other_user = FactoryGirl.create( :user_yas)
1781 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1782 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1783 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
1784 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
1787 context 'つつがなく終わるとき' do
1788 it 'ステータスコード200 OKを返す' do
1789 get :scrolls, :id => @other_author.id
1790 response.should be_success
1793 it 'scrollテンプレートを描画する' do
1794 get :scrolls, :id => @other_author.id
1795 response.should render_template("scroll")
1800 get :scrolls, :id => @other_author.id, :format => :json
1801 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1805 context 'ユーザ権限がないとき' do
1809 it 'ステータスコード200 OKを返す' do
1810 get :scrolls, :id => @other_author.id
1811 response.should be_success
1814 it 'scrollsテンプレートを描画する' do
1815 get :scrolls, :id => @other_author.id
1816 response.should render_template("scrolls")
1821 get :scrolls, :id => @other_author.id, :format => :json
1822 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1828 describe '対象作家のストーリー一覧表示に於いて' do
1830 @other_user = FactoryGirl.create( :user_yas)
1831 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1832 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1833 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
1834 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1835 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id
1836 ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
1839 context 'つつがなく終わるとき' do
1840 it 'ステータスコード200 OKを返す' do
1841 get :scroll_panels, :id => @other_author.id
1842 response.should be_success
1845 it 'scroll_panelsテンプレートを描画する' do
1846 get :scroll_panels, :id => @other_author.id
1847 response.should render_template("scroll_panels")
1852 get :scroll_panels, :id => @other_author.id, :format => :json
1853 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1857 context 'ユーザ権限がないとき' do
1861 it 'ステータスコード200 OKを返す' do
1862 get :scroll_panels, :id => @other_author.id
1863 response.should be_success
1866 it 'scroll_panelsテンプレートを描画する' do
1867 get :scroll_panels, :id => @other_author.id
1868 response.should render_template("scroll_panels")
1873 get :scroll_panels, :id => @other_author.id, :format => :json
1874 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1880 describe '対象作家のコマ一覧表示に於いて' do
1882 @other_user = FactoryGirl.create( :user_yas)
1883 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1884 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1885 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1886 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
1889 context 'つつがなく終わるとき' do
1890 it 'ステータスコード200 OKを返す' do
1891 get :panels, :id => @other_author.id
1892 response.should be_success
1895 it 'panelsテンプレートを描画する' do
1896 get :panels, :id => @other_author.id
1897 response.should render_template("panels")
1902 get :panels, :id => @other_author.id, :format => :json
1903 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1907 context 'ユーザ権限がないとき' do
1911 it 'ステータスコード200 OKを返す' do
1912 get :panels, :id => @other_author.id
1913 response.should be_success
1916 it 'panelsテンプレートを描画する' do
1917 get :panels, :id => @other_author.id
1918 response.should render_template("panels")
1923 get :panels, :id => @other_author.id, :format => :json
1924 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1930 describe '対象作家のコマ絵一覧表示に於いて' do
1932 @other_user = FactoryGirl.create( :user_yas)
1933 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1934 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1935 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1936 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1937 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1938 @panel = FactoryGirl.create :panel, :author_id => @author.id
1939 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
1940 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
1943 context 'つつがなく終わるとき' do
1944 it 'ステータスコード200 OKを返す' do
1945 get :panel_pictures, :id => @other_author.id
1946 response.should be_success
1949 it 'panel_picturesテンプレートを描画する' do
1950 get :panel_pictures, :id => @other_author.id
1951 response.should render_template("panel_pictures")
1956 get :panel_pictures, :id => @other_author.id, :format => :json
1957 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1961 context 'ユーザ権限がないとき' do
1965 it 'ステータスコード200 OKを返す' do
1966 get :panel_pictures, :id => @other_author.id
1967 response.should be_success
1970 it 'panel_picturesテンプレートを描画する' do
1971 get :panel_pictures, :id => @other_author.id
1972 response.should render_template("panel_pictures")
1977 get :panel_pictures, :id => @other_author.id, :format => :json
1978 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1984 describe '対象作家の絵地一覧表示に於いて' do
1986 @other_user = FactoryGirl.create( :user_yas)
1987 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1988 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1989 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1990 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1991 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1992 @panel = FactoryGirl.create :panel, :author_id => @author.id
1993 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1994 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1997 context 'つつがなく終わるとき' do
1998 it 'ステータスコード200 OKを返す' do
1999 get :ground_pictures, :id => @other_author.id
2000 response.should be_success
2003 it 'ground_picturesテンプレートを描画する' do
2004 get :ground_pictures, :id => @other_author.id
2005 response.should render_template("ground_pictures")
2010 get :ground_pictures, :id => @other_author.id, :format => :json
2011 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2015 context 'ユーザ権限がないとき' do
2020 it 'ground_picturesテンプレートを描画する' do
2021 get :ground_pictures, :id => @other_author.id
2022 response.should render_template("ground_pictures")
2027 get :ground_pictures, :id => @other_author.id, :format => :json
2028 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2034 describe '対象作家の色地一覧表示に於いて' do
2036 @other_user = FactoryGirl.create( :user_yas)
2037 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2038 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2039 @gc = FactoryGirl.create :ground_color
2040 @panel = FactoryGirl.create :panel, :author_id => @author.id
2041 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
2044 context 'つつがなく終わるとき' do
2045 it 'ステータスコード200 OKを返す' do
2046 get :ground_colors, :id => @other_author.id
2047 response.should be_success
2050 it 'ground_colorsテンプレートを描画する' do
2051 get :ground_colors, :id => @other_author.id
2052 response.should render_template("ground_colors")
2057 get :ground_colors, :id => @other_author.id, :format => :json
2058 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2062 context 'ユーザ権限がないとき' do
2067 it 'ground_colorsテンプレートを描画する' do
2068 get :ground_colors, :id => @other_author.id
2069 response.should render_template("ground_colors")
2074 get :ground_colors, :id => @other_author.id, :format => :json
2075 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2081 describe '作家数取得に於いて' do
2083 Author.should_receive(:visible_count).and_return(3)
2086 context 'つつがなく終わるとき' do
2087 it 'ステータスコード200 OKを返す' do
2088 get :count, :format => :json
2089 response.should be_success
2093 get :count, :format => :json
2094 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2100 describe '新規作成フォーム表示に於いて' do
2102 @new_user = FactoryGirl.create( :user_yas)
2105 context 'つつがなく終わるとき' do
2106 it 'ステータスコード200 OKを返す' do
2108 response.should be_success
2111 it 'newテンプレートを描画する' do
2113 response.should render_template("new")
2117 it 'new.jsテンプレートを描画する' do
2118 get :new, :format => :js
2119 response.should render_template("new")
2124 get :new, :format => :json
2125 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2129 context 'ユーザ権限がないとき' do
2134 it 'ステータスコード302 Foundを返す' do
2136 response.status.should eq 302
2138 it 'サインインページへ遷移する' do
2140 response.body.should redirect_to '/users/sign_in'
2144 it 'ステータスコード401 Unauthorizedを返す' do
2145 get :new, :format => :js
2146 response.status.should eq 401
2148 it '応答メッセージにUnauthorizedを返す' do
2149 get :new, :format => :js
2150 response.message.should match(/Unauthorized/)
2154 it 'ステータスコード401 Unauthorizedを返す' do
2155 get :new, :format => :json
2156 response.status.should eq 401
2158 it '応答メッセージにUnauthorizedを返す' do
2159 get :new, :format => :json
2160 response.message.should match(/Unauthorized/)
2166 describe '新規作成に於いて' do
2168 @new_user = FactoryGirl.create( :user_yas)
2170 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
2172 context 'つつがなく終わるとき' do
2174 it 'ステータスコード302 Foundを返す' do
2175 Author.any_instance.stub(:save).and_return(true)
2176 post :create, :author => @attr
2177 response.status.should eq 302
2180 # Author.any_instance.stub(:save).and_return(true)
2181 post :create, :author => @attr
2182 response.should redirect_to(root_path)
2186 it 'ステータスコード200 OKを返す' do
2187 # Author.any_instance.stub(:save).and_return(true)
2188 post :create, :author => @attr, :format => :json
2189 response.should be_success
2193 context 'ユーザ権限がないとき' do
2198 it 'ステータスコード302 Foundを返す' do
2199 post :create, :author => @attr
2200 response.status.should eq 302
2202 it 'サインインページへ遷移する' do
2203 post :create, :author => @attr
2204 response.body.should redirect_to '/users/sign_in'
2208 it 'ステータスコード401 Unauthorizedを返す' do
2209 post :create, :author => @attr, :format => :json
2210 response.status.should eq 401
2212 it '応答メッセージにUnauthorizedを返す' do
2213 post :create, :author => @attr, :format => :json
2214 response.message.should match(/Unauthorized/)
2220 describe '編集フォーム表示に於いて' do
2223 Author.stub(:edit).and_return(@author)
2225 context 'つつがなく終わるとき' do
2226 it 'ステータスコード200 OKを返す' do
2227 get :edit, :id => @author.id
2228 response.should be_success
2231 it 'editテンプレートを描画する' do
2232 get :edit, :id => @author.id
2233 response.should render_template("edit")
2237 it 'edit.jsテンプレートを描画する' do
2238 get :edit, :id => @author.id, :format => :js
2239 response.should render_template("edit")
2243 context 'ユーザ権限がないとき' do
2248 it 'ステータスコード302 Foundを返す' do
2249 get :edit, :id => @author.id
2250 response.status.should eq 302
2252 it 'サインインページへ遷移する' do
2253 get :edit, :id => @author.id
2254 response.body.should redirect_to '/users/sign_in'
2258 it 'ステータスコード401 Unauthorizedを返す' do
2259 get :edit, :id => @author.id, :format => :js
2260 response.status.should eq 401
2262 it '応答メッセージにUnauthorizedを返す' do
2263 get :edit, :id => @author.id, :format => :js
2264 response.message.should match(/Unauthorized/)
2270 describe '更新に於いて' do
2272 @attr = @author.attributes
2273 @attr['name'] = 'ryu'
2276 context 'つつがなく終わるとき' do
2278 put :update, :id => @author.id, :author => @attr
2279 Author.find(@author.id).name.should eq 'ryu'
2282 it 'ステータスコード302 Foundを返す' do
2283 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2284 put :update, :id => @author.id, :author => @attr
2285 response.status.should eq 302
2288 put :update, :id => @author.id, :author => @attr
2289 response.should redirect_to('/home/configure')
2293 it 'ステータスコード200 OKを返す' do
2294 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2295 put :update, :id => @author.id, :author => @attr, :format => :json
2296 response.should be_success
2298 it 'ページ本体は特に返さない' do
2299 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2300 put :update, :id => @author.id, :author => @attr, :format => :json
2301 response.body.should match /./
2305 context 'ユーザ権限がないとき' do
2309 it 'ステータスコード302 Foundを返す' do
2310 put :update, :id => @author.id, :author => @attr
2311 response.status.should eq 302
2314 it 'サインインページへ遷移する' do
2315 put :update, :id => @author.id, :author => @attr
2316 response.body.should redirect_to '/users/sign_in'
2320 it '応答メッセージにUnauthorizedを返す' do
2321 put :update, :id => @author.id, :author => @attr, :format => :json
2322 response.message.should match(/Unauthorized/)