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 '@paginateにページ制御を取得している' do
64 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
66 it 'indexテンプレートを描画する' do
68 response.should render_template("index")
73 get :index, :format => :json
74 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
76 it '作家モデルにjson一覧出力オプションを問い合わせている' do
77 Author.should_receive(:list_json_opt).exactly(1)
78 get :index, :format => :json
80 it 'データがリスト構造になっている' do
81 get :index, :format => :json
82 json = JSON.parse response.body
83 json.should have_at_least(3).items
85 it 'リストの先頭くらいは作家っぽいものであって欲しい' do
86 get :index, :format => :json
87 json = JSON.parse response.body
88 json.first.has_key?("name").should be_true
89 json.first.has_key?("user_id").should be_true
93 context 'ユーザ権限がないとき' do
98 it 'ステータスコード302 Foundを返す' do
100 response.status.should eq 302
102 it 'サインインページへ遷移する' do
104 response.should redirect_to '/users/sign_in'
108 it 'ステータスコード401 Unauthorizedを返す' do
109 get :index, :format => :json
110 response.status.should eq 401
112 it '応答メッセージにUnauthorizedを返す' do
113 get :index, :format => :json
114 response.message.should match(/Unauthorized/)
118 context 'ユーザ権限はないが管理者権限があるとき' do
123 it 'ステータスコード200 OKを返す' do
125 response.should be_success
128 context 'ユーザだが作家登録していないとき' do
132 it 'ステータスコード200 OKを返す' do
134 response.should be_success
141 Author.stub(:show).and_return(@author)
144 context 'つつがなく終わるとき' do
145 it 'ステータスコード200 OKを返す' do
146 get :show, :id => @author.id
147 response.should be_success
149 it '作家モデルに単体取得を問い合わせている' do
150 Author.should_receive(:show).exactly(1)
153 #@authorだとログイン中のアカウントと干渉してしまう。
154 it '@auにアレを取得している' do
155 get :show, :id => @author.id
156 assigns(:au).should eq(@author)
159 it 'showテンプレートを描画する' do
160 get :show, :id => @author.id
161 response.should render_template("show")
166 get :show, :id => @author.id, :format => :json
167 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
169 it '作家モデルにjson単体出力オプションを問い合わせている' do
170 Author.should_receive(:show_json_opt).exactly(1)
171 get :show, :id => @author.id, :format => :json
174 get :show, :id => @author.id, :format => :json
175 json = JSON.parse response.body
176 json["name"].should match(/test/)
177 json["user_id"].should eq @author.user_id
181 context 'ユーザ権限がないとき' do
186 it 'ステータスコード302 Foundを返す' do
187 get :show, :id => @author.id
188 response.status.should eq 302
190 it 'サインインページへ遷移する' do
191 get :show, :id => @author.id
192 response.body.should redirect_to '/users/sign_in'
196 it 'ステータスコード401 Unauthorizedを返す' do
197 get :show, :id => @author.id, :format => :json
198 response.status.should eq 401
200 it '応答メッセージにUnauthorizedを返す' do
201 get :show, :id => @author.id, :format => :json
202 response.message.should match(/Unauthorized/)
206 context 'ユーザ権限はないが管理者権限があるとき' do
211 it 'ステータスコード200 OKを返す' do
212 get :show, :id => @author.id
213 response.should be_success
216 context 'ユーザだが作家登録していないとき' do
220 it 'ステータスコード200 OKを返す' do
221 get :show, :id => @author.id
222 response.should be_success
226 context '対象作家がないとき' do
228 it '例外404 not_foundを返す' do
231 }.should raise_error(ActiveRecord::RecordNotFound)
235 it '例外404 not_foundを返す' do
237 get :show, :id => 0, :format => :json
238 }.should raise_error(ActiveRecord::RecordNotFound)
245 describe '対象作家のコミック一覧表示に於いて' do
247 @other_user = FactoryGirl.create( :user_yas)
248 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
249 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
250 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
251 Author.stub(:show).and_return(@other_author)
252 Comic.stub(:himlist).and_return([@comic, @comic, @comic])
255 context 'パラメータpageについて' do
257 get :comics, :id => @other_author.id, :page => 5
258 assigns(:page).should eq 5
260 it '省略されると@pageに1値が入る' do
261 get :comics, :id => @other_author.id
262 assigns(:page).should eq 1
264 it '与えられたpage_sizeがセットされている' do
265 get :comics, :id => @other_author.id, :page_size => 15
266 assigns(:page_size).should eq 15
268 it '省略されると@page_sizeにデフォルト値が入る' do
269 get :comics, :id => @other_author.id
270 assigns(:page_size).should eq Author.default_comic_page_size
272 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
273 get :comics, :id => @other_author.id, :page_size => 1500
274 assigns(:page_size).should eq Author.comic_max_page_size
276 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
277 get :comics, :id => @other_author.id, :page_size => 0
278 assigns(:page_size).should eq Author.default_comic_page_size
281 context 'つつがなく終わるとき' do
282 it 'ステータスコード200 OKを返す' do
283 get :comics, :id => @other_author.id
284 response.should be_success
286 it '作家モデルに単体取得を問い合わせている' do
287 Author.should_receive(:show).exactly(1)
288 get :comics, :id => @other_author.id
290 it 'コミックモデルに一覧を問い合わせている' do
291 Comic.should_receive(:himlist).exactly(1)
292 get :comics, :id => @other_author.id
294 it '@comicsにリストを取得している' do
295 get :comics, :id => @other_author.id
296 assigns(:comics).should have_at_least(3).items
299 it '@paginateにページ制御を取得している' do
300 get :comics, :id => @other_author.id
301 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
303 it 'comicsテンプレートを描画する' do
304 get :comics, :id => @other_author.id
305 response.should render_template("comics")
310 get :comics, :id => @other_author.id, :format => :json
311 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
313 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
314 Comic.should_receive(:list_json_opt).exactly(1)
315 get :comics, :id => @other_author.id, :format => :json
317 it 'データがリスト構造になっている' do
318 get :comics, :id => @other_author.id, :format => :json
319 json = JSON.parse response.body
320 json.should have_at_least(3).items
322 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
323 get :comics, :id => @other_author.id, :format => :json
324 json = JSON.parse response.body
325 json.first.has_key?("title").should be_true
326 json.first.has_key?("visible").should be_true
330 context 'ユーザ権限がないとき' do
335 it 'ステータスコード302 Foundを返す' do
336 get :comics, :id => @other_author.id
337 response.status.should eq 302
339 it 'サインインページへ遷移する' do
340 get :comics, :id => @other_author.id
341 response.should redirect_to '/users/sign_in'
345 it 'ステータスコード401 Unauthorizedを返す' do
346 get :comics, :id => @other_author.id, :format => :json
347 response.status.should eq 401
349 it '応答メッセージにUnauthorizedを返す' do
350 get :comics, :id => @other_author.id, :format => :json
351 response.message.should match(/Unauthorized/)
355 context 'ユーザ権限はないが管理者権限があるとき' do
360 it 'ステータスコード200 OKを返す' do
361 get :comics, :id => @other_author.id
362 response.should be_success
365 context 'ユーザだが作家登録していないとき' do
369 it 'ステータスコード200 OKを返す' do
370 get :comics, :id => @other_author.id
371 response.should be_success
376 describe '対象作家のストーリー一覧表示に於いて' do
378 @other_user = FactoryGirl.create( :user_yas)
379 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
380 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
381 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
382 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
383 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_user.author.id
384 Author.stub(:show).and_return(@other_author)
385 Story.stub(:himlist).and_return([@story, @story, @story])
388 context 'パラメータpageについて' do
390 get :stories, :id => @other_author.id, :page => 5
391 assigns(:page).should eq 5
393 it '省略されると@pageに1値が入る' do
394 get :stories, :id => @other_author.id
395 assigns(:page).should eq 1
397 it '与えられたpage_sizeがセットされている' do
398 get :stories, :id => @other_author.id, :page_size => 15
399 assigns(:page_size).should eq 15
401 it '省略されると@page_sizeにデフォルト値が入る' do
402 get :stories, :id => @other_author.id
403 assigns(:page_size).should eq Author.default_story_page_size
405 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
406 get :stories, :id => @other_author.id, :page_size => 1500
407 assigns(:page_size).should eq Author.story_max_page_size
409 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
410 get :stories, :id => @other_author.id, :page_size => 0
411 assigns(:page_size).should eq Author.default_story_page_size
414 context 'つつがなく終わるとき' do
415 it 'ステータスコード200 OKを返す' do
416 get :stories, :id => @other_author.id
417 response.should be_success
419 it '作家モデルに単体取得を問い合わせている' do
420 Author.should_receive(:show).exactly(1)
421 get :stories, :id => @other_author.id
423 it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
424 Story.should_receive(:himlist).exactly(1)
425 get :stories, :id => @other_author.id
427 it '@storiesにリストを取得している' do
428 get :stories, :id => @other_author.id
429 assigns(:stories).should have_at_least(3).items
432 it '@paginateにページ制御を取得している' do
433 get :stories, :id => @other_author.id
434 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
436 it 'storiesテンプレートを描画する' do
437 get :stories, :id => @other_author.id
438 response.should render_template("stories")
443 get :stories, :id => @other_author.id, :format => :json
444 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
446 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
447 Story.should_receive(:list_json_opt).exactly(1)
448 get :stories, :id => @other_author.id, :format => :json
450 it 'データがリスト構造になっている' do
451 get :stories, :id => @other_author.id, :format => :json
452 json = JSON.parse response.body
453 json.should have_at_least(3).items
455 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
456 get :stories, :id => @other_author.id, :format => :json
457 json = JSON.parse response.body
458 json.first.has_key?("panel_id").should be_true
459 json.first.has_key?("comic_id").should be_true
460 json.first.has_key?("t").should be_true
464 context 'ユーザ権限がないとき' do
469 it 'ステータスコード302 Foundを返す' do
470 get :stories, :id => @other_author.id
471 response.status.should eq 302
473 it 'サインインページへ遷移する' do
474 get :stories, :id => @other_author.id
475 response.should redirect_to '/users/sign_in'
479 it 'ステータスコード401 Unauthorizedを返す' do
480 get :stories, :id => @other_author.id, :format => :json
481 response.status.should eq 401
483 it '応答メッセージにUnauthorizedを返す' do
484 get :stories, :id => @other_author.id, :format => :json
485 response.message.should match(/Unauthorized/)
489 context 'ユーザ権限はないが管理者権限があるとき' do
494 it 'ステータスコード200 OKを返す' do
495 get :stories, :id => @other_author.id
496 response.should be_success
499 context 'ユーザだが作家登録していないとき' do
503 it 'ステータスコード200 OKを返す' do
504 get :stories, :id => @other_author.id
505 response.should be_success
510 describe '対象作家のコマ一覧表示に於いて' do
512 @other_user = FactoryGirl.create( :user_yas)
513 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
514 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
515 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
516 Author.stub(:show).and_return(@other_author)
517 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
520 context 'パラメータpageについて' do
522 get :panels, :id => @other_author.id, :page => 5
523 assigns(:page).should eq 5
525 it '省略されると@pageに1値が入る' do
526 get :panels, :id => @other_author.id
527 assigns(:page).should eq 1
529 it '与えられたpage_sizeがセットされている' do
530 get :panels, :id => @other_author.id, :page_size => 15
531 assigns(:page_size).should eq 15
533 it '省略されると@page_sizeにデフォルト値が入る' do
534 get :panels, :id => @other_author.id
535 assigns(:page_size).should eq Author.default_panel_page_size
537 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
538 get :panels, :id => @other_author.id, :page_size => 1500
539 assigns(:page_size).should eq Author.panel_max_page_size
541 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
542 get :panels, :id => @other_author.id, :page_size => 0
543 assigns(:page_size).should eq Author.default_panel_page_size
546 context 'つつがなく終わるとき' do
547 it 'ステータスコード200 OKを返す' do
548 get :panels, :id => @other_author.id
549 response.should be_success
551 it '作家モデルに単体取得を問い合わせている' do
552 Author.should_receive(:show).exactly(1)
553 get :panels, :id => @other_author.id
555 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
556 Panel.should_receive(:himlist).exactly(1)
557 get :panels, :id => @other_author.id
559 it '@panelsにリストを取得している' do
560 get :panels, :id => @other_author.id
561 assigns(:panels).should have_at_least(3).items
564 it '@paginateにページ制御を取得している' do
565 get :panels, :id => @other_author.id
566 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
568 it 'panelsテンプレートを描画する' do
569 get :panels, :id => @other_author.id
570 response.should render_template("panels")
575 get :panels, :id => @other_author.id, :format => :json
576 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
578 it 'コマモデルにコマリストのjson出力を問い合わせている' do
579 Panel.should_receive(:list_as_json_text).exactly(1)
580 get :panels, :id => @other_author.id, :format => :json
582 it 'データがリスト構造になっている' do
583 get :panels, :id => @other_author.id, :format => :json
584 json = JSON.parse response.body
585 json.should have_at_least(3).items
587 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
588 get :panels, :id => @other_author.id, :format => :json
589 json = JSON.parse response.body
590 json.first.has_key?("z").should be_true
594 context 'ユーザ権限がないとき' do
599 it 'ステータスコード302 Foundを返す' do
600 get :panels, :id => @other_author.id
601 response.status.should eq 302
603 it 'サインインページへ遷移する' do
604 get :panels, :id => @other_author.id
605 response.should redirect_to '/users/sign_in'
609 it 'ステータスコード401 Unauthorizedを返す' do
610 get :panels, :id => @other_author.id, :format => :json
611 response.status.should eq 401
613 it '応答メッセージにUnauthorizedを返す' do
614 get :panels, :id => @other_author.id, :format => :json
615 response.message.should match(/Unauthorized/)
619 context 'ユーザ権限はないが管理者権限があるとき' do
624 it 'ステータスコード200 OKを返す' do
625 get :panels, :id => @other_author.id
626 response.should be_success
629 context 'ユーザだが作家登録していないとき' do
633 it 'ステータスコード200 OKを返す' do
634 get :panels, :id => @other_author.id
635 response.should be_success
640 describe '対象作家のコマ絵一覧表示に於いて' do
642 @other_user = FactoryGirl.create( :user_yas)
643 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
644 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
645 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
646 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
647 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
648 @panel = FactoryGirl.create :panel, :author_id => @author.id
649 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
650 Author.stub(:show).and_return(@other_author)
651 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
654 context 'パラメータpageについて' do
656 get :panel_pictures, :id => @other_author.id, :page => 5
657 assigns(:page).should eq 5
659 it '省略されると@pageに1値が入る' do
660 get :panel_pictures, :id => @other_author.id
661 assigns(:page).should eq 1
663 it '与えられたpage_sizeがセットされている' do
664 get :panel_pictures, :id => @other_author.id, :page_size => 15
665 assigns(:page_size).should eq 15
667 it '省略されると@page_sizeにデフォルト値が入る' do
668 get :panel_pictures, :id => @other_author.id
669 assigns(:page_size).should eq Author.default_panel_picture_page_size
671 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
672 get :panel_pictures, :id => @other_author.id, :page_size => 1500
673 assigns(:page_size).should eq Author.panel_picture_max_page_size
675 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
676 get :panel_pictures, :id => @other_author.id, :page_size => 0
677 assigns(:page_size).should eq Author.default_panel_picture_page_size
680 context 'つつがなく終わるとき' do
681 it 'ステータスコード200 OKを返す' do
682 get :panel_pictures, :id => @other_author.id
683 response.should be_success
685 it '作家モデルに単体取得を問い合わせている' do
686 Author.should_receive(:show).exactly(1)
687 get :panel_pictures, :id => @other_author.id
689 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
690 PanelPicture.should_receive(:himlist).exactly(1)
691 get :panel_pictures, :id => @other_author.id
693 it '@panel_picturesにリストを取得している' do
694 get :panel_pictures, :id => @other_author.id
695 assigns(:panel_pictures).should have_at_least(3).items
698 it '@paginateにページ制御を取得している' do
699 get :panel_pictures, :id => @other_author.id
700 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
702 it 'panel_picturesテンプレートを描画する' do
703 get :panel_pictures, :id => @other_author.id
704 response.should render_template("panel_pictures")
709 get :panel_pictures, :id => @other_author.id, :format => :json
710 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
712 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
713 PanelPicture.should_receive(:list_json_opt).exactly(1)
714 get :panel_pictures, :id => @other_author.id, :format => :json
716 it 'データがリスト構造になっている' do
717 get :panel_pictures, :id => @other_author.id, :format => :json
718 json = JSON.parse response.body
719 json.should have_at_least(3).items
721 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
722 get :panel_pictures, :id => @other_author.id, :format => :json
723 json = JSON.parse response.body
724 json.first.has_key?("link").should be_true
725 json.first.has_key?("x").should be_true
726 json.first.has_key?("y").should be_true
730 context 'ユーザ権限がないとき' do
735 it 'ステータスコード302 Foundを返す' do
736 get :panel_pictures, :id => @other_author.id
737 response.status.should eq 302
739 it 'サインインページへ遷移する' do
740 get :panel_pictures, :id => @other_author.id
741 response.should redirect_to '/users/sign_in'
745 it 'ステータスコード401 Unauthorizedを返す' do
746 get :panel_pictures, :id => @other_author.id, :format => :json
747 response.status.should eq 401
749 it '応答メッセージにUnauthorizedを返す' do
750 get :panel_pictures, :id => @other_author.id, :format => :json
751 response.message.should match(/Unauthorized/)
755 context 'ユーザ権限はないが管理者権限があるとき' do
760 it 'ステータスコード200 OKを返す' do
761 get :panel_pictures, :id => @other_author.id
762 response.should be_success
765 context 'ユーザだが作家登録していないとき' do
769 it 'ステータスコード200 OKを返す' do
770 get :panel_pictures, :id => @other_author.id
771 response.should be_success
776 describe '対象作家の絵地一覧表示に於いて' do
778 @other_user = FactoryGirl.create( :user_yas)
779 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
780 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
781 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
782 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
783 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
784 @panel = FactoryGirl.create :panel, :author_id => @author.id
785 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
786 Author.stub(:show).and_return(@other_author)
787 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
790 context 'パラメータpageについて' do
792 get :ground_pictures, :id => @other_author.id, :page => 5
793 assigns(:page).should eq 5
795 it '省略されると@pageに1値が入る' do
796 get :ground_pictures, :id => @other_author.id
797 assigns(:page).should eq 1
799 it '与えられたpage_sizeがセットされている' do
800 get :ground_pictures, :id => @other_author.id, :page_size => 15
801 assigns(:page_size).should eq 15
803 it '省略されると@page_sizeにデフォルト値が入る' do
804 get :ground_pictures, :id => @other_author.id
805 assigns(:page_size).should eq Author.default_ground_picture_page_size
807 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
808 get :ground_pictures, :id => @other_author.id, :page_size => 1500
809 assigns(:page_size).should eq Author.ground_picture_max_page_size
811 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
812 get :ground_pictures, :id => @other_author.id, :page_size => 0
813 assigns(:page_size).should eq Author.default_ground_picture_page_size
816 context 'つつがなく終わるとき' do
817 it 'ステータスコード200 OKを返す' do
818 get :ground_pictures, :id => @other_author.id
819 response.should be_success
821 it '作家モデルに単体取得を問い合わせている' do
822 Author.should_receive(:show).exactly(1)
823 get :ground_pictures, :id => @other_author.id
825 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
826 GroundPicture.should_receive(:himlist).exactly(1)
827 get :ground_pictures, :id => @other_author.id
829 it '@ground_picturesにリストを取得している' do
830 get :ground_pictures, :id => @other_author.id
831 assigns(:ground_pictures).should have_at_least(3).items
834 it '@paginateにページ制御を取得している' do
835 get :ground_pictures, :id => @other_author.id
836 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
838 it 'ground_picturesテンプレートを描画する' do
839 get :ground_pictures, :id => @other_author.id
840 response.should render_template("ground_pictures")
845 get :ground_pictures, :id => @other_author.id, :format => :json
846 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
848 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
849 GroundPicture.should_receive(:list_json_opt).exactly(1)
850 get :ground_pictures, :id => @other_author.id, :format => :json
852 it 'データがリスト構造になっている' do
853 get :ground_pictures, :id => @other_author.id, :format => :json
854 json = JSON.parse response.body
855 json.should have_at_least(3).items
857 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
858 get :ground_pictures, :id => @other_author.id, :format => :json
859 json = JSON.parse response.body
860 json.first.has_key?("panel_id").should be_true
861 json.first.has_key?("picture_id").should be_true
862 json.first.has_key?("z").should be_true
866 context 'ユーザ権限がないとき' do
871 it 'ステータスコード302 Foundを返す' do
872 get :ground_pictures, :id => @other_author.id
873 response.status.should eq 302
875 it 'サインインページへ遷移する' do
876 get :ground_pictures, :id => @other_author.id
877 response.should redirect_to '/users/sign_in'
881 it 'ステータスコード401 Unauthorizedを返す' do
882 get :ground_pictures, :id => @other_author.id, :format => :json
883 response.status.should eq 401
885 it '応答メッセージにUnauthorizedを返す' do
886 get :ground_pictures, :id => @other_author.id, :format => :json
887 response.message.should match(/Unauthorized/)
891 context 'ユーザ権限はないが管理者権限があるとき' do
896 it 'ステータスコード200 OKを返す' do
897 get :ground_pictures, :id => @other_author.id
898 response.should be_success
901 context 'ユーザだが作家登録していないとき' do
905 it 'ステータスコード200 OKを返す' do
906 get :ground_pictures, :id => @other_author.id
907 response.should be_success
912 describe '対象作家の色地一覧表示に於いて' do
914 @other_user = FactoryGirl.create( :user_yas)
915 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
916 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
917 @gc = FactoryGirl.create :ground_color
918 @panel = FactoryGirl.create :panel, :author_id => @author.id
919 Author.stub(:show).and_return(@other_author)
920 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
923 context 'パラメータpageについて' do
925 get :ground_colors, :id => @other_author.id, :page => 5
926 assigns(:page).should eq 5
928 it '省略されると@pageに1値が入る' do
929 get :ground_colors, :id => @other_author.id
930 assigns(:page).should eq 1
932 it '与えられたpage_sizeがセットされている' do
933 get :ground_colors, :id => @other_author.id, :page_size => 15
934 assigns(:page_size).should eq 15
936 it '省略されると@page_sizeにデフォルト値が入る' do
937 get :ground_colors, :id => @other_author.id
938 assigns(:page_size).should eq Author.default_ground_color_page_size
940 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
941 get :ground_colors, :id => @other_author.id, :page_size => 1500
942 assigns(:page_size).should eq Author.ground_color_max_page_size
944 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
945 get :ground_colors, :id => @other_author.id, :page_size => 0
946 assigns(:page_size).should eq Author.ground_color_page_size
949 context 'つつがなく終わるとき' do
950 it 'ステータスコード200 OKを返す' do
951 get :ground_colors, :id => @other_author.id
952 response.should be_success
954 it '作家モデルに単体取得を問い合わせている' do
955 Author.should_receive(:show).exactly(1)
956 get :ground_colors, :id => @other_author.id
958 it '色地モデルに他作家の色地一覧を問い合わせている' do
959 GroundColor.should_receive(:himlist).exactly(1)
960 get :ground_colors, :id => @other_author.id
962 it '@ground_colorsにリストを取得している' do
963 get :ground_colors, :id => @other_author.id
964 assigns(:ground_colors).should have_at_least(3).items
967 it '@paginateにページ制御を取得している' do
968 get :ground_colors, :id => @other_author.id
969 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
971 it 'ground_colorsテンプレートを描画する' do
972 get :ground_colors, :id => @other_author.id
973 response.should render_template("ground_colors")
978 get :ground_colors, :id => @other_author.id, :format => :json
979 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
981 it '色地モデルにjson一覧出力オプションを問い合わせている' do
982 GroundColor.should_receive(:list_json_opt).exactly(1)
983 get :ground_colors, :id => @other_author.id, :format => :json
985 it 'データがリスト構造になっている' do
986 get :ground_colors, :id => @other_author.id, :format => :json
987 json = JSON.parse response.body
988 json.should have_at_least(3).items
990 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
991 get :ground_colors, :id => @other_author.id, :format => :json
992 json = JSON.parse response.body
993 json.first.has_key?("panel_id").should be_true
994 json.first.has_key?("code").should be_true
995 json.first.has_key?("z").should be_true
999 context 'ユーザ権限がないとき' do
1004 it 'ステータスコード302 Foundを返す' do
1005 get :ground_colors, :id => @other_author.id
1006 response.status.should eq 302
1008 it 'サインインページへ遷移する' do
1009 get :ground_colors, :id => @other_author.id
1010 response.should redirect_to '/users/sign_in'
1014 it 'ステータスコード401 Unauthorizedを返す' do
1015 get :ground_colors, :id => @other_author.id, :format => :json
1016 response.status.should eq 401
1018 it '応答メッセージにUnauthorizedを返す' do
1019 get :ground_colors, :id => @other_author.id, :format => :json
1020 response.message.should match(/Unauthorized/)
1024 context 'ユーザ権限はないが管理者権限があるとき' do
1029 it 'ステータスコード200 OKを返す' do
1030 get :ground_colors, :id => @other_author.id
1031 response.should be_success
1034 context 'ユーザだが作家登録していないとき' do
1038 it 'ステータスコード200 OKを返す' do
1039 get :ground_colors, :id => @other_author.id
1040 response.should be_success
1045 describe '作家数取得に於いて' do
1047 Author.should_receive(:visible_count).and_return(3)
1050 context 'つつがなく終わるとき' do
1051 it 'ステータスコード200 OKを返す' do
1052 get :count, :format => :json
1053 response.should be_success
1057 get :count, :format => :json
1058 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1060 it 'データがHash構造になっていて作家数が3である' do
1061 get :count, :format => :json
1062 json = JSON.parse response.body
1063 json["count"].should == 3
1069 describe '新規作成フォーム表示に於いて' do
1071 @new_user = FactoryGirl.create( :user_yas)
1074 context 'つつがなく終わるとき' do
1075 it 'ステータスコード200 OKを返す' do
1077 response.should be_success
1079 it '@auに新規データを用意している' do
1081 assigns(:au).should be_a_new(Author)
1083 it '作家モデルにデフォルト値補充を依頼している' do
1084 Author.any_instance.should_receive(:supply_default).exactly(1)
1088 it 'newテンプレートを描画する' do
1090 response.should render_template("new")
1094 it 'new.jsテンプレートを描画する' do
1095 get :new, :format => :js
1096 response.should render_template("new")
1101 get :new, :format => :json
1102 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1104 it '作家モデルにjson単体出力オプションを問い合わせている' do
1105 Author.should_receive(:show_json_opt).exactly(1)
1106 get :new, :format => :json
1110 context 'ユーザ権限がないとき' do
1115 it 'ステータスコード302 Foundを返す' do
1117 response.status.should eq 302
1119 it 'サインインページへ遷移する' do
1121 response.body.should redirect_to '/users/sign_in'
1125 it 'ステータスコード401 Unauthorizedを返す' do
1126 get :new, :format => :js
1127 response.status.should eq 401
1129 it '応答メッセージにUnauthorizedを返す' do
1130 get :new, :format => :js
1131 response.message.should match(/Unauthorized/)
1135 it 'ステータスコード401 Unauthorizedを返す' do
1136 get :new, :format => :json
1137 response.status.should eq 401
1139 it '応答メッセージにUnauthorizedを返す' do
1140 get :new, :format => :json
1141 response.message.should match(/Unauthorized/)
1145 context 'ユーザ権限はないが管理者権限があるとき' do
1151 it 'ステータスコード302 Foundを返す' do
1153 response.status.should eq 302
1155 it 'サインインページへ遷移する' do
1157 response.body.should redirect_to '/users/sign_in'
1161 context 'ユーザだが作家登録していないとき' do
1165 it 'ステータスコード200 OKを返す' do
1167 response.should be_success
1172 describe '新規作成に於いて' do
1174 @new_user = FactoryGirl.create( :user_yas)
1176 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1178 context '事前チェックしておく' do
1179 it '作家モデルにデフォルト値補充を依頼している' do
1180 Author.any_instance.should_receive(:supply_default).exactly(1)
1181 post :create, :author => @attr
1183 it '作家モデルにカラム値復元を依頼している' do
1184 Author.any_instance.should_receive(:attributes=).exactly(1)
1185 post :create, :author => @attr
1187 it '作家モデルに上書き補充を依頼している' do
1188 Author.any_instance.should_receive(:overwrite).exactly(1)
1189 post :create, :author => @attr
1192 Author.any_instance.should_receive(:save).exactly(1)
1193 post :create, :author => @attr
1196 context 'つつがなく終わるとき' do
1197 it "@auに作成された作家を保持していて、それがDBにある" do
1198 post :create, :author => @attr
1199 assigns(:au).should be_a(Author)
1200 assigns(:au).should be_persisted
1203 it 'ステータスコード302 Foundを返す' do
1204 Author.any_instance.stub(:save).and_return(true)
1205 post :create, :author => @attr
1206 response.status.should eq 302
1209 # Author.any_instance.stub(:save).and_return(true)
1210 post :create, :author => @attr
1211 response.should redirect_to(root_path)
1215 it 'ステータスコード200 OKを返す' do
1216 # Author.any_instance.stub(:save).and_return(true)
1217 post :create, :author => @attr, :format => :json
1218 response.should be_success
1220 it '作成された作家をjsonデータで返す' do
1221 post :create, :author => @attr, :format => :json
1222 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1224 it '作家モデルにjson単体出力オプションを問い合わせている' do
1225 Author.should_receive(:show_json_opt).exactly(1)
1226 post :create, :author => @attr, :format => :json
1228 it 'データがアレになっている' do
1229 post :create, :author => @attr, :format => :json
1230 json = JSON.parse response.body
1231 json["name"].should match(/ken/)
1235 context 'ユーザ権限がないとき' do
1240 it 'ステータスコード302 Foundを返す' do
1241 post :create, :author => @attr
1242 response.status.should eq 302
1244 it 'サインインページへ遷移する' do
1245 post :create, :author => @attr
1246 response.body.should redirect_to '/users/sign_in'
1250 it 'ステータスコード401 Unauthorizedを返す' do
1251 post :create, :author => @attr, :format => :json
1252 response.status.should eq 401
1254 it '応答メッセージにUnauthorizedを返す' do
1255 post :create, :author => @attr, :format => :json
1256 response.message.should match(/Unauthorized/)
1260 context 'ユーザ権限はないが管理者権限があるとき' do
1266 it 'ステータスコード302 Foundを返す' do
1267 post :create, :author => @attr
1268 response.status.should eq 302
1270 it 'サインインページへ遷移する' do
1271 post :create, :author => @attr
1272 response.body.should redirect_to '/users/sign_in'
1276 context '検証、保存に失敗した' do
1278 Author.any_instance.stub(:save).and_return(false)
1280 it "未保存の作家を保持している" do
1281 post :create, :author => @attr
1282 assigns(:au).should be_a_new(Author)
1285 it 'ステータスコード200 OKを返す' do
1286 post :create, :author => @attr
1287 response.status.should eq 200
1290 post :create, :author => @attr
1291 response.should render_template("new")
1295 it 'ステータスコード422 unprocessable_entity を返す' do
1296 post :create, :author => @attr, :format => :json
1297 response.status.should eq 422
1299 it '応答メッセージUnprocessable Entityを返す' do
1300 post :create, :author => @attr, :format => :json
1301 response.message.should match(/Unprocessable/)
1307 describe '編集フォーム表示に於いて' do
1310 Author.stub(:edit).and_return(@author)
1312 context 'つつがなく終わるとき' do
1313 it 'ステータスコード200 OKを返す' do
1314 get :edit, :id => @author.id
1315 response.should be_success
1317 it '作家モデルに編集取得を問い合わせている' do
1318 Author.should_receive(:edit).exactly(1)
1319 get :edit, :id => @author.id
1321 #@authorだとログイン中のアカウントと干渉してしまう。
1322 it '@auにデータを用意している' do
1323 get :edit, :id => @author.id
1324 assigns(:au).should eq @author
1327 it 'editテンプレートを描画する' do
1328 get :edit, :id => @author.id
1329 response.should render_template("edit")
1333 it 'edit.jsテンプレートを描画する' do
1334 get :edit, :id => @author.id, :format => :js
1335 response.should render_template("edit")
1339 context 'ユーザ権限がないとき' do
1344 it 'ステータスコード302 Foundを返す' do
1345 get :edit, :id => @author.id
1346 response.status.should eq 302
1348 it 'サインインページへ遷移する' do
1349 get :edit, :id => @author.id
1350 response.body.should redirect_to '/users/sign_in'
1354 it 'ステータスコード401 Unauthorizedを返す' do
1355 get :edit, :id => @author.id, :format => :js
1356 response.status.should eq 401
1358 it '応答メッセージにUnauthorizedを返す' do
1359 get :edit, :id => @author.id, :format => :js
1360 response.message.should match(/Unauthorized/)
1364 context 'ユーザ権限はないが管理者権限があるとき' do
1370 it 'ステータスコード302 Foundを返す' do
1371 get :edit, :id => @author.id
1372 response.status.should eq 302
1374 it 'サインインページへ遷移する' do
1375 get :edit, :id => @author.id
1376 response.body.should redirect_to '/users/sign_in'
1380 context 'ユーザだが作家登録していないとき' do
1382 @other_user = FactoryGirl.create( :user_yas)
1383 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1387 it 'ステータスコード302 Foundを返す' do
1388 get :edit, :id => @other_author.id
1389 response.status.should eq 302
1391 it '作家登録ページへ遷移する' do
1392 get :edit, :id => @other_author.id
1393 response.body.should redirect_to new_author_path
1399 describe '更新に於いて' do
1401 @attr = @author.attributes
1402 @attr['name'] = 'ryu'
1405 context '事前チェックしておく' do
1406 it '作家モデルに編集取得を問い合わせている' do
1407 Author.stub(:edit).with(any_args()).and_return @author
1408 Author.should_receive(:edit).exactly(1)
1409 put :update, :id => @author.id, :author => @attr
1411 it 'モデルにpostデータ転送を依頼する' do
1412 Author.any_instance.stub(:attributes=).with(any_args)
1413 Author.any_instance.should_receive(:attributes=).exactly(1)
1414 put :update, :id => @author.id, :author => @attr
1416 it 'モデルに上書き補充を依頼する' do
1417 Author.any_instance.stub(:overwrite).with(any_args)
1418 Author.any_instance.should_receive(:overwrite).exactly(1)
1419 put :update, :id => @author.id, :author => @attr
1422 Author.any_instance.stub(:save).with(any_args).and_return true
1423 Author.any_instance.should_receive(:save).exactly(1)
1424 put :update, :id => @author.id, :author => @attr
1426 it '@auにアレを取得している' do
1427 put :update, :id => @author.id, :author => @attr
1428 assigns(:au).should eq @author
1431 context 'つつがなく終わるとき' do
1433 put :update, :id => @author.id, :author => @attr
1434 Author.find(@author.id).name.should eq 'ryu'
1437 it 'ステータスコード302 Foundを返す' do
1438 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1439 put :update, :id => @author.id, :author => @attr
1440 response.status.should eq 302
1443 put :update, :id => @author.id, :author => @attr
1444 response.should redirect_to('/home/configure')
1448 it 'ステータスコード200 OKを返す' do
1449 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1450 put :update, :id => @author.id, :author => @attr, :format => :json
1451 response.should be_success
1453 it 'ページ本体は特に返さない' do
1454 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1455 put :update, :id => @author.id, :author => @attr, :format => :json
1456 response.body.should match /./
1460 context 'ユーザ権限がないとき' do
1465 it 'ステータスコード302 Foundを返す' do
1466 put :update, :id => @author.id, :author => @attr
1467 response.status.should eq 302
1469 it 'サインインページへ遷移する' do
1470 put :update, :id => @author.id, :author => @attr
1471 response.body.should redirect_to '/users/sign_in'
1475 it '応答メッセージにUnauthorizedを返す' do
1476 put :update, :id => @author.id, :author => @attr, :format => :json
1477 response.message.should match(/Unauthorized/)
1481 context 'ユーザ権限はないが管理者権限があるとき' do
1487 it 'ステータスコード302 Foundを返す' do
1488 put :update, :id => @author.id, :author => @attr
1489 response.status.should eq 302
1491 it 'サインインページへ遷移する' do
1492 put :update, :id => @author.id, :author => @attr
1493 response.body.should redirect_to '/users/sign_in'
1497 context 'ユーザだが作家登録していないとき' do
1499 @other_user = FactoryGirl.create( :user_yas)
1500 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1504 it 'ステータスコード302 Foundを返す' do
1505 get :update, :id => @other_author.id
1506 response.status.should eq 302
1508 it '作家登録ページへ遷移する' do
1509 get :update, :id => @other_author.id
1510 response.body.should redirect_to new_author_path
1514 context '検証、保存に失敗したとき' do
1516 Author.any_instance.stub(:save).and_return(false)
1519 it 'ステータスコード200 Okを返す' do
1520 put :update, :id => @author.id, :author => @attr
1521 response.status.should eq 200
1524 put :update, :id => @author.id, :author => @attr
1525 response.should render_template("edit")
1529 it 'ステータスコード422 unprocessable_entity を返す' do
1530 Author.any_instance.stub(:save).and_return(false)
1531 put :update, :id => @author.id, :author => @attr, :format => :json
1532 response.status.should eq 422
1534 it '応答メッセージUnprocessable Entityを返す' do
1535 put :update, :id => @author.id, :author => @attr, :format => :json
1536 response.message.should match(/Unprocessable/)
1543 describe '一覧表示に於いて' do
1545 Author.stub(:list).and_return([@author, @author, @author])
1548 context 'つつがなく終わるとき' do
1549 it 'ステータスコード200 OKを返す' do
1551 response.should be_success
1554 it 'indexテンプレートを描画する' do
1556 response.should render_template("index")
1561 get :index, :format => :json
1562 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1566 context 'ユーザ権限がないとき' do
1570 it 'ステータスコード200 OKを返す' do
1572 response.should be_success
1575 it 'indexテンプレートを描画する' do
1577 response.should render_template("index")
1582 get :index, :format => :json
1583 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1589 describe '閲覧に於いて' do
1591 Author.stub(:show).and_return(@author)
1594 context 'つつがなく終わるとき' do
1595 it 'ステータスコード200 OKを返す' do
1596 get :show, :id => @author.id
1597 response.should be_success
1600 it 'showテンプレートを描画する' do
1601 get :show, :id => @author.id
1602 response.should render_template("show")
1607 get :show, :id => @author.id, :format => :json
1608 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1612 context 'ユーザ権限がないとき' do
1616 it 'ステータスコード200 OKを返す' do
1617 get :show, :id => @author.id
1618 response.should be_success
1621 it 'showテンプレートを描画する' do
1622 get :show, :id => @author.id
1623 response.should render_template("show")
1628 get :show, :id => @author.id, :format => :json
1629 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1635 describe '対象作家のコミック一覧表示に於いて' do
1637 @other_user = FactoryGirl.create( :user_yas)
1638 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1639 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1640 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
1641 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
1644 context 'つつがなく終わるとき' do
1645 it 'ステータスコード200 OKを返す' do
1646 get :comics, :id => @other_author.id
1647 response.should be_success
1650 it 'comicテンプレートを描画する' do
1651 get :comics, :id => @other_author.id
1652 response.should render_template("comic")
1657 get :comics, :id => @other_author.id, :format => :json
1658 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1662 context 'ユーザ権限がないとき' do
1666 it 'ステータスコード200 OKを返す' do
1667 get :comics, :id => @other_author.id
1668 response.should be_success
1671 it 'comicsテンプレートを描画する' do
1672 get :comics, :id => @other_author.id
1673 response.should render_template("comics")
1678 get :comics, :id => @other_author.id, :format => :json
1679 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1685 describe '対象作家のストーリー一覧表示に於いて' do
1687 @other_user = FactoryGirl.create( :user_yas)
1688 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1689 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1690 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
1691 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1692 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_author.id
1693 Story.stub(:mylist).and_return([@story, @story, @story])
1696 context 'つつがなく終わるとき' do
1697 it 'ステータスコード200 OKを返す' do
1698 get :stories, :id => @other_author.id
1699 response.should be_success
1702 it 'storiesテンプレートを描画する' do
1703 get :stories, :id => @other_author.id
1704 response.should render_template("stories")
1709 get :stories, :id => @other_author.id, :format => :json
1710 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1714 context 'ユーザ権限がないとき' do
1718 it 'ステータスコード200 OKを返す' do
1719 get :stories, :id => @other_author.id
1720 response.should be_success
1723 it 'storiesテンプレートを描画する' do
1724 get :stories, :id => @other_author.id
1725 response.should render_template("stories")
1730 get :stories, :id => @other_author.id, :format => :json
1731 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1737 describe '対象作家のコマ一覧表示に於いて' do
1739 @other_user = FactoryGirl.create( :user_yas)
1740 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1741 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1742 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1743 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
1746 context 'つつがなく終わるとき' do
1747 it 'ステータスコード200 OKを返す' do
1748 get :panels, :id => @other_author.id
1749 response.should be_success
1752 it 'panelsテンプレートを描画する' do
1753 get :panels, :id => @other_author.id
1754 response.should render_template("panels")
1759 get :panels, :id => @other_author.id, :format => :json
1760 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1764 context 'ユーザ権限がないとき' do
1768 it 'ステータスコード200 OKを返す' do
1769 get :panels, :id => @other_author.id
1770 response.should be_success
1773 it 'panelsテンプレートを描画する' do
1774 get :panels, :id => @other_author.id
1775 response.should render_template("panels")
1780 get :panels, :id => @other_author.id, :format => :json
1781 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1787 describe '対象作家のコマ絵一覧表示に於いて' do
1789 @other_user = FactoryGirl.create( :user_yas)
1790 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1791 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1792 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1793 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1794 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1795 @panel = FactoryGirl.create :panel, :author_id => @author.id
1796 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
1797 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
1800 context 'つつがなく終わるとき' do
1801 it 'ステータスコード200 OKを返す' do
1802 get :panel_pictures, :id => @other_author.id
1803 response.should be_success
1806 it 'panel_picturesテンプレートを描画する' do
1807 get :panel_pictures, :id => @other_author.id
1808 response.should render_template("panel_pictures")
1813 get :panel_pictures, :id => @other_author.id, :format => :json
1814 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1818 context 'ユーザ権限がないとき' do
1822 it 'ステータスコード200 OKを返す' do
1823 get :panel_pictures, :id => @other_author.id
1824 response.should be_success
1827 it 'panel_picturesテンプレートを描画する' do
1828 get :panel_pictures, :id => @other_author.id
1829 response.should render_template("panel_pictures")
1834 get :panel_pictures, :id => @other_author.id, :format => :json
1835 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1841 describe '対象作家の絵地一覧表示に於いて' do
1843 @other_user = FactoryGirl.create( :user_yas)
1844 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1845 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1846 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1847 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1848 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1849 @panel = FactoryGirl.create :panel, :author_id => @author.id
1850 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1851 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1854 context 'つつがなく終わるとき' do
1855 it 'ステータスコード200 OKを返す' do
1856 get :ground_pictures, :id => @other_author.id
1857 response.should be_success
1860 it 'ground_picturesテンプレートを描画する' do
1861 get :ground_pictures, :id => @other_author.id
1862 response.should render_template("ground_pictures")
1867 get :ground_pictures, :id => @other_author.id, :format => :json
1868 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1872 context 'ユーザ権限がないとき' do
1877 it 'ground_picturesテンプレートを描画する' do
1878 get :ground_pictures, :id => @other_author.id
1879 response.should render_template("ground_pictures")
1884 get :ground_pictures, :id => @other_author.id, :format => :json
1885 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1891 describe '対象作家の色地一覧表示に於いて' do
1893 @other_user = FactoryGirl.create( :user_yas)
1894 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1895 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1896 @gc = FactoryGirl.create :ground_color
1897 @panel = FactoryGirl.create :panel, :author_id => @author.id
1898 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1901 context 'つつがなく終わるとき' do
1902 it 'ステータスコード200 OKを返す' do
1903 get :ground_colors, :id => @other_author.id
1904 response.should be_success
1907 it 'ground_colorsテンプレートを描画する' do
1908 get :ground_colors, :id => @other_author.id
1909 response.should render_template("ground_colors")
1914 get :ground_colors, :id => @other_author.id, :format => :json
1915 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1919 context 'ユーザ権限がないとき' do
1924 it 'ground_colorsテンプレートを描画する' do
1925 get :ground_colors, :id => @other_author.id
1926 response.should render_template("ground_colors")
1931 get :ground_colors, :id => @other_author.id, :format => :json
1932 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1938 describe '作家数取得に於いて' do
1940 Author.should_receive(:visible_count).and_return(3)
1943 context 'つつがなく終わるとき' do
1944 it 'ステータスコード200 OKを返す' do
1945 get :count, :format => :json
1946 response.should be_success
1950 get :count, :format => :json
1951 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1957 describe '新規作成フォーム表示に於いて' do
1959 @new_user = FactoryGirl.create( :user_yas)
1962 context 'つつがなく終わるとき' do
1963 it 'ステータスコード200 OKを返す' do
1965 response.should be_success
1968 it 'newテンプレートを描画する' do
1970 response.should render_template("new")
1974 it 'new.jsテンプレートを描画する' do
1975 get :new, :format => :js
1976 response.should render_template("new")
1981 get :new, :format => :json
1982 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1986 context 'ユーザ権限がないとき' do
1991 it 'ステータスコード302 Foundを返す' do
1993 response.status.should eq 302
1995 it 'サインインページへ遷移する' do
1997 response.body.should redirect_to '/users/sign_in'
2001 it 'ステータスコード401 Unauthorizedを返す' do
2002 get :new, :format => :js
2003 response.status.should eq 401
2005 it '応答メッセージにUnauthorizedを返す' do
2006 get :new, :format => :js
2007 response.message.should match(/Unauthorized/)
2011 it 'ステータスコード401 Unauthorizedを返す' do
2012 get :new, :format => :json
2013 response.status.should eq 401
2015 it '応答メッセージにUnauthorizedを返す' do
2016 get :new, :format => :json
2017 response.message.should match(/Unauthorized/)
2023 describe '新規作成に於いて' do
2025 @new_user = FactoryGirl.create( :user_yas)
2027 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
2029 context 'つつがなく終わるとき' do
2031 it 'ステータスコード302 Foundを返す' do
2032 Author.any_instance.stub(:save).and_return(true)
2033 post :create, :author => @attr
2034 response.status.should eq 302
2037 # Author.any_instance.stub(:save).and_return(true)
2038 post :create, :author => @attr
2039 response.should redirect_to(root_path)
2043 it 'ステータスコード200 OKを返す' do
2044 # Author.any_instance.stub(:save).and_return(true)
2045 post :create, :author => @attr, :format => :json
2046 response.should be_success
2050 context 'ユーザ権限がないとき' do
2055 it 'ステータスコード302 Foundを返す' do
2056 post :create, :author => @attr
2057 response.status.should eq 302
2059 it 'サインインページへ遷移する' do
2060 post :create, :author => @attr
2061 response.body.should redirect_to '/users/sign_in'
2065 it 'ステータスコード401 Unauthorizedを返す' do
2066 post :create, :author => @attr, :format => :json
2067 response.status.should eq 401
2069 it '応答メッセージにUnauthorizedを返す' do
2070 post :create, :author => @attr, :format => :json
2071 response.message.should match(/Unauthorized/)
2077 describe '編集フォーム表示に於いて' do
2080 Author.stub(:edit).and_return(@author)
2082 context 'つつがなく終わるとき' do
2083 it 'ステータスコード200 OKを返す' do
2084 get :edit, :id => @author.id
2085 response.should be_success
2088 it 'editテンプレートを描画する' do
2089 get :edit, :id => @author.id
2090 response.should render_template("edit")
2094 it 'edit.jsテンプレートを描画する' do
2095 get :edit, :id => @author.id, :format => :js
2096 response.should render_template("edit")
2100 context 'ユーザ権限がないとき' do
2105 it 'ステータスコード302 Foundを返す' do
2106 get :edit, :id => @author.id
2107 response.status.should eq 302
2109 it 'サインインページへ遷移する' do
2110 get :edit, :id => @author.id
2111 response.body.should redirect_to '/users/sign_in'
2115 it 'ステータスコード401 Unauthorizedを返す' do
2116 get :edit, :id => @author.id, :format => :js
2117 response.status.should eq 401
2119 it '応答メッセージにUnauthorizedを返す' do
2120 get :edit, :id => @author.id, :format => :js
2121 response.message.should match(/Unauthorized/)
2127 describe '更新に於いて' do
2129 @attr = @author.attributes
2130 @attr['name'] = 'ryu'
2133 context 'つつがなく終わるとき' do
2135 put :update, :id => @author.id, :author => @attr
2136 Author.find(@author.id).name.should eq 'ryu'
2139 it 'ステータスコード302 Foundを返す' do
2140 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2141 put :update, :id => @author.id, :author => @attr
2142 response.status.should eq 302
2145 put :update, :id => @author.id, :author => @attr
2146 response.should redirect_to('/home/configure')
2150 it 'ステータスコード200 OKを返す' do
2151 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2152 put :update, :id => @author.id, :author => @attr, :format => :json
2153 response.should be_success
2155 it 'ページ本体は特に返さない' do
2156 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2157 put :update, :id => @author.id, :author => @attr, :format => :json
2158 response.body.should match /./
2162 context 'ユーザ権限がないとき' do
2166 it 'ステータスコード302 Foundを返す' do
2167 put :update, :id => @author.id, :author => @attr
2168 response.status.should eq 302
2171 it 'サインインページへ遷移する' do
2172 put :update, :id => @author.id, :author => @attr
2173 response.body.should redirect_to '/users/sign_in'
2177 it '応答メッセージにUnauthorizedを返す' do
2178 put :update, :id => @author.id, :author => @attr, :format => :json
2179 response.message.should match(/Unauthorized/)