1 # -*- encoding: utf-8 -*-
5 describe AuthorsController do
7 @admin =FactoryGirl.create :admin
8 @sp = FactoryGirl.create :system_picture
9 @lg = FactoryGirl.create :license_group
10 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
11 @speech_balloon_template = FactoryGirl.create :speech_balloon_template
12 @user = FactoryGirl.create( :user_yas)
13 @author = FactoryGirl.create :author, :user_id => @user.id
14 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
17 if MagicNumber['run_mode'] == 1
18 describe '一覧表示に於いて' do
20 Author.stub(:list).and_return([@author, @author, @author])
24 it '与えられたpageがセットされている' do
25 get :index, :page => 5
26 assigns(:page).should eq 5
28 it '省略されると@pageに1値が入る' do
30 assigns(:page).should eq 1
32 it '与えられたpage_sizeがセットされている' do
33 get :index, :page_size => 15
34 assigns(:page_size).should eq 15
36 it '省略されると@page_sizeにデフォルト値が入る' do
38 assigns(:page_size).should eq Author.default_page_size
40 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
41 get :index, :page_size => 1500
42 assigns(:page_size).should eq Author.max_page_size
44 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
45 get :index, :page_size => 0
46 assigns(:page_size).should eq Author.default_page_size
49 context 'つつがなく終わるとき' do
50 it 'ステータスコード200 OKを返す' do
52 response.should be_success
54 it '作家モデルに一覧を問い合わせている' do
55 Author.should_receive(:list).exactly(1)
58 it '@authorsにリストを取得している' do
60 assigns(:authors).should have_at_least(3).items
63 it '@paginateにページ制御を取得している' do
65 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
67 it 'indexテンプレートを描画する' do
69 response.should render_template("index")
74 get :index, :format => :json
75 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
77 it '作家モデルにjson一覧出力オプションを問い合わせている' do
78 Author.should_receive(:list_json_opt).exactly(1)
79 get :index, :format => :json
81 it 'データがリスト構造になっている' do
82 get :index, :format => :json
83 json = JSON.parse response.body
84 json.should have_at_least(3).items
86 it 'リストの先頭くらいは作家っぽいものであって欲しい' do
87 get :index, :format => :json
88 json = JSON.parse response.body
89 json.first.has_key?("name").should be_true
90 json.first.has_key?("user_id").should be_true
94 context 'ユーザ権限がないとき' do
99 it 'ステータスコード302 Foundを返す' do
101 response.status.should eq 302
103 it 'サインインページへ遷移する' do
105 response.should redirect_to '/users/sign_in'
109 it 'ステータスコード401 Unauthorizedを返す' do
110 get :index, :format => :json
111 response.status.should eq 401
113 it '応答メッセージにUnauthorizedを返す' do
114 get :index, :format => :json
115 response.message.should match(/Unauthorized/)
119 context 'ユーザ権限はないが管理者権限があるとき' do
124 it 'ステータスコード200 OKを返す' do
126 response.should be_success
129 context 'ユーザだが作家登録していないとき' do
133 it 'ステータスコード200 OKを返す' do
135 response.should be_success
142 Author.stub(:show).and_return(@author)
145 context 'つつがなく終わるとき' do
146 it 'ステータスコード200 OKを返す' do
147 get :show, :id => @author.id
148 response.should be_success
150 it '作家モデルに単体取得を問い合わせている' do
151 Author.should_receive(:show).exactly(1)
154 #@authorだとログイン中のアカウントと干渉してしまう。
155 it '@auにアレを取得している' do
156 get :show, :id => @author.id
157 assigns(:au).should eq(@author)
160 it 'showテンプレートを描画する' do
161 get :show, :id => @author.id
162 response.should render_template("show")
167 get :show, :id => @author.id, :format => :json
168 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
170 it '作家モデルにjson単体出力オプションを問い合わせている' do
171 Author.should_receive(:show_json_opt).exactly(1)
172 get :show, :id => @author.id, :format => :json
175 get :show, :id => @author.id, :format => :json
176 json = JSON.parse response.body
177 json["name"].should match(/test/)
178 json["user_id"].should eq @author.user_id
182 context 'ユーザ権限がないとき' do
187 it 'ステータスコード302 Foundを返す' do
188 get :show, :id => @author.id
189 response.status.should eq 302
191 it 'サインインページへ遷移する' do
192 get :show, :id => @author.id
193 response.body.should redirect_to '/users/sign_in'
197 it 'ステータスコード401 Unauthorizedを返す' do
198 get :show, :id => @author.id, :format => :json
199 response.status.should eq 401
201 it '応答メッセージにUnauthorizedを返す' do
202 get :show, :id => @author.id, :format => :json
203 response.message.should match(/Unauthorized/)
207 context 'ユーザ権限はないが管理者権限があるとき' do
212 it 'ステータスコード200 OKを返す' do
213 get :show, :id => @author.id
214 response.should be_success
217 context 'ユーザだが作家登録していないとき' do
221 it 'ステータスコード200 OKを返す' do
222 get :show, :id => @author.id
223 response.should be_success
227 context '対象作家がないとき' do
229 it '例外404 not_foundを返す' do
232 }.should raise_error(ActiveRecord::RecordNotFound)
236 it '例外404 not_foundを返す' do
238 get :show, :id => 0, :format => :json
239 }.should raise_error(ActiveRecord::RecordNotFound)
246 describe '対象作家のコミック一覧表示に於いて' do
248 @other_user = FactoryGirl.create( :user_yas)
249 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
250 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
251 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
252 Author.stub(:show).and_return(@other_author)
253 Comic.stub(:himlist).and_return([@comic, @comic, @comic])
256 context 'パラメータpageについて' do
258 get :comics, :id => @other_author.id, :page => 5
259 assigns(:page).should eq 5
261 it '省略されると@pageに1値が入る' do
262 get :comics, :id => @other_author.id
263 assigns(:page).should eq 1
265 it '与えられたpage_sizeがセットされている' do
266 get :comics, :id => @other_author.id, :page_size => 15
267 assigns(:page_size).should eq 15
269 it '省略されると@page_sizeにデフォルト値が入る' do
270 get :comics, :id => @other_author.id
271 assigns(:page_size).should eq Author.default_comic_page_size
273 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
274 get :comics, :id => @other_author.id, :page_size => 1500
275 assigns(:page_size).should eq Author.comic_max_page_size
277 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
278 get :comics, :id => @other_author.id, :page_size => 0
279 assigns(:page_size).should eq Author.default_comic_page_size
282 context 'つつがなく終わるとき' do
283 it 'ステータスコード200 OKを返す' do
284 get :comics, :id => @other_author.id
285 response.should be_success
287 it '作家モデルに単体取得を問い合わせている' do
288 Author.should_receive(:show).exactly(1)
289 get :comics, :id => @other_author.id
291 it 'コミックモデルに一覧を問い合わせている' do
292 Comic.should_receive(:himlist).exactly(1)
293 get :comics, :id => @other_author.id
295 it '@comicsにリストを取得している' do
296 get :comics, :id => @other_author.id
297 assigns(:comics).should have_at_least(3).items
300 it '@paginateにページ制御を取得している' do
301 get :comics, :id => @other_author.id
302 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
304 it 'comicsテンプレートを描画する' do
305 get :comics, :id => @other_author.id
306 response.should render_template("comics")
311 get :comics, :id => @other_author.id, :format => :json
312 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
314 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
315 Comic.should_receive(:list_json_opt).exactly(1)
316 get :comics, :id => @other_author.id, :format => :json
318 it 'データがリスト構造になっている' do
319 get :comics, :id => @other_author.id, :format => :json
320 json = JSON.parse response.body
321 json.should have_at_least(3).items
323 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
324 get :comics, :id => @other_author.id, :format => :json
325 json = JSON.parse response.body
326 json.first.has_key?("title").should be_true
327 json.first.has_key?("visible").should be_true
331 context 'ユーザ権限がないとき' do
336 it 'ステータスコード302 Foundを返す' do
337 get :comics, :id => @other_author.id
338 response.status.should eq 302
340 it 'サインインページへ遷移する' do
341 get :comics, :id => @other_author.id
342 response.should redirect_to '/users/sign_in'
346 it 'ステータスコード401 Unauthorizedを返す' do
347 get :comics, :id => @other_author.id, :format => :json
348 response.status.should eq 401
350 it '応答メッセージにUnauthorizedを返す' do
351 get :comics, :id => @other_author.id, :format => :json
352 response.message.should match(/Unauthorized/)
356 context 'ユーザ権限はないが管理者権限があるとき' do
361 it 'ステータスコード200 OKを返す' do
362 get :comics, :id => @other_author.id
363 response.should be_success
366 context 'ユーザだが作家登録していないとき' do
370 it 'ステータスコード200 OKを返す' do
371 get :comics, :id => @other_author.id
372 response.should be_success
377 describe '対象作家のストーリー一覧表示に於いて' do
379 @other_user = FactoryGirl.create( :user_yas)
380 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
381 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
382 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
383 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
384 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_user.author.id
385 Author.stub(:show).and_return(@other_author)
386 Story.stub(:himlist).and_return([@story, @story, @story])
389 context 'パラメータpageについて' do
391 get :stories, :id => @other_author.id, :page => 5
392 assigns(:page).should eq 5
394 it '省略されると@pageに1値が入る' do
395 get :stories, :id => @other_author.id
396 assigns(:page).should eq 1
398 it '与えられたpage_sizeがセットされている' do
399 get :stories, :id => @other_author.id, :page_size => 15
400 assigns(:page_size).should eq 15
402 it '省略されると@page_sizeにデフォルト値が入る' do
403 get :stories, :id => @other_author.id
404 assigns(:page_size).should eq Author.default_story_page_size
406 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
407 get :stories, :id => @other_author.id, :page_size => 1500
408 assigns(:page_size).should eq Author.story_max_page_size
410 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
411 get :stories, :id => @other_author.id, :page_size => 0
412 assigns(:page_size).should eq Author.default_story_page_size
415 context 'つつがなく終わるとき' do
416 it 'ステータスコード200 OKを返す' do
417 get :stories, :id => @other_author.id
418 response.should be_success
420 it '作家モデルに単体取得を問い合わせている' do
421 Author.should_receive(:show).exactly(1)
422 get :stories, :id => @other_author.id
424 it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
425 Story.should_receive(:himlist).exactly(1)
426 get :stories, :id => @other_author.id
428 it '@storiesにリストを取得している' do
429 get :stories, :id => @other_author.id
430 assigns(:stories).should have_at_least(3).items
433 it '@paginateにページ制御を取得している' do
434 get :stories, :id => @other_author.id
435 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
437 it 'storiesテンプレートを描画する' do
438 get :stories, :id => @other_author.id
439 response.should render_template("stories")
444 get :stories, :id => @other_author.id, :format => :json
445 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
447 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
448 Story.should_receive(:list_json_opt).exactly(1)
449 get :stories, :id => @other_author.id, :format => :json
451 it 'データがリスト構造になっている' do
452 get :stories, :id => @other_author.id, :format => :json
453 json = JSON.parse response.body
454 json.should have_at_least(3).items
456 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
457 get :stories, :id => @other_author.id, :format => :json
458 json = JSON.parse response.body
459 json.first.has_key?("panel_id").should be_true
460 json.first.has_key?("comic_id").should be_true
461 json.first.has_key?("t").should be_true
465 context 'ユーザ権限がないとき' do
470 it 'ステータスコード302 Foundを返す' do
471 get :stories, :id => @other_author.id
472 response.status.should eq 302
474 it 'サインインページへ遷移する' do
475 get :stories, :id => @other_author.id
476 response.should redirect_to '/users/sign_in'
480 it 'ステータスコード401 Unauthorizedを返す' do
481 get :stories, :id => @other_author.id, :format => :json
482 response.status.should eq 401
484 it '応答メッセージにUnauthorizedを返す' do
485 get :stories, :id => @other_author.id, :format => :json
486 response.message.should match(/Unauthorized/)
490 context 'ユーザ権限はないが管理者権限があるとき' do
495 it 'ステータスコード200 OKを返す' do
496 get :stories, :id => @other_author.id
497 response.should be_success
500 context 'ユーザだが作家登録していないとき' do
504 it 'ステータスコード200 OKを返す' do
505 get :stories, :id => @other_author.id
506 response.should be_success
511 describe '対象作家のコマ一覧表示に於いて' do
513 @other_user = FactoryGirl.create( :user_yas)
514 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
515 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
516 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
517 Author.stub(:show).and_return(@other_author)
518 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
521 context 'パラメータpageについて' do
523 get :panels, :id => @other_author.id, :page => 5
524 assigns(:page).should eq 5
526 it '省略されると@pageに1値が入る' do
527 get :panels, :id => @other_author.id
528 assigns(:page).should eq 1
530 it '与えられたpage_sizeがセットされている' do
531 get :panels, :id => @other_author.id, :page_size => 15
532 assigns(:page_size).should eq 15
534 it '省略されると@page_sizeにデフォルト値が入る' do
535 get :panels, :id => @other_author.id
536 assigns(:page_size).should eq Author.default_panel_page_size
538 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
539 get :panels, :id => @other_author.id, :page_size => 1500
540 assigns(:page_size).should eq Author.panel_max_page_size
542 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
543 get :panels, :id => @other_author.id, :page_size => 0
544 assigns(:page_size).should eq Author.default_panel_page_size
547 context 'つつがなく終わるとき' do
548 it 'ステータスコード200 OKを返す' do
549 get :panels, :id => @other_author.id
550 response.should be_success
552 it '作家モデルに単体取得を問い合わせている' do
553 Author.should_receive(:show).exactly(1)
554 get :panels, :id => @other_author.id
556 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
557 Panel.should_receive(:himlist).exactly(1)
558 get :panels, :id => @other_author.id
560 it '@panelsにリストを取得している' do
561 get :panels, :id => @other_author.id
562 assigns(:panels).should have_at_least(3).items
565 it '@paginateにページ制御を取得している' do
566 get :panels, :id => @other_author.id
567 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
569 it 'panelsテンプレートを描画する' do
570 get :panels, :id => @other_author.id
571 response.should render_template("panels")
576 get :panels, :id => @other_author.id, :format => :json
577 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
579 it 'コマモデルにコマリストのjson出力を問い合わせている' do
580 Panel.should_receive(:list_as_json_text).exactly(1)
581 get :panels, :id => @other_author.id, :format => :json
583 it 'データがリスト構造になっている' do
584 get :panels, :id => @other_author.id, :format => :json
585 json = JSON.parse response.body
586 json.should have_at_least(3).items
588 it 'リストの先頭くらいはコマっぽいものであって欲しい' do
589 get :panels, :id => @other_author.id, :format => :json
590 json = JSON.parse response.body
591 json.first.has_key?("z").should be_true
595 context 'ユーザ権限がないとき' do
600 it 'ステータスコード302 Foundを返す' do
601 get :panels, :id => @other_author.id
602 response.status.should eq 302
604 it 'サインインページへ遷移する' do
605 get :panels, :id => @other_author.id
606 response.should redirect_to '/users/sign_in'
610 it 'ステータスコード401 Unauthorizedを返す' do
611 get :panels, :id => @other_author.id, :format => :json
612 response.status.should eq 401
614 it '応答メッセージにUnauthorizedを返す' do
615 get :panels, :id => @other_author.id, :format => :json
616 response.message.should match(/Unauthorized/)
620 context 'ユーザ権限はないが管理者権限があるとき' do
625 it 'ステータスコード200 OKを返す' do
626 get :panels, :id => @other_author.id
627 response.should be_success
630 context 'ユーザだが作家登録していないとき' do
634 it 'ステータスコード200 OKを返す' do
635 get :panels, :id => @other_author.id
636 response.should be_success
641 describe '対象作家のコマ絵一覧表示に於いて' do
643 @other_user = FactoryGirl.create( :user_yas)
644 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
645 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
646 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
647 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
648 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
649 @panel = FactoryGirl.create :panel, :author_id => @author.id
650 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
651 Author.stub(:show).and_return(@other_author)
652 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
655 context 'パラメータpageについて' do
657 get :panel_pictures, :id => @other_author.id, :page => 5
658 assigns(:page).should eq 5
660 it '省略されると@pageに1値が入る' do
661 get :panel_pictures, :id => @other_author.id
662 assigns(:page).should eq 1
664 it '与えられたpage_sizeがセットされている' do
665 get :panel_pictures, :id => @other_author.id, :page_size => 15
666 assigns(:page_size).should eq 15
668 it '省略されると@page_sizeにデフォルト値が入る' do
669 get :panel_pictures, :id => @other_author.id
670 assigns(:page_size).should eq Author.default_panel_picture_page_size
672 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
673 get :panel_pictures, :id => @other_author.id, :page_size => 1500
674 assigns(:page_size).should eq Author.panel_picture_max_page_size
676 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
677 get :panel_pictures, :id => @other_author.id, :page_size => 0
678 assigns(:page_size).should eq Author.default_panel_picture_page_size
681 context 'つつがなく終わるとき' do
682 it 'ステータスコード200 OKを返す' do
683 get :panel_pictures, :id => @other_author.id
684 response.should be_success
686 it '作家モデルに単体取得を問い合わせている' do
687 Author.should_receive(:show).exactly(1)
688 get :panel_pictures, :id => @other_author.id
690 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
691 PanelPicture.should_receive(:himlist).exactly(1)
692 get :panel_pictures, :id => @other_author.id
694 it '@panel_picturesにリストを取得している' do
695 get :panel_pictures, :id => @other_author.id
696 assigns(:panel_pictures).should have_at_least(3).items
699 it '@paginateにページ制御を取得している' do
700 get :panel_pictures, :id => @other_author.id
701 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
703 it 'panel_picturesテンプレートを描画する' do
704 get :panel_pictures, :id => @other_author.id
705 response.should render_template("panel_pictures")
710 get :panel_pictures, :id => @other_author.id, :format => :json
711 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
713 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
714 PanelPicture.should_receive(:list_json_opt).exactly(1)
715 get :panel_pictures, :id => @other_author.id, :format => :json
717 it 'データがリスト構造になっている' do
718 get :panel_pictures, :id => @other_author.id, :format => :json
719 json = JSON.parse response.body
720 json.should have_at_least(3).items
722 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
723 get :panel_pictures, :id => @other_author.id, :format => :json
724 json = JSON.parse response.body
725 json.first.has_key?("link").should be_true
726 json.first.has_key?("x").should be_true
727 json.first.has_key?("y").should be_true
731 context 'ユーザ権限がないとき' do
736 it 'ステータスコード302 Foundを返す' do
737 get :panel_pictures, :id => @other_author.id
738 response.status.should eq 302
740 it 'サインインページへ遷移する' do
741 get :panel_pictures, :id => @other_author.id
742 response.should redirect_to '/users/sign_in'
746 it 'ステータスコード401 Unauthorizedを返す' do
747 get :panel_pictures, :id => @other_author.id, :format => :json
748 response.status.should eq 401
750 it '応答メッセージにUnauthorizedを返す' do
751 get :panel_pictures, :id => @other_author.id, :format => :json
752 response.message.should match(/Unauthorized/)
756 context 'ユーザ権限はないが管理者権限があるとき' do
761 it 'ステータスコード200 OKを返す' do
762 get :panel_pictures, :id => @other_author.id
763 response.should be_success
766 context 'ユーザだが作家登録していないとき' do
770 it 'ステータスコード200 OKを返す' do
771 get :panel_pictures, :id => @other_author.id
772 response.should be_success
777 describe '対象作家のフキダシ一覧表示に於いて' do
779 @other_user = FactoryGirl.create( :user_yas)
780 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
781 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
782 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
783 @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
784 Author.stub(:show).and_return(@other_author)
785 SpeechBalloon.stub(:himlist).and_return([@sb, @sb, @sb])
788 context 'パラメータpageについて' do
790 get :speech_balloons, :id => @other_author.id, :page => 5
791 assigns(:page).should eq 5
793 it '省略されると@pageに1値が入る' do
794 get :speech_balloons, :id => @other_author.id
795 assigns(:page).should eq 1
797 it '与えられたpage_sizeがセットされている' do
798 get :speech_balloons, :id => @other_author.id, :page_size => 15
799 assigns(:page_size).should eq 15
801 it '省略されると@page_sizeにデフォルト値が入る' do
802 get :speech_balloons, :id => @other_author.id
803 assigns(:page_size).should eq Author.default_speech_balloon_page_size
805 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
806 get :speech_balloons, :id => @other_author.id, :page_size => 1500
807 assigns(:page_size).should eq Author.speech_balloon_max_page_size
809 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
810 get :speech_balloons, :id => @other_author.id, :page_size => 0
811 assigns(:page_size).should eq Author.default_speech_balloon_page_size
814 context 'つつがなく終わるとき' do
815 it 'ステータスコード200 OKを返す' do
816 get :speech_balloons, :id => @other_author.id
817 response.should be_success
819 it '作家モデルに単体取得を問い合わせている' do
820 Author.should_receive(:show).exactly(1)
821 get :speech_balloons, :id => @other_author.id
823 it 'フキダシモデルに他作家のフキダシ一覧を問い合わせている' do
824 SpeechBalloon.should_receive(:himlist).exactly(1)
825 get :speech_balloons, :id => @other_author.id
827 it '@speech_balloonsにリストを取得している' do
828 get :speech_balloons, :id => @other_author.id
829 assigns(:speech_balloons).should have_at_least(3).items
832 it '@paginateにページ制御を取得している' do
833 get :speech_balloons, :id => @other_author.id
834 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
836 it 'speech_balloonsテンプレートを描画する' do
837 get :speech_balloons, :id => @other_author.id
838 response.should render_template("speech_balloons")
843 get :speech_balloons, :id => @other_author.id, :format => :json
844 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
846 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
847 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
848 get :speech_balloons, :id => @other_author.id, :format => :json
850 it 'データがリスト構造になっている' do
851 get :speech_balloons, :id => @other_author.id, :format => :json
852 json = JSON.parse response.body
853 json.should have_at_least(3).items
855 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
856 get :speech_balloons, :id => @other_author.id, :format => :json
857 json = JSON.parse response.body
858 json.first.has_key?("speech_balloon_template_id").should be_true
859 json.first.has_key?("z").should be_true
860 json.first.has_key?("t").should be_true
864 context 'ユーザ権限がないとき' do
869 it 'ステータスコード302 Foundを返す' do
870 get :speech_balloons, :id => @other_author.id
871 response.status.should eq 302
873 it 'サインインページへ遷移する' do
874 get :speech_balloons, :id => @other_author.id
875 response.should redirect_to '/users/sign_in'
879 it 'ステータスコード401 Unauthorizedを返す' do
880 get :speech_balloons, :id => @other_author.id, :format => :json
881 response.status.should eq 401
883 it '応答メッセージにUnauthorizedを返す' do
884 get :speech_balloons, :id => @other_author.id, :format => :json
885 response.message.should match(/Unauthorized/)
889 context 'ユーザ権限はないが管理者権限があるとき' do
894 it 'ステータスコード200 OKを返す' do
895 get :speech_balloons, :id => @other_author.id
896 response.should be_success
899 context 'ユーザだが作家登録していないとき' do
903 it 'ステータスコード200 OKを返す' do
904 get :speech_balloons, :id => @other_author.id
905 response.should be_success
910 describe '対象作家の絵地一覧表示に於いて' do
912 @other_user = FactoryGirl.create( :user_yas)
913 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
914 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
915 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
916 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
917 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
918 @panel = FactoryGirl.create :panel, :author_id => @author.id
919 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
920 Author.stub(:show).and_return(@other_author)
921 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
924 context 'パラメータpageについて' do
926 get :ground_pictures, :id => @other_author.id, :page => 5
927 assigns(:page).should eq 5
929 it '省略されると@pageに1値が入る' do
930 get :ground_pictures, :id => @other_author.id
931 assigns(:page).should eq 1
933 it '与えられたpage_sizeがセットされている' do
934 get :ground_pictures, :id => @other_author.id, :page_size => 15
935 assigns(:page_size).should eq 15
937 it '省略されると@page_sizeにデフォルト値が入る' do
938 get :ground_pictures, :id => @other_author.id
939 assigns(:page_size).should eq Author.default_ground_picture_page_size
941 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
942 get :ground_pictures, :id => @other_author.id, :page_size => 1500
943 assigns(:page_size).should eq Author.ground_picture_max_page_size
945 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
946 get :ground_pictures, :id => @other_author.id, :page_size => 0
947 assigns(:page_size).should eq Author.default_ground_picture_page_size
950 context 'つつがなく終わるとき' do
951 it 'ステータスコード200 OKを返す' do
952 get :ground_pictures, :id => @other_author.id
953 response.should be_success
955 it '作家モデルに単体取得を問い合わせている' do
956 Author.should_receive(:show).exactly(1)
957 get :ground_pictures, :id => @other_author.id
959 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
960 GroundPicture.should_receive(:himlist).exactly(1)
961 get :ground_pictures, :id => @other_author.id
963 it '@ground_picturesにリストを取得している' do
964 get :ground_pictures, :id => @other_author.id
965 assigns(:ground_pictures).should have_at_least(3).items
968 it '@paginateにページ制御を取得している' do
969 get :ground_pictures, :id => @other_author.id
970 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
972 it 'ground_picturesテンプレートを描画する' do
973 get :ground_pictures, :id => @other_author.id
974 response.should render_template("ground_pictures")
979 get :ground_pictures, :id => @other_author.id, :format => :json
980 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
982 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
983 GroundPicture.should_receive(:list_json_opt).exactly(1)
984 get :ground_pictures, :id => @other_author.id, :format => :json
986 it 'データがリスト構造になっている' do
987 get :ground_pictures, :id => @other_author.id, :format => :json
988 json = JSON.parse response.body
989 json.should have_at_least(3).items
991 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
992 get :ground_pictures, :id => @other_author.id, :format => :json
993 json = JSON.parse response.body
994 json.first.has_key?("panel_id").should be_true
995 json.first.has_key?("picture_id").should be_true
996 json.first.has_key?("z").should be_true
1000 context 'ユーザ権限がないとき' do
1005 it 'ステータスコード302 Foundを返す' do
1006 get :ground_pictures, :id => @other_author.id
1007 response.status.should eq 302
1009 it 'サインインページへ遷移する' do
1010 get :ground_pictures, :id => @other_author.id
1011 response.should redirect_to '/users/sign_in'
1015 it 'ステータスコード401 Unauthorizedを返す' do
1016 get :ground_pictures, :id => @other_author.id, :format => :json
1017 response.status.should eq 401
1019 it '応答メッセージにUnauthorizedを返す' do
1020 get :ground_pictures, :id => @other_author.id, :format => :json
1021 response.message.should match(/Unauthorized/)
1025 context 'ユーザ権限はないが管理者権限があるとき' do
1030 it 'ステータスコード200 OKを返す' do
1031 get :ground_pictures, :id => @other_author.id
1032 response.should be_success
1035 context 'ユーザだが作家登録していないとき' do
1039 it 'ステータスコード200 OKを返す' do
1040 get :ground_pictures, :id => @other_author.id
1041 response.should be_success
1046 describe '対象作家の色地一覧表示に於いて' do
1048 @other_user = FactoryGirl.create( :user_yas)
1049 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1050 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1051 @gc = FactoryGirl.create :ground_color
1052 @panel = FactoryGirl.create :panel, :author_id => @author.id
1053 Author.stub(:show).and_return(@other_author)
1054 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1057 context 'パラメータpageについて' do
1059 get :ground_colors, :id => @other_author.id, :page => 5
1060 assigns(:page).should eq 5
1062 it '省略されると@pageに1値が入る' do
1063 get :ground_colors, :id => @other_author.id
1064 assigns(:page).should eq 1
1066 it '与えられたpage_sizeがセットされている' do
1067 get :ground_colors, :id => @other_author.id, :page_size => 15
1068 assigns(:page_size).should eq 15
1070 it '省略されると@page_sizeにデフォルト値が入る' do
1071 get :ground_colors, :id => @other_author.id
1072 assigns(:page_size).should eq Author.default_ground_color_page_size
1074 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1075 get :ground_colors, :id => @other_author.id, :page_size => 1500
1076 assigns(:page_size).should eq Author.ground_color_max_page_size
1078 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1079 get :ground_colors, :id => @other_author.id, :page_size => 0
1080 assigns(:page_size).should eq Author.ground_color_page_size
1083 context 'つつがなく終わるとき' do
1084 it 'ステータスコード200 OKを返す' do
1085 get :ground_colors, :id => @other_author.id
1086 response.should be_success
1088 it '作家モデルに単体取得を問い合わせている' do
1089 Author.should_receive(:show).exactly(1)
1090 get :ground_colors, :id => @other_author.id
1092 it '色地モデルに他作家の色地一覧を問い合わせている' do
1093 GroundColor.should_receive(:himlist).exactly(1)
1094 get :ground_colors, :id => @other_author.id
1096 it '@ground_colorsにリストを取得している' do
1097 get :ground_colors, :id => @other_author.id
1098 assigns(:ground_colors).should have_at_least(3).items
1101 it '@paginateにページ制御を取得している' do
1102 get :ground_colors, :id => @other_author.id
1103 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1105 it 'ground_colorsテンプレートを描画する' do
1106 get :ground_colors, :id => @other_author.id
1107 response.should render_template("ground_colors")
1112 get :ground_colors, :id => @other_author.id, :format => :json
1113 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1115 it '色地モデルにjson一覧出力オプションを問い合わせている' do
1116 GroundColor.should_receive(:list_json_opt).exactly(1)
1117 get :ground_colors, :id => @other_author.id, :format => :json
1119 it 'データがリスト構造になっている' do
1120 get :ground_colors, :id => @other_author.id, :format => :json
1121 json = JSON.parse response.body
1122 json.should have_at_least(3).items
1124 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
1125 get :ground_colors, :id => @other_author.id, :format => :json
1126 json = JSON.parse response.body
1127 json.first.has_key?("panel_id").should be_true
1128 json.first.has_key?("code").should be_true
1129 json.first.has_key?("z").should be_true
1133 context 'ユーザ権限がないとき' do
1138 it 'ステータスコード302 Foundを返す' do
1139 get :ground_colors, :id => @other_author.id
1140 response.status.should eq 302
1142 it 'サインインページへ遷移する' do
1143 get :ground_colors, :id => @other_author.id
1144 response.should redirect_to '/users/sign_in'
1148 it 'ステータスコード401 Unauthorizedを返す' do
1149 get :ground_colors, :id => @other_author.id, :format => :json
1150 response.status.should eq 401
1152 it '応答メッセージにUnauthorizedを返す' do
1153 get :ground_colors, :id => @other_author.id, :format => :json
1154 response.message.should match(/Unauthorized/)
1158 context 'ユーザ権限はないが管理者権限があるとき' do
1163 it 'ステータスコード200 OKを返す' do
1164 get :ground_colors, :id => @other_author.id
1165 response.should be_success
1168 context 'ユーザだが作家登録していないとき' do
1172 it 'ステータスコード200 OKを返す' do
1173 get :ground_colors, :id => @other_author.id
1174 response.should be_success
1179 describe '作家数取得に於いて' do
1181 Author.should_receive(:visible_count).and_return(3)
1184 context 'つつがなく終わるとき' do
1185 it 'ステータスコード200 OKを返す' do
1186 get :count, :format => :json
1187 response.should be_success
1191 get :count, :format => :json
1192 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1194 it 'データがHash構造になっていて作家数が3である' do
1195 get :count, :format => :json
1196 json = JSON.parse response.body
1197 json["count"].should == 3
1203 describe '新規作成フォーム表示に於いて' do
1205 @new_user = FactoryGirl.create( :user_yas)
1208 context 'つつがなく終わるとき' do
1209 it 'ステータスコード200 OKを返す' do
1211 response.should be_success
1213 it '@auに新規データを用意している' do
1215 assigns(:au).should be_a_new(Author)
1217 it '作家モデルにデフォルト値補充を依頼している' do
1218 Author.any_instance.should_receive(:supply_default).exactly(1)
1222 it 'newテンプレートを描画する' do
1224 response.should render_template("new")
1228 it 'new.jsテンプレートを描画する' do
1229 get :new, :format => :js
1230 response.should render_template("new")
1235 get :new, :format => :json
1236 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1238 it '作家モデルにjson単体出力オプションを問い合わせている' do
1239 Author.should_receive(:show_json_opt).exactly(1)
1240 get :new, :format => :json
1244 context 'ユーザ権限がないとき' do
1249 it 'ステータスコード302 Foundを返す' do
1251 response.status.should eq 302
1253 it 'サインインページへ遷移する' do
1255 response.body.should redirect_to '/users/sign_in'
1259 it 'ステータスコード401 Unauthorizedを返す' do
1260 get :new, :format => :js
1261 response.status.should eq 401
1263 it '応答メッセージにUnauthorizedを返す' do
1264 get :new, :format => :js
1265 response.message.should match(/Unauthorized/)
1269 it 'ステータスコード401 Unauthorizedを返す' do
1270 get :new, :format => :json
1271 response.status.should eq 401
1273 it '応答メッセージにUnauthorizedを返す' do
1274 get :new, :format => :json
1275 response.message.should match(/Unauthorized/)
1279 context 'ユーザ権限はないが管理者権限があるとき' do
1285 it 'ステータスコード302 Foundを返す' do
1287 response.status.should eq 302
1289 it 'サインインページへ遷移する' do
1291 response.body.should redirect_to '/users/sign_in'
1295 context 'ユーザだが作家登録していないとき' do
1299 it 'ステータスコード200 OKを返す' do
1301 response.should be_success
1306 describe '新規作成に於いて' do
1308 @new_user = FactoryGirl.create( :user_yas)
1310 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1312 context '事前チェックしておく' do
1313 it '作家モデルにデフォルト値補充を依頼している' do
1314 Author.any_instance.should_receive(:supply_default).exactly(1)
1315 post :create, :author => @attr
1317 it '作家モデルにカラム値復元を依頼している' do
1318 Author.any_instance.should_receive(:attributes=).exactly(1)
1319 post :create, :author => @attr
1321 it '作家モデルに上書き補充を依頼している' do
1322 Author.any_instance.should_receive(:overwrite).exactly(1)
1323 post :create, :author => @attr
1326 Author.any_instance.should_receive(:save).exactly(1)
1327 post :create, :author => @attr
1330 context 'つつがなく終わるとき' do
1331 it "@auに作成された作家を保持していて、それがDBにある" do
1332 post :create, :author => @attr
1333 assigns(:au).should be_a(Author)
1334 assigns(:au).should be_persisted
1337 it 'ステータスコード302 Foundを返す' do
1338 Author.any_instance.stub(:save).and_return(true)
1339 post :create, :author => @attr
1340 response.status.should eq 302
1343 # Author.any_instance.stub(:save).and_return(true)
1344 post :create, :author => @attr
1345 response.should redirect_to(root_path)
1349 it 'ステータスコード200 OKを返す' do
1350 # Author.any_instance.stub(:save).and_return(true)
1351 post :create, :author => @attr, :format => :json
1352 response.should be_success
1354 it '作成された作家をjsonデータで返す' do
1355 post :create, :author => @attr, :format => :json
1356 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1358 it '作家モデルにjson単体出力オプションを問い合わせている' do
1359 Author.should_receive(:show_json_opt).exactly(1)
1360 post :create, :author => @attr, :format => :json
1362 it 'データがアレになっている' do
1363 post :create, :author => @attr, :format => :json
1364 json = JSON.parse response.body
1365 json["name"].should match(/ken/)
1369 context 'ユーザ権限がないとき' do
1374 it 'ステータスコード302 Foundを返す' do
1375 post :create, :author => @attr
1376 response.status.should eq 302
1378 it 'サインインページへ遷移する' do
1379 post :create, :author => @attr
1380 response.body.should redirect_to '/users/sign_in'
1384 it 'ステータスコード401 Unauthorizedを返す' do
1385 post :create, :author => @attr, :format => :json
1386 response.status.should eq 401
1388 it '応答メッセージにUnauthorizedを返す' do
1389 post :create, :author => @attr, :format => :json
1390 response.message.should match(/Unauthorized/)
1394 context 'ユーザ権限はないが管理者権限があるとき' do
1400 it 'ステータスコード302 Foundを返す' do
1401 post :create, :author => @attr
1402 response.status.should eq 302
1404 it 'サインインページへ遷移する' do
1405 post :create, :author => @attr
1406 response.body.should redirect_to '/users/sign_in'
1410 context '検証、保存に失敗した' do
1412 Author.any_instance.stub(:save).and_return(false)
1414 it "未保存の作家を保持している" do
1415 post :create, :author => @attr
1416 assigns(:au).should be_a_new(Author)
1419 it 'ステータスコード200 OKを返す' do
1420 post :create, :author => @attr
1421 response.status.should eq 200
1424 post :create, :author => @attr
1425 response.should render_template("new")
1429 it 'ステータスコード422 unprocessable_entity を返す' do
1430 post :create, :author => @attr, :format => :json
1431 response.status.should eq 422
1433 it '応答メッセージUnprocessable Entityを返す' do
1434 post :create, :author => @attr, :format => :json
1435 response.message.should match(/Unprocessable/)
1441 describe '編集フォーム表示に於いて' do
1444 Author.stub(:edit).and_return(@author)
1446 context 'つつがなく終わるとき' do
1447 it 'ステータスコード200 OKを返す' do
1448 get :edit, :id => @author.id
1449 response.should be_success
1451 it '作家モデルに編集取得を問い合わせている' do
1452 Author.should_receive(:edit).exactly(1)
1453 get :edit, :id => @author.id
1455 #@authorだとログイン中のアカウントと干渉してしまう。
1456 it '@auにデータを用意している' do
1457 get :edit, :id => @author.id
1458 assigns(:au).should eq @author
1461 it 'editテンプレートを描画する' do
1462 get :edit, :id => @author.id
1463 response.should render_template("edit")
1467 it 'edit.jsテンプレートを描画する' do
1468 get :edit, :id => @author.id, :format => :js
1469 response.should render_template("edit")
1473 context 'ユーザ権限がないとき' do
1478 it 'ステータスコード302 Foundを返す' do
1479 get :edit, :id => @author.id
1480 response.status.should eq 302
1482 it 'サインインページへ遷移する' do
1483 get :edit, :id => @author.id
1484 response.body.should redirect_to '/users/sign_in'
1488 it 'ステータスコード401 Unauthorizedを返す' do
1489 get :edit, :id => @author.id, :format => :js
1490 response.status.should eq 401
1492 it '応答メッセージにUnauthorizedを返す' do
1493 get :edit, :id => @author.id, :format => :js
1494 response.message.should match(/Unauthorized/)
1498 context 'ユーザ権限はないが管理者権限があるとき' do
1504 it 'ステータスコード302 Foundを返す' do
1505 get :edit, :id => @author.id
1506 response.status.should eq 302
1508 it 'サインインページへ遷移する' do
1509 get :edit, :id => @author.id
1510 response.body.should redirect_to '/users/sign_in'
1514 context 'ユーザだが作家登録していないとき' do
1516 @other_user = FactoryGirl.create( :user_yas)
1517 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1521 it 'ステータスコード302 Foundを返す' do
1522 get :edit, :id => @other_author.id
1523 response.status.should eq 302
1525 it '作家登録ページへ遷移する' do
1526 get :edit, :id => @other_author.id
1527 response.body.should redirect_to new_author_path
1533 describe '更新に於いて' do
1535 @attr = @author.attributes
1536 @attr['name'] = 'ryu'
1539 context '事前チェックしておく' do
1540 it '作家モデルに編集取得を問い合わせている' do
1541 Author.stub(:edit).with(any_args()).and_return @author
1542 Author.should_receive(:edit).exactly(1)
1543 put :update, :id => @author.id, :author => @attr
1545 it 'モデルにpostデータ転送を依頼する' do
1546 Author.any_instance.stub(:attributes=).with(any_args)
1547 Author.any_instance.should_receive(:attributes=).exactly(1)
1548 put :update, :id => @author.id, :author => @attr
1550 it 'モデルに上書き補充を依頼する' do
1551 Author.any_instance.stub(:overwrite).with(any_args)
1552 Author.any_instance.should_receive(:overwrite).exactly(1)
1553 put :update, :id => @author.id, :author => @attr
1556 Author.any_instance.stub(:save).with(any_args).and_return true
1557 Author.any_instance.should_receive(:save).exactly(1)
1558 put :update, :id => @author.id, :author => @attr
1560 it '@auにアレを取得している' do
1561 put :update, :id => @author.id, :author => @attr
1562 assigns(:au).should eq @author
1565 context 'つつがなく終わるとき' do
1567 put :update, :id => @author.id, :author => @attr
1568 Author.find(@author.id).name.should eq 'ryu'
1571 it 'ステータスコード302 Foundを返す' do
1572 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1573 put :update, :id => @author.id, :author => @attr
1574 response.status.should eq 302
1577 put :update, :id => @author.id, :author => @attr
1578 response.should redirect_to('/home/configure')
1582 it 'ステータスコード200 OKを返す' do
1583 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1584 put :update, :id => @author.id, :author => @attr, :format => :json
1585 response.should be_success
1587 it 'ページ本体は特に返さない' do
1588 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1589 put :update, :id => @author.id, :author => @attr, :format => :json
1590 response.body.should match /./
1594 context 'ユーザ権限がないとき' do
1599 it 'ステータスコード302 Foundを返す' do
1600 put :update, :id => @author.id, :author => @attr
1601 response.status.should eq 302
1603 it 'サインインページへ遷移する' do
1604 put :update, :id => @author.id, :author => @attr
1605 response.body.should redirect_to '/users/sign_in'
1609 it '応答メッセージにUnauthorizedを返す' do
1610 put :update, :id => @author.id, :author => @attr, :format => :json
1611 response.message.should match(/Unauthorized/)
1615 context 'ユーザ権限はないが管理者権限があるとき' do
1621 it 'ステータスコード302 Foundを返す' do
1622 put :update, :id => @author.id, :author => @attr
1623 response.status.should eq 302
1625 it 'サインインページへ遷移する' do
1626 put :update, :id => @author.id, :author => @attr
1627 response.body.should redirect_to '/users/sign_in'
1631 context 'ユーザだが作家登録していないとき' do
1633 @other_user = FactoryGirl.create( :user_yas)
1634 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1638 it 'ステータスコード302 Foundを返す' do
1639 get :update, :id => @other_author.id
1640 response.status.should eq 302
1642 it '作家登録ページへ遷移する' do
1643 get :update, :id => @other_author.id
1644 response.body.should redirect_to new_author_path
1648 context '検証、保存に失敗したとき' do
1650 Author.any_instance.stub(:save).and_return(false)
1653 it 'ステータスコード200 Okを返す' do
1654 put :update, :id => @author.id, :author => @attr
1655 response.status.should eq 200
1658 put :update, :id => @author.id, :author => @attr
1659 response.should render_template("edit")
1663 it 'ステータスコード422 unprocessable_entity を返す' do
1664 Author.any_instance.stub(:save).and_return(false)
1665 put :update, :id => @author.id, :author => @attr, :format => :json
1666 response.status.should eq 422
1668 it '応答メッセージUnprocessable Entityを返す' do
1669 put :update, :id => @author.id, :author => @attr, :format => :json
1670 response.message.should match(/Unprocessable/)
1677 describe '一覧表示に於いて' do
1679 Author.stub(:list).and_return([@author, @author, @author])
1682 context 'つつがなく終わるとき' do
1683 it 'ステータスコード200 OKを返す' do
1685 response.should be_success
1688 it 'indexテンプレートを描画する' do
1690 response.should render_template("index")
1695 get :index, :format => :json
1696 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1700 context 'ユーザ権限がないとき' do
1704 it 'ステータスコード200 OKを返す' do
1706 response.should be_success
1709 it 'indexテンプレートを描画する' do
1711 response.should render_template("index")
1716 get :index, :format => :json
1717 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1723 describe '閲覧に於いて' do
1725 Author.stub(:show).and_return(@author)
1728 context 'つつがなく終わるとき' do
1729 it 'ステータスコード200 OKを返す' do
1730 get :show, :id => @author.id
1731 response.should be_success
1734 it 'showテンプレートを描画する' do
1735 get :show, :id => @author.id
1736 response.should render_template("show")
1741 get :show, :id => @author.id, :format => :json
1742 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1746 context 'ユーザ権限がないとき' do
1750 it 'ステータスコード200 OKを返す' do
1751 get :show, :id => @author.id
1752 response.should be_success
1755 it 'showテンプレートを描画する' do
1756 get :show, :id => @author.id
1757 response.should render_template("show")
1762 get :show, :id => @author.id, :format => :json
1763 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1769 describe '対象作家のコミック一覧表示に於いて' do
1771 @other_user = FactoryGirl.create( :user_yas)
1772 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1773 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1774 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
1775 Comic.stub(:mylist).and_return([@comic, @comic, @comic])
1778 context 'つつがなく終わるとき' do
1779 it 'ステータスコード200 OKを返す' do
1780 get :comics, :id => @other_author.id
1781 response.should be_success
1784 it 'comicテンプレートを描画する' do
1785 get :comics, :id => @other_author.id
1786 response.should render_template("comic")
1791 get :comics, :id => @other_author.id, :format => :json
1792 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1796 context 'ユーザ権限がないとき' do
1800 it 'ステータスコード200 OKを返す' do
1801 get :comics, :id => @other_author.id
1802 response.should be_success
1805 it 'comicsテンプレートを描画する' do
1806 get :comics, :id => @other_author.id
1807 response.should render_template("comics")
1812 get :comics, :id => @other_author.id, :format => :json
1813 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1819 describe '対象作家のストーリー一覧表示に於いて' do
1821 @other_user = FactoryGirl.create( :user_yas)
1822 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1823 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1824 @comic = FactoryGirl.create :comic, :author_id => @other_user.author.id
1825 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1826 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @other_author.id
1827 Story.stub(:mylist).and_return([@story, @story, @story])
1830 context 'つつがなく終わるとき' do
1831 it 'ステータスコード200 OKを返す' do
1832 get :stories, :id => @other_author.id
1833 response.should be_success
1836 it 'storiesテンプレートを描画する' do
1837 get :stories, :id => @other_author.id
1838 response.should render_template("stories")
1843 get :stories, :id => @other_author.id, :format => :json
1844 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1848 context 'ユーザ権限がないとき' do
1852 it 'ステータスコード200 OKを返す' do
1853 get :stories, :id => @other_author.id
1854 response.should be_success
1857 it 'storiesテンプレートを描画する' do
1858 get :stories, :id => @other_author.id
1859 response.should render_template("stories")
1864 get :stories, :id => @other_author.id, :format => :json
1865 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1871 describe '対象作家のコマ一覧表示に於いて' do
1873 @other_user = FactoryGirl.create( :user_yas)
1874 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1875 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1876 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1877 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
1880 context 'つつがなく終わるとき' do
1881 it 'ステータスコード200 OKを返す' do
1882 get :panels, :id => @other_author.id
1883 response.should be_success
1886 it 'panelsテンプレートを描画する' do
1887 get :panels, :id => @other_author.id
1888 response.should render_template("panels")
1893 get :panels, :id => @other_author.id, :format => :json
1894 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1898 context 'ユーザ権限がないとき' do
1902 it 'ステータスコード200 OKを返す' do
1903 get :panels, :id => @other_author.id
1904 response.should be_success
1907 it 'panelsテンプレートを描画する' do
1908 get :panels, :id => @other_author.id
1909 response.should render_template("panels")
1914 get :panels, :id => @other_author.id, :format => :json
1915 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1921 describe '対象作家のコマ絵一覧表示に於いて' do
1923 @other_user = FactoryGirl.create( :user_yas)
1924 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1925 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1926 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1927 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1928 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1929 @panel = FactoryGirl.create :panel, :author_id => @author.id
1930 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
1931 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
1934 context 'つつがなく終わるとき' do
1935 it 'ステータスコード200 OKを返す' do
1936 get :panel_pictures, :id => @other_author.id
1937 response.should be_success
1940 it 'panel_picturesテンプレートを描画する' do
1941 get :panel_pictures, :id => @other_author.id
1942 response.should render_template("panel_pictures")
1947 get :panel_pictures, :id => @other_author.id, :format => :json
1948 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1952 context 'ユーザ権限がないとき' do
1956 it 'ステータスコード200 OKを返す' do
1957 get :panel_pictures, :id => @other_author.id
1958 response.should be_success
1961 it 'panel_picturesテンプレートを描画する' do
1962 get :panel_pictures, :id => @other_author.id
1963 response.should render_template("panel_pictures")
1968 get :panel_pictures, :id => @other_author.id, :format => :json
1969 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1975 describe '対象作家の絵地一覧表示に於いて' do
1977 @other_user = FactoryGirl.create( :user_yas)
1978 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1979 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1980 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1981 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1982 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1983 @panel = FactoryGirl.create :panel, :author_id => @author.id
1984 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1985 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1988 context 'つつがなく終わるとき' do
1989 it 'ステータスコード200 OKを返す' do
1990 get :ground_pictures, :id => @other_author.id
1991 response.should be_success
1994 it 'ground_picturesテンプレートを描画する' do
1995 get :ground_pictures, :id => @other_author.id
1996 response.should render_template("ground_pictures")
2001 get :ground_pictures, :id => @other_author.id, :format => :json
2002 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2006 context 'ユーザ権限がないとき' do
2011 it 'ground_picturesテンプレートを描画する' do
2012 get :ground_pictures, :id => @other_author.id
2013 response.should render_template("ground_pictures")
2018 get :ground_pictures, :id => @other_author.id, :format => :json
2019 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2025 describe '対象作家の色地一覧表示に於いて' do
2027 @other_user = FactoryGirl.create( :user_yas)
2028 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2029 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2030 @gc = FactoryGirl.create :ground_color
2031 @panel = FactoryGirl.create :panel, :author_id => @author.id
2032 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
2035 context 'つつがなく終わるとき' do
2036 it 'ステータスコード200 OKを返す' do
2037 get :ground_colors, :id => @other_author.id
2038 response.should be_success
2041 it 'ground_colorsテンプレートを描画する' do
2042 get :ground_colors, :id => @other_author.id
2043 response.should render_template("ground_colors")
2048 get :ground_colors, :id => @other_author.id, :format => :json
2049 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2053 context 'ユーザ権限がないとき' do
2058 it 'ground_colorsテンプレートを描画する' do
2059 get :ground_colors, :id => @other_author.id
2060 response.should render_template("ground_colors")
2065 get :ground_colors, :id => @other_author.id, :format => :json
2066 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2072 describe '作家数取得に於いて' do
2074 Author.should_receive(:visible_count).and_return(3)
2077 context 'つつがなく終わるとき' do
2078 it 'ステータスコード200 OKを返す' do
2079 get :count, :format => :json
2080 response.should be_success
2084 get :count, :format => :json
2085 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2091 describe '新規作成フォーム表示に於いて' do
2093 @new_user = FactoryGirl.create( :user_yas)
2096 context 'つつがなく終わるとき' do
2097 it 'ステータスコード200 OKを返す' do
2099 response.should be_success
2102 it 'newテンプレートを描画する' do
2104 response.should render_template("new")
2108 it 'new.jsテンプレートを描画する' do
2109 get :new, :format => :js
2110 response.should render_template("new")
2115 get :new, :format => :json
2116 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2120 context 'ユーザ権限がないとき' do
2125 it 'ステータスコード302 Foundを返す' do
2127 response.status.should eq 302
2129 it 'サインインページへ遷移する' do
2131 response.body.should redirect_to '/users/sign_in'
2135 it 'ステータスコード401 Unauthorizedを返す' do
2136 get :new, :format => :js
2137 response.status.should eq 401
2139 it '応答メッセージにUnauthorizedを返す' do
2140 get :new, :format => :js
2141 response.message.should match(/Unauthorized/)
2145 it 'ステータスコード401 Unauthorizedを返す' do
2146 get :new, :format => :json
2147 response.status.should eq 401
2149 it '応答メッセージにUnauthorizedを返す' do
2150 get :new, :format => :json
2151 response.message.should match(/Unauthorized/)
2157 describe '新規作成に於いて' do
2159 @new_user = FactoryGirl.create( :user_yas)
2161 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
2163 context 'つつがなく終わるとき' do
2165 it 'ステータスコード302 Foundを返す' do
2166 Author.any_instance.stub(:save).and_return(true)
2167 post :create, :author => @attr
2168 response.status.should eq 302
2171 # Author.any_instance.stub(:save).and_return(true)
2172 post :create, :author => @attr
2173 response.should redirect_to(root_path)
2177 it 'ステータスコード200 OKを返す' do
2178 # Author.any_instance.stub(:save).and_return(true)
2179 post :create, :author => @attr, :format => :json
2180 response.should be_success
2184 context 'ユーザ権限がないとき' do
2189 it 'ステータスコード302 Foundを返す' do
2190 post :create, :author => @attr
2191 response.status.should eq 302
2193 it 'サインインページへ遷移する' do
2194 post :create, :author => @attr
2195 response.body.should redirect_to '/users/sign_in'
2199 it 'ステータスコード401 Unauthorizedを返す' do
2200 post :create, :author => @attr, :format => :json
2201 response.status.should eq 401
2203 it '応答メッセージにUnauthorizedを返す' do
2204 post :create, :author => @attr, :format => :json
2205 response.message.should match(/Unauthorized/)
2211 describe '編集フォーム表示に於いて' do
2214 Author.stub(:edit).and_return(@author)
2216 context 'つつがなく終わるとき' do
2217 it 'ステータスコード200 OKを返す' do
2218 get :edit, :id => @author.id
2219 response.should be_success
2222 it 'editテンプレートを描画する' do
2223 get :edit, :id => @author.id
2224 response.should render_template("edit")
2228 it 'edit.jsテンプレートを描画する' do
2229 get :edit, :id => @author.id, :format => :js
2230 response.should render_template("edit")
2234 context 'ユーザ権限がないとき' do
2239 it 'ステータスコード302 Foundを返す' do
2240 get :edit, :id => @author.id
2241 response.status.should eq 302
2243 it 'サインインページへ遷移する' do
2244 get :edit, :id => @author.id
2245 response.body.should redirect_to '/users/sign_in'
2249 it 'ステータスコード401 Unauthorizedを返す' do
2250 get :edit, :id => @author.id, :format => :js
2251 response.status.should eq 401
2253 it '応答メッセージにUnauthorizedを返す' do
2254 get :edit, :id => @author.id, :format => :js
2255 response.message.should match(/Unauthorized/)
2261 describe '更新に於いて' do
2263 @attr = @author.attributes
2264 @attr['name'] = 'ryu'
2267 context 'つつがなく終わるとき' do
2269 put :update, :id => @author.id, :author => @attr
2270 Author.find(@author.id).name.should eq 'ryu'
2273 it 'ステータスコード302 Foundを返す' do
2274 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2275 put :update, :id => @author.id, :author => @attr
2276 response.status.should eq 302
2279 put :update, :id => @author.id, :author => @attr
2280 response.should redirect_to('/home/configure')
2284 it 'ステータスコード200 OKを返す' do
2285 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2286 put :update, :id => @author.id, :author => @attr, :format => :json
2287 response.should be_success
2289 it 'ページ本体は特に返さない' do
2290 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2291 put :update, :id => @author.id, :author => @attr, :format => :json
2292 response.body.should match /./
2296 context 'ユーザ権限がないとき' do
2300 it 'ステータスコード302 Foundを返す' do
2301 put :update, :id => @author.id, :author => @attr
2302 response.status.should eq 302
2305 it 'サインインページへ遷移する' do
2306 put :update, :id => @author.id, :author => @attr
2307 response.body.should redirect_to '/users/sign_in'
2311 it '応答メッセージにUnauthorizedを返す' do
2312 put :update, :id => @author.id, :author => @attr, :format => :json
2313 response.message.should match(/Unauthorized/)