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 @user = FactoryGirl.create( :user_yas)
12 @author = FactoryGirl.create :author, :user_id => @user.id
13 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
16 if MagicNumber['run_mode'] == 1
17 describe '一覧表示に於いて' do
19 Author.stub(:list).and_return([@author, @author, @author])
23 it '与えられたpageがセットされている' do
24 get :index, :page => 5
25 assigns(:page).should eq 5
27 it '省略されると@pageに1値が入る' do
29 assigns(:page).should eq 1
31 it '与えられたpage_sizeがセットされている' do
32 get :index, :page_size => 15
33 assigns(:page_size).should eq 15
35 it '省略されると@page_sizeにデフォルト値が入る' do
37 assigns(:page_size).should eq Author.default_page_size
39 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
40 get :index, :page_size => 1500
41 assigns(:page_size).should eq Author.max_page_size
43 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
44 get :index, :page_size => 0
45 assigns(:page_size).should eq Author.default_page_size
48 context 'つつがなく終わるとき' do
49 it 'ステータスコード200 OKを返す' do
51 response.should be_success
53 it '作家モデルに一覧を問い合わせている' do
54 Author.should_receive(:list).exactly(1)
57 it '@authorsにリストを取得している' do
59 assigns(:authors).should have_at_least(3).items
62 it 'indexテンプレートを描画する' do
64 response.should render_template("index")
69 get :index, :format => :json
70 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
72 it '作家モデルにjson一覧出力オプションを問い合わせている' do
73 Author.should_receive(:list_json_opt).exactly(1)
74 get :index, :format => :json
76 it 'データがリスト構造になっている' do
77 get :index, :format => :json
78 json = JSON.parse response.body
79 json.should have_at_least(3).items
81 it 'リストの先頭くらいは作家っぽいものであって欲しい' do
82 get :index, :format => :json
83 json = JSON.parse response.body
84 json.first.has_key?("name").should be_true
85 json.first.has_key?("user_id").should be_true
89 context 'ユーザ権限がないとき' do
94 it 'ステータスコード302 Foundを返す' do
96 response.status.should eq 302
100 response.should redirect_to '/users/sign_in'
104 it 'ステータスコード401 Unauthorizedを返す' do
105 get :index, :format => :json
106 response.status.should eq 401
108 it '応答メッセージにUnauthorizedを返す' do
109 get :index, :format => :json
110 response.message.should match(/Unauthorized/)
114 context 'ユーザ権限はないが管理者権限があるとき' do
119 it 'ステータスコード200 OKを返す' do
121 response.should be_success
124 context 'ユーザだが作家登録していないとき' do
128 it 'ステータスコード200 OKを返す' do
130 response.should be_success
137 Author.stub(:show).and_return(@author)
140 context 'つつがなく終わるとき' do
141 it 'ステータスコード200 OKを返す' do
142 get :show, :id => @author.id
143 response.should be_success
145 it '作家モデルに単体取得を問い合わせている' do
146 Author.should_receive(:show).exactly(1)
149 #@authorだとログイン中のアカウントと干渉してしまう。
150 it '@auにアレを取得している' do
151 get :show, :id => @author.id
152 assigns(:au).should eq(@author)
155 it 'showテンプレートを描画する' do
156 get :show, :id => @author.id
157 response.should render_template("show")
162 get :show, :id => @author.id, :format => :json
163 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
165 it '作家モデルにjson単体出力オプションを問い合わせている' do
166 Author.should_receive(:show_json_opt).exactly(1)
167 get :show, :id => @author.id, :format => :json
170 get :show, :id => @author.id, :format => :json
171 json = JSON.parse response.body
172 json["name"].should match(/test/)
173 json["user_id"].should eq @author.user_id
177 context 'ユーザ権限がないとき' do
182 it 'ステータスコード302 Foundを返す' do
183 get :show, :id => @author.id
184 response.status.should eq 302
186 it 'サインインページへ遷移する' do
187 get :show, :id => @author.id
188 response.body.should redirect_to '/users/sign_in'
192 it 'ステータスコード401 Unauthorizedを返す' do
193 get :show, :id => @author.id, :format => :json
194 response.status.should eq 401
196 it '応答メッセージにUnauthorizedを返す' do
197 get :show, :id => @author.id, :format => :json
198 response.message.should match(/Unauthorized/)
202 context 'ユーザ権限はないが管理者権限があるとき' do
207 it 'ステータスコード200 OKを返す' do
208 get :show, :id => @author.id
209 response.should be_success
212 context 'ユーザだが作家登録していないとき' do
216 it 'ステータスコード200 OKを返す' do
217 get :show, :id => @author.id
218 response.should be_success
222 context '対象作家がないとき' do
224 it '例外404 not_foundを返す' do
227 }.should raise_error(ActiveRecord::RecordNotFound)
231 it '例外404 not_foundを返す' do
233 get :show, :id => 0, :format => :json
234 }.should raise_error(ActiveRecord::RecordNotFound)
241 describe '対象作家のコミック一覧表示に於いて' do
243 @other_user = FactoryGirl.create( :user_yas)
244 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
245 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
246 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
247 Comic.stub(:himlist).and_return([@comic, @comic, @comic])
250 context 'パラメータpageについて' do
252 get :comics, :id => @other_author.id, :page => 5
253 assigns(:page).should eq 5
255 it '省略されると@pageに1値が入る' do
256 get :comics, :id => @other_author.id
257 assigns(:page).should eq 1
259 it '与えられたpage_sizeがセットされている' do
260 get :comics, :id => @other_author.id, :page_size => 15
261 assigns(:page_size).should eq 15
263 it '省略されると@page_sizeにデフォルト値が入る' do
264 get :comics, :id => @other_author.id
265 assigns(:page_size).should eq Author.default_comic_page_size
267 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
268 get :comics, :id => @other_author.id, :page_size => 1500
269 assigns(:page_size).should eq Author.comic_max_page_size
271 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
272 get :comics, :id => @other_author.id, :page_size => 0
273 assigns(:page_size).should eq Author.default_comic_page_size
276 context 'つつがなく終わるとき' do
277 it 'ステータスコード200 OKを返す' do
278 get :comics, :id => @other_author.id
279 response.should be_success
281 it '作家モデルに単体取得を問い合わせている' do
282 Author.should_receive(:show).exactly(1)
283 get :comics, :id => @other_author.id
285 it 'コミックモデルに一覧を問い合わせている' do
286 Comic.should_receive(:himlist).exactly(1)
287 get :comics, :id => @other_author.id
289 it '@comicsにリストを取得している' do
290 get :comics, :id => @other_author.id
291 assigns(:comics).should have_at_least(3).items
294 it 'comicsテンプレートを描画する' do
295 get :comics, :id => @other_author.id
296 response.should render_template("comics")
301 get :comics, :id => @other_author.id, :format => :json
302 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
304 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
305 Comic.should_receive(:list_json_opt).exactly(1)
306 get :comics, :id => @other_author.id, :format => :json
308 it 'データがリスト構造になっている' do
309 get :comics, :id => @other_author.id, :format => :json
310 json = JSON.parse response.body
311 json.should have_at_least(3).items
313 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
314 get :comics, :id => @other_author.id, :format => :json
315 json = JSON.parse response.body
316 json.first.has_key?("title").should be_true
317 json.first.has_key?("visible").should be_true
321 context 'ユーザ権限がないとき' do
326 it 'ステータスコード302 Foundを返す' do
327 get :comics, :id => @other_author.id
328 response.status.should eq 302
330 it 'サインインページへ遷移する' do
331 get :comics, :id => @other_author.id
332 response.should redirect_to '/users/sign_in'
336 it 'ステータスコード401 Unauthorizedを返す' do
337 get :comics, :id => @other_author.id, :format => :json
338 response.status.should eq 401
340 it '応答メッセージにUnauthorizedを返す' do
341 get :comics, :id => @other_author.id, :format => :json
342 response.message.should match(/Unauthorized/)
346 context 'ユーザ権限はないが管理者権限があるとき' do
351 it 'ステータスコード200 OKを返す' do
352 get :comics, :id => @other_author.id
353 response.should be_success
356 context 'ユーザだが作家登録していないとき' do
360 it 'ステータスコード200 OKを返す' do
361 get :comics, :id => @other_author.id
362 response.should be_success
367 describe '対象作家のストーリー一覧表示に於いて' do
369 @other_user = FactoryGirl.create( :user_yas)
370 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
371 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
372 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
373 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
374 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_user.author.id
375 Story.stub(:himlist).and_return([@story, @story, @story])
378 context 'パラメータpageについて' do
380 get :stories, :id => @other_author.id, :page => 5
381 assigns(:page).should eq 5
383 it '省略されると@pageに1値が入る' do
384 get :stories, :id => @other_author.id
385 assigns(:page).should eq 1
387 it '与えられたpage_sizeがセットされている' do
388 get :stories, :id => @other_author.id, :page_size => 15
389 assigns(:page_size).should eq 15
391 it '省略されると@page_sizeにデフォルト値が入る' do
392 get :stories, :id => @other_author.id
393 assigns(:page_size).should eq Author.default_story_page_size
395 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
396 get :stories, :id => @other_author.id, :page_size => 1500
397 assigns(:page_size).should eq Author.story_max_page_size
399 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
400 get :stories, :id => @other_author.id, :page_size => 0
401 assigns(:page_size).should eq Author.default_story_page_size
404 context 'つつがなく終わるとき' do
405 it 'ステータスコード200 OKを返す' do
406 get :stories, :id => @other_author.id
407 response.should be_success
409 it '作家モデルに単体取得を問い合わせている' do
410 Author.should_receive(:show).exactly(1)
411 get :stories, :id => @other_author.id
413 it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
414 Story.should_receive(:himlist).exactly(1)
415 get :stories, :id => @other_author.id
417 it '@storiesにリストを取得している' do
418 get :stories, :id => @other_author.id
419 assigns(:stories).should have_at_least(3).items
422 it 'storiesテンプレートを描画する' do
423 get :stories, :id => @other_author.id
424 response.should render_template("stories")
429 get :stories, :id => @other_author.id, :format => :json
430 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
432 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
433 Story.should_receive(:list_json_opt).exactly(1)
434 get :stories, :id => @other_author.id, :format => :json
436 it 'データがリスト構造になっている' do
437 get :stories, :id => @other_author.id, :format => :json
438 json = JSON.parse response.body
439 json.should have_at_least(3).items
441 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
442 get :stories, :id => @other_author.id, :format => :json
443 json = JSON.parse response.body
444 json.first.has_key?("panel_id").should be_true
445 json.first.has_key?("comic_id").should be_true
446 json.first.has_key?("t").should be_true
450 context 'ユーザ権限がないとき' do
455 it 'ステータスコード302 Foundを返す' do
456 get :stories, :id => @other_author.id
457 response.status.should eq 302
459 it 'サインインページへ遷移する' do
460 get :stories, :id => @other_author.id
461 response.should redirect_to '/users/sign_in'
465 it 'ステータスコード401 Unauthorizedを返す' do
466 get :stories, :id => @other_author.id, :format => :json
467 response.status.should eq 401
469 it '応答メッセージにUnauthorizedを返す' do
470 get :stories, :id => @other_author.id, :format => :json
471 response.message.should match(/Unauthorized/)
475 context 'ユーザ権限はないが管理者権限があるとき' do
480 it 'ステータスコード200 OKを返す' do
481 get :stories, :id => @other_author.id
482 response.should be_success
485 context 'ユーザだが作家登録していないとき' do
489 it 'ステータスコード200 OKを返す' do
490 get :stories, :id => @other_author.id
491 response.should be_success
496 describe '対象作家のコマ一覧表示に於いて' do
498 @other_user = FactoryGirl.create( :user_yas)
499 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
500 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
501 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
502 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
505 context 'パラメータpageについて' do
507 get :panels, :id => @other_author.id, :page => 5
508 assigns(:page).should eq 5
510 it '省略されると@pageに1値が入る' do
511 get :panels, :id => @other_author.id
512 assigns(:page).should eq 1
514 it '与えられたpage_sizeがセットされている' do
515 get :panels, :id => @other_author.id, :page_size => 15
516 assigns(:page_size).should eq 15
518 it '省略されると@page_sizeにデフォルト値が入る' do
519 get :panels, :id => @other_author.id
520 assigns(:page_size).should eq Author.default_panel_page_size
522 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
523 get :panels, :id => @other_author.id, :page_size => 1500
524 assigns(:page_size).should eq Author.panel_max_page_size
526 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
527 get :panels, :id => @other_author.id, :page_size => 0
528 assigns(:page_size).should eq Author.default_panel_page_size
531 context 'つつがなく終わるとき' do
532 it 'ステータスコード200 OKを返す' do
533 get :panels, :id => @other_author.id
534 response.should be_success
536 it '作家モデルに単体取得を問い合わせている' do
537 Author.should_receive(:show).exactly(1)
538 get :panels, :id => @other_author.id
540 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
541 Panel.should_receive(:himlist).exactly(1)
542 get :panels, :id => @other_author.id
544 it '@panelsにリストを取得している' do
545 get :panels, :id => @other_author.id
546 assigns(:panels).should have_at_least(3).items
549 it 'panelsテンプレートを描画する' do
550 get :panels, :id => @other_author.id
551 response.should render_template("panels")
556 get :panels, :id => @other_author.id, :format => :json
557 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
559 it 'コマモデルにコマリストのjson出力を問い合わせている' do
560 Panel.should_receive(:list_as_json_text).exactly(1)
561 get :panels, :id => @other_author.id, :format => :json
563 it 'データがリスト構造になっている' do
564 get :panels, :id => @other_author.id, :format => :json
565 json = JSON.parse response.body
566 json.should have_at_least(3).items
568 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
569 get :panels, :id => @other_author.id, :format => :json
570 json = JSON.parse response.body
571 json.first.has_key?("z").should be_true
575 context 'ユーザ権限がないとき' do
580 it 'ステータスコード302 Foundを返す' do
581 get :panels, :id => @other_author.id
582 response.status.should eq 302
584 it 'サインインページへ遷移する' do
585 get :panels, :id => @other_author.id
586 response.should redirect_to '/users/sign_in'
590 it 'ステータスコード401 Unauthorizedを返す' do
591 get :panels, :id => @other_author.id, :format => :json
592 response.status.should eq 401
594 it '応答メッセージにUnauthorizedを返す' do
595 get :panels, :id => @other_author.id, :format => :json
596 response.message.should match(/Unauthorized/)
600 context 'ユーザ権限はないが管理者権限があるとき' do
605 it 'ステータスコード200 OKを返す' do
606 get :panels, :id => @other_author.id
607 response.should be_success
610 context 'ユーザだが作家登録していないとき' do
614 it 'ステータスコード200 OKを返す' do
615 get :panels, :id => @other_author.id
616 response.should be_success
621 describe '対象作家のコマ絵一覧表示に於いて' do
623 @other_user = FactoryGirl.create( :user_yas)
624 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
625 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
626 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
627 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
628 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
629 @panel = FactoryGirl.create :panel, :author_id => @author.id
630 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
631 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
634 context 'パラメータpageについて' do
636 get :panel_pictures, :id => @other_author.id, :page => 5
637 assigns(:page).should eq 5
639 it '省略されると@pageに1値が入る' do
640 get :panel_pictures, :id => @other_author.id
641 assigns(:page).should eq 1
643 it '与えられたpage_sizeがセットされている' do
644 get :panel_pictures, :id => @other_author.id, :page_size => 15
645 assigns(:page_size).should eq 15
647 it '省略されると@page_sizeにデフォルト値が入る' do
648 get :panel_pictures, :id => @other_author.id
649 assigns(:page_size).should eq Author.default_panel_picture_page_size
651 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
652 get :panel_pictures, :id => @other_author.id, :page_size => 1500
653 assigns(:page_size).should eq Author.panel_picture_max_page_size
655 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
656 get :panel_pictures, :id => @other_author.id, :page_size => 0
657 assigns(:page_size).should eq Author.default_panel_picture_page_size
660 context 'つつがなく終わるとき' do
661 it 'ステータスコード200 OKを返す' do
662 get :panel_pictures, :id => @other_author.id
663 response.should be_success
665 it '作家モデルに単体取得を問い合わせている' do
666 Author.should_receive(:show).exactly(1)
667 get :panel_pictures, :id => @other_author.id
669 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
670 PanelPicture.should_receive(:himlist).exactly(1)
671 get :panel_pictures, :id => @other_author.id
673 it '@panel_picturesにリストを取得している' do
674 get :panel_pictures, :id => @other_author.id
675 assigns(:panel_pictures).should have_at_least(3).items
678 it 'panel_picturesテンプレートを描画する' do
679 get :panel_pictures, :id => @other_author.id
680 response.should render_template("panel_pictures")
685 get :panel_pictures, :id => @other_author.id, :format => :json
686 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
688 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
689 PanelPicture.should_receive(:list_json_opt).exactly(1)
690 get :panel_pictures, :id => @other_author.id, :format => :json
692 it 'データがリスト構造になっている' do
693 get :panel_pictures, :id => @other_author.id, :format => :json
694 json = JSON.parse response.body
695 json.should have_at_least(3).items
697 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
698 get :panel_pictures, :id => @other_author.id, :format => :json
699 json = JSON.parse response.body
700 json.first.has_key?("link").should be_true
701 json.first.has_key?("x").should be_true
702 json.first.has_key?("y").should be_true
706 context 'ユーザ権限がないとき' do
711 it 'ステータスコード302 Foundを返す' do
712 get :panel_pictures, :id => @other_author.id
713 response.status.should eq 302
715 it 'サインインページへ遷移する' do
716 get :panel_pictures, :id => @other_author.id
717 response.should redirect_to '/users/sign_in'
721 it 'ステータスコード401 Unauthorizedを返す' do
722 get :panel_pictures, :id => @other_author.id, :format => :json
723 response.status.should eq 401
725 it '応答メッセージにUnauthorizedを返す' do
726 get :panel_pictures, :id => @other_author.id, :format => :json
727 response.message.should match(/Unauthorized/)
731 context 'ユーザ権限はないが管理者権限があるとき' do
736 it 'ステータスコード200 OKを返す' do
737 get :panel_pictures, :id => @other_author.id
738 response.should be_success
741 context 'ユーザだが作家登録していないとき' do
745 it 'ステータスコード200 OKを返す' do
746 get :panel_pictures, :id => @other_author.id
747 response.should be_success
752 describe '対象作家の絵地一覧表示に於いて' do
754 @other_user = FactoryGirl.create( :user_yas)
755 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
756 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
757 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
758 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
759 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
760 @panel = FactoryGirl.create :panel, :author_id => @author.id
761 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
762 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
765 context 'パラメータpageについて' do
767 get :ground_pictures, :id => @other_author.id, :page => 5
768 assigns(:page).should eq 5
770 it '省略されると@pageに1値が入る' do
771 get :ground_pictures, :id => @other_author.id
772 assigns(:page).should eq 1
774 it '与えられたpage_sizeがセットされている' do
775 get :ground_pictures, :id => @other_author.id, :page_size => 15
776 assigns(:page_size).should eq 15
778 it '省略されると@page_sizeにデフォルト値が入る' do
779 get :ground_pictures, :id => @other_author.id
780 assigns(:page_size).should eq Author.default_ground_picture_page_size
782 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
783 get :ground_pictures, :id => @other_author.id, :page_size => 1500
784 assigns(:page_size).should eq Author.ground_picture_max_page_size
786 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
787 get :ground_pictures, :id => @other_author.id, :page_size => 0
788 assigns(:page_size).should eq Author.default_ground_picture_page_size
791 context 'つつがなく終わるとき' do
792 it 'ステータスコード200 OKを返す' do
793 get :ground_pictures, :id => @other_author.id
794 response.should be_success
796 it '作家モデルに単体取得を問い合わせている' do
797 Author.should_receive(:show).exactly(1)
798 get :ground_pictures, :id => @other_author.id
800 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
801 GroundPicture.should_receive(:himlist).exactly(1)
802 get :ground_pictures, :id => @other_author.id
804 it '@ground_picturesにリストを取得している' do
805 get :ground_pictures, :id => @other_author.id
806 assigns(:ground_pictures).should have_at_least(3).items
809 it 'ground_picturesテンプレートを描画する' do
810 get :ground_pictures, :id => @other_author.id
811 response.should render_template("ground_pictures")
816 get :ground_pictures, :id => @other_author.id, :format => :json
817 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
819 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
820 GroundPicture.should_receive(:list_json_opt).exactly(1)
821 get :ground_pictures, :id => @other_author.id, :format => :json
823 it 'データがリスト構造になっている' do
824 get :ground_pictures, :id => @other_author.id, :format => :json
825 json = JSON.parse response.body
826 json.should have_at_least(3).items
828 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
829 get :ground_pictures, :id => @other_author.id, :format => :json
830 json = JSON.parse response.body
831 json.first.has_key?("panel_id").should be_true
832 json.first.has_key?("picture_id").should be_true
833 json.first.has_key?("z").should be_true
837 context 'ユーザ権限がないとき' do
842 it 'ステータスコード302 Foundを返す' do
843 get :ground_pictures, :id => @other_author.id
844 response.status.should eq 302
846 it 'サインインページへ遷移する' do
847 get :ground_pictures, :id => @other_author.id
848 response.should redirect_to '/users/sign_in'
852 it 'ステータスコード401 Unauthorizedを返す' do
853 get :ground_pictures, :id => @other_author.id, :format => :json
854 response.status.should eq 401
856 it '応答メッセージにUnauthorizedを返す' do
857 get :ground_pictures, :id => @other_author.id, :format => :json
858 response.message.should match(/Unauthorized/)
862 context 'ユーザ権限はないが管理者権限があるとき' do
867 it 'ステータスコード200 OKを返す' do
868 get :ground_pictures, :id => @other_author.id
869 response.should be_success
872 context 'ユーザだが作家登録していないとき' do
876 it 'ステータスコード200 OKを返す' do
877 get :ground_pictures, :id => @other_author.id
878 response.should be_success
883 describe '対象作家の選択色地一覧表示に於いて' do
885 @other_user = FactoryGirl.create( :user_yas)
886 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
887 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
888 @color = FactoryGirl.create :color
889 @gc = FactoryGirl.create :ground_color, :color_id => @color.id
890 @panel = FactoryGirl.create :panel, :author_id => @author.id
891 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
894 context 'パラメータpageについて' do
896 get :ground_colors, :id => @other_author.id, :page => 5
897 assigns(:page).should eq 5
899 it '省略されると@pageに1値が入る' do
900 get :ground_colors, :id => @other_author.id
901 assigns(:page).should eq 1
903 it '与えられたpage_sizeがセットされている' do
904 get :ground_colors, :id => @other_author.id, :page_size => 15
905 assigns(:page_size).should eq 15
907 it '省略されると@page_sizeにデフォルト値が入る' do
908 get :ground_colors, :id => @other_author.id
909 assigns(:page_size).should eq Author.default_ground_color_page_size
911 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
912 get :ground_colors, :id => @other_author.id, :page_size => 1500
913 assigns(:page_size).should eq Author.ground_color_max_page_size
915 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
916 get :ground_colors, :id => @other_author.id, :page_size => 0
917 assigns(:page_size).should eq Author.ground_color_page_size
920 context 'つつがなく終わるとき' do
921 it 'ステータスコード200 OKを返す' do
922 get :ground_colors, :id => @other_author.id
923 response.should be_success
925 it '作家モデルに単体取得を問い合わせている' do
926 Author.should_receive(:show).exactly(1)
927 get :ground_colors, :id => @other_author.id
929 it '選択色地モデルに他作家の選択色地一覧を問い合わせている' do
930 GroundColor.should_receive(:himlist).exactly(1)
931 get :ground_colors, :id => @other_author.id
933 it '@ground_colorsにリストを取得している' do
934 get :ground_colors, :id => @other_author.id
935 assigns(:ground_colors).should have_at_least(3).items
938 it 'ground_colorsテンプレートを描画する' do
939 get :ground_colors, :id => @other_author.id
940 response.should render_template("ground_colors")
945 get :ground_colors, :id => @other_author.id, :format => :json
946 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
948 it '選択色地モデルにjson一覧出力オプションを問い合わせている' do
949 GroundColor.should_receive(:list_json_opt).exactly(1)
950 get :ground_colors, :id => @other_author.id, :format => :json
952 it 'データがリスト構造になっている' do
953 get :ground_colors, :id => @other_author.id, :format => :json
954 json = JSON.parse response.body
955 json.should have_at_least(3).items
957 it 'リストの先頭くらいは選択色地っぽいものであって欲しい' do
958 get :ground_colors, :id => @other_author.id, :format => :json
959 json = JSON.parse response.body
960 json.first.has_key?("panel_id").should be_true
961 json.first.has_key?("color_id").should be_true
962 json.first.has_key?("z").should be_true
966 context 'ユーザ権限がないとき' do
971 it 'ステータスコード302 Foundを返す' do
972 get :ground_colors, :id => @other_author.id
973 response.status.should eq 302
975 it 'サインインページへ遷移する' do
976 get :ground_colors, :id => @other_author.id
977 response.should redirect_to '/users/sign_in'
981 it 'ステータスコード401 Unauthorizedを返す' do
982 get :ground_colors, :id => @other_author.id, :format => :json
983 response.status.should eq 401
985 it '応答メッセージにUnauthorizedを返す' do
986 get :ground_colors, :id => @other_author.id, :format => :json
987 response.message.should match(/Unauthorized/)
991 context 'ユーザ権限はないが管理者権限があるとき' do
996 it 'ステータスコード200 OKを返す' do
997 get :ground_colors, :id => @other_author.id
998 response.should be_success
1001 context 'ユーザだが作家登録していないとき' do
1005 it 'ステータスコード200 OKを返す' do
1006 get :ground_colors, :id => @other_author.id
1007 response.should be_success
1012 describe '対象作家の指定色地一覧表示に於いて' do
1014 @other_user = FactoryGirl.create( :user_yas)
1015 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1016 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1017 @panel = FactoryGirl.create :panel, :author_id => @author.id
1018 @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
1019 PanelColor.stub(:himlist).and_return([@pc, @pc, @pc])
1022 context 'パラメータpageについて' do
1024 get :panel_colors, :id => @other_author.id, :page => 5
1025 assigns(:page).should eq 5
1027 it '省略されると@pageに1値が入る' do
1028 get :panel_colors, :id => @other_author.id
1029 assigns(:page).should eq 1
1031 it '与えられたpage_sizeがセットされている' do
1032 get :panel_colors, :id => @other_author.id, :page_size => 15
1033 assigns(:page_size).should eq 15
1035 it '省略されると@page_sizeにデフォルト値が入る' do
1036 get :panel_colors, :id => @other_author.id
1037 assigns(:page_size).should eq Author.default_panel_color_page_size
1039 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1040 get :panel_colors, :id => @other_author.id, :page_size => 1500
1041 assigns(:page_size).should eq Author.panel_color_max_page_size
1043 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1044 get :panel_colors, :id => @other_author.id, :page_size => 0
1045 assigns(:page_size).should eq Author.panel_color_page_size
1048 context 'つつがなく終わるとき' do
1049 it 'ステータスコード200 OKを返す' do
1050 get :panel_colors, :id => @other_author.id
1051 response.should be_success
1053 it '作家モデルに単体取得を問い合わせている' do
1054 Author.should_receive(:show).exactly(1)
1055 get :panel_colors, :id => @other_author.id
1057 it '指定色地モデルに他作家の指定色地一覧を問い合わせている' do
1058 PanelColor.should_receive(:himlist).exactly(1)
1059 get :panel_colors, :id => @other_author.id
1061 it '@panel_colorsにリストを取得している' do
1062 get :panel_colors, :id => @other_author.id
1063 assigns(:panel_colors).should have_at_least(3).items
1066 it 'panel_colorsテンプレートを描画する' do
1067 get :panel_colors, :id => @other_author.id
1068 response.should render_template("panel_colors")
1073 get :panel_colors, :id => @other_author.id, :format => :json
1074 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1076 it '指定色地モデルにjson一覧出力オプションを問い合わせている' do
1077 PanelColor.should_receive(:list_json_opt).exactly(1)
1078 get :panel_colors, :id => @other_author.id, :format => :json
1080 it 'データがリスト構造になっている' do
1081 get :panel_colors, :id => @other_author.id, :format => :json
1082 json = JSON.parse response.body
1083 json.should have_at_least(3).items
1085 it 'リストの先頭くらいは指定色地っぽいものであって欲しい' do
1086 get :panel_colors, :id => @other_author.id, :format => :json
1087 json = JSON.parse response.body
1088 json.first.has_key?("panel_id").should be_true
1089 json.first.has_key?("code").should be_true
1090 json.first.has_key?("z").should be_true
1094 context 'ユーザ権限がないとき' do
1099 it 'ステータスコード302 Foundを返す' do
1100 get :panel_colors, :id => @other_author.id
1101 response.status.should eq 302
1103 it 'サインインページへ遷移する' do
1104 get :panel_colors, :id => @other_author.id
1105 response.should redirect_to '/users/sign_in'
1109 it 'ステータスコード401 Unauthorizedを返す' do
1110 get :panel_colors, :id => @other_author.id, :format => :json
1111 response.status.should eq 401
1113 it '応答メッセージにUnauthorizedを返す' do
1114 get :panel_colors, :id => @other_author.id, :format => :json
1115 response.message.should match(/Unauthorized/)
1119 context 'ユーザ権限はないが管理者権限があるとき' do
1124 it 'ステータスコード200 OKを返す' do
1125 get :panel_colors, :id => @other_author.id
1126 response.should be_success
1129 context 'ユーザだが作家登録していないとき' do
1133 it 'ステータスコード200 OKを返す' do
1134 get :panel_colors, :id => @other_author.id
1135 response.should be_success
1140 describe '作家数取得に於いて' do
1142 Author.should_receive(:visible_count).and_return(3)
1145 context 'つつがなく終わるとき' do
1146 it 'ステータスコード200 OKを返す' do
1147 get :count, :format => :json
1148 response.should be_success
1152 get :count, :format => :json
1153 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1155 it 'データがHash構造になっていて作家数が3である' do
1156 get :count, :format => :json
1157 json = JSON.parse response.body
1158 json["count"].should == 3
1164 describe '新規作成フォーム表示に於いて' do
1166 @new_user = FactoryGirl.create( :user_yas)
1169 context 'つつがなく終わるとき' do
1170 it 'ステータスコード200 OKを返す' do
1172 response.should be_success
1174 it '@auに新規データを用意している' do
1176 assigns(:au).should be_a_new(Author)
1178 it '作家モデルにデフォルト値補充を依頼している' do
1179 Author.any_instance.should_receive(:supply_default).exactly(1)
1183 it 'newテンプレートを描画する' do
1185 response.should render_template("new")
1189 it 'new.jsテンプレートを描画する' do
1190 get :new, :format => :js
1191 response.should render_template("new")
1196 get :new, :format => :json
1197 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1199 it '作家モデルにjson単体出力オプションを問い合わせている' do
1200 Author.should_receive(:show_json_opt).exactly(1)
1201 get :new, :format => :json
1205 context 'ユーザ権限がないとき' do
1210 it 'ステータスコード302 Foundを返す' do
1212 response.status.should eq 302
1214 it 'サインインページへ遷移する' do
1216 response.body.should redirect_to '/users/sign_in'
1220 it 'ステータスコード401 Unauthorizedを返す' do
1221 get :new, :format => :js
1222 response.status.should eq 401
1224 it '応答メッセージにUnauthorizedを返す' do
1225 get :new, :format => :js
1226 response.message.should match(/Unauthorized/)
1230 it 'ステータスコード401 Unauthorizedを返す' do
1231 get :new, :format => :json
1232 response.status.should eq 401
1234 it '応答メッセージにUnauthorizedを返す' do
1235 get :new, :format => :json
1236 response.message.should match(/Unauthorized/)
1240 context 'ユーザ権限はないが管理者権限があるとき' do
1246 it 'ステータスコード302 Foundを返す' do
1248 response.status.should eq 302
1250 it 'サインインページへ遷移する' do
1252 response.body.should redirect_to '/users/sign_in'
1256 context 'ユーザだが作家登録していないとき' do
1260 it 'ステータスコード200 OKを返す' do
1262 response.should be_success
1267 describe '新規作成に於いて' do
1269 @new_user = FactoryGirl.create( :user_yas)
1271 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1273 context '事前チェックしておく' do
1274 it '作家モデルにデフォルト値補充を依頼している' do
1275 Author.any_instance.should_receive(:supply_default).exactly(1)
1276 post :create, :author => @attr
1278 it '作家モデルにカラム値復元を依頼している' do
1279 Author.any_instance.should_receive(:attributes=).exactly(1)
1280 post :create, :author => @attr
1282 it '作家モデルに上書き補充を依頼している' do
1283 Author.any_instance.should_receive(:overwrite).exactly(1)
1284 post :create, :author => @attr
1287 Author.any_instance.should_receive(:save).exactly(1)
1288 post :create, :author => @attr
1291 context 'つつがなく終わるとき' do
1292 it "@auに作成された作家を保持していて、それがDBにある" do
1293 post :create, :author => @attr
1294 assigns(:au).should be_a(Author)
1295 assigns(:au).should be_persisted
1298 it 'ステータスコード302 Foundを返す' do
1299 Author.any_instance.stub(:save).and_return(true)
1300 post :create, :author => @attr
1301 response.status.should eq 302
1304 # Author.any_instance.stub(:save).and_return(true)
1305 post :create, :author => @attr
1306 response.should redirect_to(root_path)
1310 it 'ステータスコード200 OKを返す' do
1311 # Author.any_instance.stub(:save).and_return(true)
1312 post :create, :author => @attr, :format => :json
1313 response.should be_success
1315 it '作成された作家をjsonデータで返す' do
1316 post :create, :author => @attr, :format => :json
1317 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1319 it '作家モデルにjson単体出力オプションを問い合わせている' do
1320 Author.should_receive(:show_json_opt).exactly(1)
1321 post :create, :author => @attr, :format => :json
1323 it 'データがアレになっている' do
1324 post :create, :author => @attr, :format => :json
1325 json = JSON.parse response.body
1326 json["name"].should match(/ken/)
1330 context 'ユーザ権限がないとき' do
1335 it 'ステータスコード302 Foundを返す' do
1336 post :create, :author => @attr
1337 response.status.should eq 302
1339 it 'サインインページへ遷移する' do
1340 post :create, :author => @attr
1341 response.body.should redirect_to '/users/sign_in'
1345 it 'ステータスコード401 Unauthorizedを返す' do
1346 post :create, :author => @attr, :format => :json
1347 response.status.should eq 401
1349 it '応答メッセージにUnauthorizedを返す' do
1350 post :create, :author => @attr, :format => :json
1351 response.message.should match(/Unauthorized/)
1355 context 'ユーザ権限はないが管理者権限があるとき' do
1361 it 'ステータスコード302 Foundを返す' do
1362 post :create, :author => @attr
1363 response.status.should eq 302
1365 it 'サインインページへ遷移する' do
1366 post :create, :author => @attr
1367 response.body.should redirect_to '/users/sign_in'
1371 context '検証、保存に失敗した' do
1373 Author.any_instance.stub(:save).and_return(false)
1375 it "未保存の作家を保持している" do
1376 post :create, :author => @attr
1377 assigns(:au).should be_a_new(Author)
1380 it 'ステータスコード200 OKを返す' do
1381 post :create, :author => @attr
1382 response.status.should eq 200
1385 post :create, :author => @attr
1386 response.should render_template("new")
1390 it 'ステータスコード422 unprocessable_entity を返す' do
1391 post :create, :author => @attr, :format => :json
1392 response.status.should eq 422
1394 it '応答メッセージUnprocessable Entityを返す' do
1395 post :create, :author => @attr, :format => :json
1396 response.message.should match(/Unprocessable/)
1402 describe '編集フォーム表示に於いて' do
1405 Author.stub(:edit).and_return(@author)
1407 context 'つつがなく終わるとき' do
1408 it 'ステータスコード200 OKを返す' do
1409 get :edit, :id => @author.id
1410 response.should be_success
1412 it '作家モデルに編集取得を問い合わせている' do
1413 Author.should_receive(:edit).exactly(1)
1414 get :edit, :id => @author.id
1416 #@authorだとログイン中のアカウントと干渉してしまう。
1417 it '@auにデータを用意している' do
1418 get :edit, :id => @author.id
1419 assigns(:au).should eq @author
1422 it 'editテンプレートを描画する' do
1423 get :edit, :id => @author.id
1424 response.should render_template("edit")
1428 it 'edit.jsテンプレートを描画する' do
1429 get :edit, :id => @author.id, :format => :js
1430 response.should render_template("edit")
1434 context 'ユーザ権限がないとき' do
1439 it 'ステータスコード302 Foundを返す' do
1440 get :edit, :id => @author.id
1441 response.status.should eq 302
1443 it 'サインインページへ遷移する' do
1444 get :edit, :id => @author.id
1445 response.body.should redirect_to '/users/sign_in'
1449 it 'ステータスコード401 Unauthorizedを返す' do
1450 get :edit, :id => @author.id, :format => :js
1451 response.status.should eq 401
1453 it '応答メッセージにUnauthorizedを返す' do
1454 get :edit, :id => @author.id, :format => :js
1455 response.message.should match(/Unauthorized/)
1459 context 'ユーザ権限はないが管理者権限があるとき' do
1465 it 'ステータスコード302 Foundを返す' do
1466 get :edit, :id => @author.id
1467 response.status.should eq 302
1469 it 'サインインページへ遷移する' do
1470 get :edit, :id => @author.id
1471 response.body.should redirect_to '/users/sign_in'
1475 context 'ユーザだが作家登録していないとき' do
1477 @other_user = FactoryGirl.create( :user_yas)
1478 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1482 it 'ステータスコード302 Foundを返す' do
1483 get :edit, :id => @other_author.id
1484 response.status.should eq 302
1486 it '作家登録ページへ遷移する' do
1487 get :edit, :id => @other_author.id
1488 response.body.should redirect_to new_author_path
1494 describe '更新に於いて' do
1496 @attr = @author.attributes
1497 @attr['name'] = 'ryu'
1500 context '事前チェックしておく' do
1501 it '作家モデルに編集取得を問い合わせている' do
1502 Author.stub(:edit).with(any_args()).and_return @author
1503 Author.should_receive(:edit).exactly(1)
1504 put :update, :id => @author.id, :author => @attr
1506 it 'モデルにpostデータ転送を依頼する' do
1507 Author.any_instance.stub(:attributes=).with(any_args)
1508 Author.any_instance.should_receive(:attributes=).exactly(1)
1509 put :update, :id => @author.id, :author => @attr
1511 it 'モデルに上書き補充を依頼する' do
1512 Author.any_instance.stub(:overwrite).with(any_args)
1513 Author.any_instance.should_receive(:overwrite).exactly(1)
1514 put :update, :id => @author.id, :author => @attr
1517 Author.any_instance.stub(:save).with(any_args).and_return true
1518 Author.any_instance.should_receive(:save).exactly(1)
1519 put :update, :id => @author.id, :author => @attr
1521 it '@auにアレを取得している' do
1522 put :update, :id => @author.id, :author => @attr
1523 assigns(:au).should eq @author
1526 context 'つつがなく終わるとき' do
1528 put :update, :id => @author.id, :author => @attr
1529 Author.find(@author.id).name.should eq 'ryu'
1532 it 'ステータスコード302 Foundを返す' do
1533 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1534 put :update, :id => @author.id, :author => @attr
1535 response.status.should eq 302
1538 put :update, :id => @author.id, :author => @attr
1539 response.should redirect_to('/home/configure')
1543 it 'ステータスコード200 OKを返す' do
1544 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1545 put :update, :id => @author.id, :author => @attr, :format => :json
1546 response.should be_success
1548 it 'ページ本体は特に返さない' do
1549 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1550 put :update, :id => @author.id, :author => @attr, :format => :json
1551 response.body.should match /./
1555 context 'ユーザ権限がないとき' do
1560 it 'ステータスコード302 Foundを返す' do
1561 put :update, :id => @author.id, :author => @attr
1562 response.status.should eq 302
1564 it 'サインインページへ遷移する' do
1565 put :update, :id => @author.id, :author => @attr
1566 response.body.should redirect_to '/users/sign_in'
1570 it '応答メッセージにUnauthorizedを返す' do
1571 put :update, :id => @author.id, :author => @attr, :format => :json
1572 response.message.should match(/Unauthorized/)
1576 context 'ユーザ権限はないが管理者権限があるとき' do
1582 it 'ステータスコード302 Foundを返す' do
1583 put :update, :id => @author.id, :author => @attr
1584 response.status.should eq 302
1586 it 'サインインページへ遷移する' do
1587 put :update, :id => @author.id, :author => @attr
1588 response.body.should redirect_to '/users/sign_in'
1592 context 'ユーザだが作家登録していないとき' do
1594 @other_user = FactoryGirl.create( :user_yas)
1595 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1599 it 'ステータスコード302 Foundを返す' do
1600 get :update, :id => @other_author.id
1601 response.status.should eq 302
1603 it '作家登録ページへ遷移する' do
1604 get :update, :id => @other_author.id
1605 response.body.should redirect_to new_author_path
1609 context '検証、保存に失敗したとき' do
1611 Author.any_instance.stub(:save).and_return(false)
1614 it 'ステータスコード200 Okを返す' do
1615 put :update, :id => @author.id, :author => @attr
1616 response.status.should eq 200
1619 put :update, :id => @author.id, :author => @attr
1620 response.should render_template("edit")
1624 it 'ステータスコード422 unprocessable_entity を返す' do
1625 Author.any_instance.stub(:save).and_return(false)
1626 put :update, :id => @author.id, :author => @attr, :format => :json
1627 response.status.should eq 422
1629 it '応答メッセージUnprocessable Entityを返す' do
1630 put :update, :id => @author.id, :author => @attr, :format => :json
1631 response.message.should match(/Unprocessable/)
1638 describe '一覧表示に於いて' do
1640 Author.stub(:list).and_return([@author, @author, @author])
1643 context 'つつがなく終わるとき' do
1644 it 'ステータスコード200 OKを返す' do
1646 response.should be_success
1649 it 'indexテンプレートを描画する' do
1651 response.should render_template("index")
1656 get :index, :format => :json
1657 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1661 context 'ユーザ権限がないとき' do
1665 it 'ステータスコード200 OKを返す' do
1667 response.should be_success
1670 it 'indexテンプレートを描画する' do
1672 response.should render_template("index")
1677 get :index, :format => :json
1678 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1684 describe '閲覧に於いて' do
1686 Author.stub(:show).and_return(@author)
1689 context 'つつがなく終わるとき' do
1690 it 'ステータスコード200 OKを返す' do
1691 get :show, :id => @author.id
1692 response.should be_success
1695 it 'showテンプレートを描画する' do
1696 get :show, :id => @author.id
1697 response.should render_template("show")
1702 get :show, :id => @author.id, :format => :json
1703 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1707 context 'ユーザ権限がないとき' do
1711 it 'ステータスコード200 OKを返す' do
1712 get :show, :id => @author.id
1713 response.should be_success
1716 it 'showテンプレートを描画する' do
1717 get :show, :id => @author.id
1718 response.should render_template("show")
1723 get :show, :id => @author.id, :format => :json
1724 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1730 describe '対象作家のコミック一覧表示に於いて' do
1732 @other_user = FactoryGirl.create( :user_yas)
1733 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1734 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1735 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
1736 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
1739 context 'つつがなく終わるとき' do
1740 it 'ステータスコード200 OKを返す' do
1741 get :comics, :id => @other_author.id
1742 response.should be_success
1745 it 'comicテンプレートを描画する' do
1746 get :comics, :id => @other_author.id
1747 response.should render_template("comic")
1752 get :comics, :id => @other_author.id, :format => :json
1753 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1757 context 'ユーザ権限がないとき' do
1761 it 'ステータスコード200 OKを返す' do
1762 get :comics, :id => @other_author.id
1763 response.should be_success
1766 it 'comicsテンプレートを描画する' do
1767 get :comics, :id => @other_author.id
1768 response.should render_template("comics")
1773 get :comics, :id => @other_author.id, :format => :json
1774 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1780 describe '対象作家のストーリー一覧表示に於いて' do
1782 @other_user = FactoryGirl.create( :user_yas)
1783 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1784 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1785 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
1786 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1787 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_author.id
1788 Story.stub(:mylist).and_return([@story, @story, @story])
1791 context 'つつがなく終わるとき' do
1792 it 'ステータスコード200 OKを返す' do
1793 get :stories, :id => @other_author.id
1794 response.should be_success
1797 it 'storiesテンプレートを描画する' do
1798 get :stories, :id => @other_author.id
1799 response.should render_template("stories")
1804 get :stories, :id => @other_author.id, :format => :json
1805 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1809 context 'ユーザ権限がないとき' do
1813 it 'ステータスコード200 OKを返す' do
1814 get :stories, :id => @other_author.id
1815 response.should be_success
1818 it 'storiesテンプレートを描画する' do
1819 get :stories, :id => @other_author.id
1820 response.should render_template("stories")
1825 get :stories, :id => @other_author.id, :format => :json
1826 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1832 describe '対象作家のコマ一覧表示に於いて' do
1834 @other_user = FactoryGirl.create( :user_yas)
1835 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1836 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1837 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1838 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
1841 context 'つつがなく終わるとき' do
1842 it 'ステータスコード200 OKを返す' do
1843 get :panels, :id => @other_author.id
1844 response.should be_success
1847 it 'panelsテンプレートを描画する' do
1848 get :panels, :id => @other_author.id
1849 response.should render_template("panels")
1854 get :panels, :id => @other_author.id, :format => :json
1855 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1859 context 'ユーザ権限がないとき' do
1863 it 'ステータスコード200 OKを返す' do
1864 get :panels, :id => @other_author.id
1865 response.should be_success
1868 it 'panelsテンプレートを描画する' do
1869 get :panels, :id => @other_author.id
1870 response.should render_template("panels")
1875 get :panels, :id => @other_author.id, :format => :json
1876 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1882 describe '対象作家のコマ絵一覧表示に於いて' do
1884 @other_user = FactoryGirl.create( :user_yas)
1885 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1886 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1887 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1888 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1889 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1890 @panel = FactoryGirl.create :panel, :author_id => @author.id
1891 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
1892 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
1895 context 'つつがなく終わるとき' do
1896 it 'ステータスコード200 OKを返す' do
1897 get :panel_pictures, :id => @other_author.id
1898 response.should be_success
1901 it 'panel_picturesテンプレートを描画する' do
1902 get :panel_pictures, :id => @other_author.id
1903 response.should render_template("panel_pictures")
1908 get :panel_pictures, :id => @other_author.id, :format => :json
1909 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1913 context 'ユーザ権限がないとき' do
1917 it 'ステータスコード200 OKを返す' do
1918 get :panel_pictures, :id => @other_author.id
1919 response.should be_success
1922 it 'panel_picturesテンプレートを描画する' do
1923 get :panel_pictures, :id => @other_author.id
1924 response.should render_template("panel_pictures")
1929 get :panel_pictures, :id => @other_author.id, :format => :json
1930 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1936 describe '対象作家の絵地一覧表示に於いて' do
1938 @other_user = FactoryGirl.create( :user_yas)
1939 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1940 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1941 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1942 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1943 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1944 @panel = FactoryGirl.create :panel, :author_id => @author.id
1945 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1946 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1949 context 'つつがなく終わるとき' do
1950 it 'ステータスコード200 OKを返す' do
1951 get :ground_pictures, :id => @other_author.id
1952 response.should be_success
1955 it 'ground_picturesテンプレートを描画する' do
1956 get :ground_pictures, :id => @other_author.id
1957 response.should render_template("ground_pictures")
1962 get :ground_pictures, :id => @other_author.id, :format => :json
1963 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1967 context 'ユーザ権限がないとき' do
1972 it 'ground_picturesテンプレートを描画する' do
1973 get :ground_pictures, :id => @other_author.id
1974 response.should render_template("ground_pictures")
1979 get :ground_pictures, :id => @other_author.id, :format => :json
1980 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1986 describe '対象作家の選択色地一覧表示に於いて' do
1988 @other_user = FactoryGirl.create( :user_yas)
1989 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1990 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1991 @color = FactoryGirl.create :color
1992 @gc = FactoryGirl.create :ground_color, :color_id => @color.id
1993 @panel = FactoryGirl.create :panel, :author_id => @author.id
1994 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1997 context 'つつがなく終わるとき' do
1998 it 'ステータスコード200 OKを返す' do
1999 get :ground_colors, :id => @other_author.id
2000 response.should be_success
2003 it 'ground_colorsテンプレートを描画する' do
2004 get :ground_colors, :id => @other_author.id
2005 response.should render_template("ground_colors")
2010 get :ground_colors, :id => @other_author.id, :format => :json
2011 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2015 context 'ユーザ権限がないとき' do
2020 it 'ground_colorsテンプレートを描画する' do
2021 get :ground_colors, :id => @other_author.id
2022 response.should render_template("ground_colors")
2027 get :ground_colors, :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 @panel = FactoryGirl.create :panel, :author_id => @author.id
2040 @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
2041 PanelColor.stub(:himlist).and_return([@pc, @pc, @pc])
2044 context 'つつがなく終わるとき' do
2045 it 'ステータスコード200 OKを返す' do
2046 get :panel_colors, :id => @other_author.id
2047 response.should be_success
2050 it 'panel_colorsテンプレートを描画する' do
2051 get :panel_colors, :id => @other_author.id
2052 response.should render_template("panel_colors")
2057 get :panel_colors, :id => @other_author.id, :format => :json
2058 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2062 context 'ユーザ権限がないとき' do
2067 it 'panel_colorsテンプレートを描画する' do
2068 get :panel_colors, :id => @other_author.id
2069 response.should render_template("panel_colors")
2074 get :panel_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/)