1 # -*- encoding: utf-8 -*-
5 describe AuthorsController do
7 SpeechBalloonTemplate.delete_all
8 @admin =FactoryGirl.create :admin
9 @sp = FactoryGirl.create :system_picture
10 @lg = FactoryGirl.create :license_group
11 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
12 @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'
13 @writing_format = FactoryGirl.create :writing_format
14 @user = FactoryGirl.create( :user_yas)
15 @author = FactoryGirl.create :author, :user_id => @user.id
16 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
19 if MagicNumber['run_mode'] == 1
20 describe '一覧表示に於いて' do
22 Author.stub(:list).and_return([@author, @author, @author])
26 it '与えられたpageがセットされている' do
27 get :index, :page => 5
28 assigns(:page).should eq 5
30 it '省略されると@pageに1値が入る' do
32 assigns(:page).should eq 1
34 it '与えられたpage_sizeがセットされている' do
35 get :index, :page_size => 15
36 assigns(:page_size).should eq 15
38 it '省略されると@page_sizeにデフォルト値が入る' do
40 assigns(:page_size).should eq Author.default_page_size
42 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
43 get :index, :page_size => 1500
44 assigns(:page_size).should eq Author.max_page_size
46 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
47 get :index, :page_size => 0
48 assigns(:page_size).should eq Author.default_page_size
51 context 'つつがなく終わるとき' do
52 it 'ステータスコード200 OKを返す' do
54 response.should be_success
56 it '作家モデルに一覧を問い合わせている' do
57 Author.should_receive(:list).exactly(1)
60 it '@authorsにリストを取得している' do
62 assigns(:authors).should have_at_least(3).items
65 it '@paginateにページ制御を取得している' do
67 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
69 it 'indexテンプレートを描画する' do
71 response.should render_template("index")
76 get :index, :format => :json
77 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
79 it '作家モデルにjson一覧出力オプションを問い合わせている' do
80 Author.should_receive(:list_json_opt).exactly(1)
81 get :index, :format => :json
83 it 'データがリスト構造になっている' do
84 get :index, :format => :json
85 json = JSON.parse response.body
86 json.should have_at_least(3).items
88 it 'リストの先頭くらいは作家っぽいものであって欲しい' do
89 get :index, :format => :json
90 json = JSON.parse response.body
91 json.first.has_key?("name").should be_true
92 json.first.has_key?("user_id").should be_true
96 context 'ユーザ権限がないとき' do
101 it 'ステータスコード302 Foundを返す' do
103 response.status.should eq 302
105 it 'サインインページへ遷移する' do
107 response.should redirect_to '/users/sign_in'
111 it 'ステータスコード401 Unauthorizedを返す' do
112 get :index, :format => :json
113 response.status.should eq 401
115 it '応答メッセージにUnauthorizedを返す' do
116 get :index, :format => :json
117 response.message.should match(/Unauthorized/)
121 context 'ユーザ権限はないが管理者権限があるとき' do
126 it 'ステータスコード200 OKを返す' do
128 response.should be_success
131 context 'ユーザだが作家登録していないとき' do
135 it 'ステータスコード200 OKを返す' do
137 response.should be_success
144 Author.stub(:show).and_return(@author)
147 context 'つつがなく終わるとき' do
148 it 'ステータスコード200 OKを返す' do
149 get :show, :id => @author.id
150 response.should be_success
152 it '作家モデルに単体取得を問い合わせている' do
153 Author.should_receive(:show).exactly(1)
156 #@authorだとログイン中のアカウントと干渉してしまう。
157 it '@auにアレを取得している' do
158 get :show, :id => @author.id
159 assigns(:au).should eq(@author)
162 it 'showテンプレートを描画する' do
163 get :show, :id => @author.id
164 response.should render_template("show")
169 get :show, :id => @author.id, :format => :json
170 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
172 it '作家モデルにjson単体出力オプションを問い合わせている' do
173 Author.should_receive(:show_json_opt).exactly(1)
174 get :show, :id => @author.id, :format => :json
177 get :show, :id => @author.id, :format => :json
178 json = JSON.parse response.body
179 json["name"].should match(/test/)
180 json["user_id"].should eq @author.user_id
184 context 'ユーザ権限がないとき' do
189 it 'ステータスコード302 Foundを返す' do
190 get :show, :id => @author.id
191 response.status.should eq 302
193 it 'サインインページへ遷移する' do
194 get :show, :id => @author.id
195 response.body.should redirect_to '/users/sign_in'
199 it 'ステータスコード401 Unauthorizedを返す' do
200 get :show, :id => @author.id, :format => :json
201 response.status.should eq 401
203 it '応答メッセージにUnauthorizedを返す' do
204 get :show, :id => @author.id, :format => :json
205 response.message.should match(/Unauthorized/)
209 context 'ユーザ権限はないが管理者権限があるとき' do
214 it 'ステータスコード200 OKを返す' do
215 get :show, :id => @author.id
216 response.should be_success
219 context 'ユーザだが作家登録していないとき' do
223 it 'ステータスコード200 OKを返す' do
224 get :show, :id => @author.id
225 response.should be_success
229 context '対象作家がないとき' do
231 it '例外404 not_foundを返す' do
234 }.should raise_error(ActiveRecord::RecordNotFound)
238 it '例外404 not_foundを返す' do
240 get :show, :id => 0, :format => :json
241 }.should raise_error(ActiveRecord::RecordNotFound)
248 describe '対象作家のコミック一覧表示に於いて' do
250 @other_user = FactoryGirl.create( :user_yas)
251 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
252 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
253 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
254 Author.stub(:show).and_return(@other_author)
255 Scroll.stub(:himlist).and_return([@scroll, @scroll, @scroll])
258 context 'パラメータpageについて' do
260 get :scrolls, :id => @other_author.id, :page => 5
261 assigns(:page).should eq 5
263 it '省略されると@pageに1値が入る' do
264 get :scrolls, :id => @other_author.id
265 assigns(:page).should eq 1
267 it '与えられたpage_sizeがセットされている' do
268 get :scrolls, :id => @other_author.id, :page_size => 15
269 assigns(:page_size).should eq 15
271 it '省略されると@page_sizeにデフォルト値が入る' do
272 get :scrolls, :id => @other_author.id
273 assigns(:page_size).should eq Author.default_scroll_page_size
275 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
276 get :scrolls, :id => @other_author.id, :page_size => 1500
277 assigns(:page_size).should eq Author.scroll_max_page_size
279 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
280 get :scrolls, :id => @other_author.id, :page_size => 0
281 assigns(:page_size).should eq Author.default_scroll_page_size
284 context 'つつがなく終わるとき' do
285 it 'ステータスコード200 OKを返す' do
286 get :scrolls, :id => @other_author.id
287 response.should be_success
289 it '作家モデルに単体取得を問い合わせている' do
290 Author.should_receive(:show).exactly(1)
291 get :scrolls, :id => @other_author.id
293 it 'コミックモデルに一覧を問い合わせている' do
294 Scroll.should_receive(:himlist).exactly(1)
295 get :scrolls, :id => @other_author.id
297 it '@scrollsにリストを取得している' do
298 get :scrolls, :id => @other_author.id
299 assigns(:scrolls).should have_at_least(3).items
302 it '@paginateにページ制御を取得している' do
303 get :scrolls, :id => @other_author.id
304 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
306 it 'scrollsテンプレートを描画する' do
307 get :scrolls, :id => @other_author.id
308 response.should render_template("scrolls")
313 get :scrolls, :id => @other_author.id, :format => :json
314 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
316 it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
317 Scroll.should_receive(:list_json_opt).exactly(1)
318 get :scrolls, :id => @other_author.id, :format => :json
320 it 'データがリスト構造になっている' do
321 get :scrolls, :id => @other_author.id, :format => :json
322 json = JSON.parse response.body
323 json.should have_at_least(3).items
325 it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
326 get :scrolls, :id => @other_author.id, :format => :json
327 json = JSON.parse response.body
328 json.first.has_key?("title").should be_true
329 json.first.has_key?("visible").should be_true
333 context 'ユーザ権限がないとき' do
338 it 'ステータスコード302 Foundを返す' do
339 get :scrolls, :id => @other_author.id
340 response.status.should eq 302
342 it 'サインインページへ遷移する' do
343 get :scrolls, :id => @other_author.id
344 response.should redirect_to '/users/sign_in'
348 it 'ステータスコード401 Unauthorizedを返す' do
349 get :scrolls, :id => @other_author.id, :format => :json
350 response.status.should eq 401
352 it '応答メッセージにUnauthorizedを返す' do
353 get :scrolls, :id => @other_author.id, :format => :json
354 response.message.should match(/Unauthorized/)
358 context 'ユーザ権限はないが管理者権限があるとき' do
363 it 'ステータスコード200 OKを返す' do
364 get :scrolls, :id => @other_author.id
365 response.should be_success
368 context 'ユーザだが作家登録していないとき' do
372 it 'ステータスコード200 OKを返す' do
373 get :scrolls, :id => @other_author.id
374 response.should be_success
379 describe '対象作家のストーリー一覧表示に於いて' do
381 @other_user = FactoryGirl.create( :user_yas)
382 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
383 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
384 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
385 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
386 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_user.author.id
387 Author.stub(:show).and_return(@other_author)
388 ScrollPanel.stub(:himlist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
391 context 'パラメータpageについて' do
393 get :scroll_panels, :id => @other_author.id, :page => 5
394 assigns(:page).should eq 5
396 it '省略されると@pageに1値が入る' do
397 get :scroll_panels, :id => @other_author.id
398 assigns(:page).should eq 1
400 it '与えられたpage_sizeがセットされている' do
401 get :scroll_panels, :id => @other_author.id, :page_size => 15
402 assigns(:page_size).should eq 15
404 it '省略されると@page_sizeにデフォルト値が入る' do
405 get :scroll_panels, :id => @other_author.id
406 assigns(:page_size).should eq Author.default_scroll_panel_page_size
408 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
409 get :scroll_panels, :id => @other_author.id, :page_size => 1500
410 assigns(:page_size).should eq Author.scroll_panel_max_page_size
412 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
413 get :scroll_panels, :id => @other_author.id, :page_size => 0
414 assigns(:page_size).should eq Author.default_scroll_panel_page_size
417 context 'つつがなく終わるとき' do
418 it 'ステータスコード200 OKを返す' do
419 get :scroll_panels, :id => @other_author.id
420 response.should be_success
422 it '作家モデルに単体取得を問い合わせている' do
423 Author.should_receive(:show).exactly(1)
424 get :scroll_panels, :id => @other_author.id
426 it 'ストーリーモデルに他作家のストーリー一覧を問い合わせている' do
427 ScrollPanel.should_receive(:himlist).exactly(1)
428 get :scroll_panels, :id => @other_author.id
430 it '@scroll_panelsにリストを取得している' do
431 get :scroll_panels, :id => @other_author.id
432 assigns(:scroll_panels).should have_at_least(3).items
435 it '@paginateにページ制御を取得している' do
436 get :scroll_panels, :id => @other_author.id
437 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
439 it 'scroll_panelsテンプレートを描画する' do
440 get :scroll_panels, :id => @other_author.id
441 response.should render_template("scroll_panels")
446 get :scroll_panels, :id => @other_author.id, :format => :json
447 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
449 it 'ストーリーモデルにjson一覧出力オプションを問い合わせている' do
450 ScrollPanel.should_receive(:list_json_opt).exactly(1)
451 get :scroll_panels, :id => @other_author.id, :format => :json
453 it 'データがリスト構造になっている' do
454 get :scroll_panels, :id => @other_author.id, :format => :json
455 json = JSON.parse response.body
456 json.should have_at_least(3).items
458 it 'リストの先頭くらいはストーリーっぽいものであって欲しい' do
459 get :scroll_panels, :id => @other_author.id, :format => :json
460 json = JSON.parse response.body
461 json.first.has_key?("panel_id").should be_true
462 json.first.has_key?("scroll_id").should be_true
463 json.first.has_key?("t").should be_true
467 context 'ユーザ権限がないとき' do
472 it 'ステータスコード302 Foundを返す' do
473 get :scroll_panels, :id => @other_author.id
474 response.status.should eq 302
476 it 'サインインページへ遷移する' do
477 get :scroll_panels, :id => @other_author.id
478 response.should redirect_to '/users/sign_in'
482 it 'ステータスコード401 Unauthorizedを返す' do
483 get :scroll_panels, :id => @other_author.id, :format => :json
484 response.status.should eq 401
486 it '応答メッセージにUnauthorizedを返す' do
487 get :scroll_panels, :id => @other_author.id, :format => :json
488 response.message.should match(/Unauthorized/)
492 context 'ユーザ権限はないが管理者権限があるとき' do
497 it 'ステータスコード200 OKを返す' do
498 get :scroll_panels, :id => @other_author.id
499 response.should be_success
502 context 'ユーザだが作家登録していないとき' do
506 it 'ステータスコード200 OKを返す' do
507 get :scroll_panels, :id => @other_author.id
508 response.should be_success
513 describe '対象作家の用紙一覧表示に於いて' do
515 @other_user = FactoryGirl.create( :user_yas)
516 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
517 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
518 @sheet = FactoryGirl.create :sheet, :author_id => @other_user.author.id
519 Author.stub(:show).and_return(@other_author)
520 Sheet.stub(:himlist).and_return([@sheet, @sheet, @sheet])
523 context 'パラメータpageについて' do
525 get :sheets, :id => @other_author.id, :page => 5
526 assigns(:page).should eq 5
528 it '省略されると@pageに1値が入る' do
529 get :sheets, :id => @other_author.id
530 assigns(:page).should eq 1
532 it '与えられたpage_sizeがセットされている' do
533 get :sheets, :id => @other_author.id, :page_size => 15
534 assigns(:page_size).should eq 15
536 it '省略されると@page_sizeにデフォルト値が入る' do
537 get :sheets, :id => @other_author.id
538 assigns(:page_size).should eq Author.default_sheet_page_size
540 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
541 get :sheets, :id => @other_author.id, :page_size => 1500
542 assigns(:page_size).should eq Author.sheet_max_page_size
544 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
545 get :sheets, :id => @other_author.id, :page_size => 0
546 assigns(:page_size).should eq Author.default_sheet_page_size
549 context 'つつがなく終わるとき' do
550 it 'ステータスコード200 OKを返す' do
551 get :sheets, :id => @other_author.id
552 response.should be_success
554 it '作家モデルに単体取得を問い合わせている' do
555 Author.should_receive(:show).exactly(1)
556 get :sheets, :id => @other_author.id
558 it '用紙モデルに一覧を問い合わせている' do
559 Sheet.should_receive(:himlist).exactly(1)
560 get :sheets, :id => @other_author.id
562 it '@sheetsにリストを取得している' do
563 get :sheets, :id => @other_author.id
564 assigns(:sheets).should have_at_least(3).items
567 it '@paginateにページ制御を取得している' do
568 get :sheets, :id => @other_author.id
569 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
571 it 'sheetsテンプレートを描画する' do
572 get :sheets, :id => @other_author.id
573 response.should render_template("sheets")
578 get :sheets, :id => @other_author.id, :format => :json
579 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
581 it '用紙モデルにjson一覧出力オプションを問い合わせている' do
582 Sheet.should_receive(:list_json_opt).exactly(1)
583 get :sheets, :id => @other_author.id, :format => :json
585 it 'データがリスト構造になっている' do
586 get :sheets, :id => @other_author.id, :format => :json
587 json = JSON.parse response.body
588 json.should have_at_least(3).items
590 it 'リストの先頭くらいは用紙っぽいものであって欲しい' do
591 get :sheets, :id => @other_author.id, :format => :json
592 json = JSON.parse response.body
593 json.first.has_key?("caption").should be_true
594 json.first.has_key?("visible").should be_true
598 context 'ユーザ権限がないとき' do
603 it 'ステータスコード302 Foundを返す' do
604 get :sheets, :id => @other_author.id
605 response.status.should eq 302
607 it 'サインインページへ遷移する' do
608 get :sheets, :id => @other_author.id
609 response.should redirect_to '/users/sign_in'
613 it 'ステータスコード401 Unauthorizedを返す' do
614 get :sheets, :id => @other_author.id, :format => :json
615 response.status.should eq 401
617 it '応答メッセージにUnauthorizedを返す' do
618 get :sheets, :id => @other_author.id, :format => :json
619 response.message.should match(/Unauthorized/)
623 context 'ユーザ権限はないが管理者権限があるとき' do
628 it 'ステータスコード200 OKを返す' do
629 get :sheets, :id => @other_author.id
630 response.should be_success
633 context 'ユーザだが作家登録していないとき' do
637 it 'ステータスコード200 OKを返す' do
638 get :sheets, :id => @other_author.id
639 response.should be_success
644 describe '対象作家の紙コマ一覧表示に於いて' do
646 @other_user = FactoryGirl.create( :user_yas)
647 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
648 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
649 @sheet = FactoryGirl.create :sheet, :author_id => @other_user.author.id
650 @panel = FactoryGirl.create :panel, :author_id => @other_user.author.id
651 @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @other_user.author.id
652 Author.stub(:show).and_return(@other_author)
653 SheetPanel.stub(:himlist).and_return([@sheet_panel, @sheet_panel, @sheet_panel])
656 context 'パラメータpageについて' do
658 get :sheet_panels, :id => @other_author.id, :page => 5
659 assigns(:page).should eq 5
661 it '省略されると@pageに1値が入る' do
662 get :sheet_panels, :id => @other_author.id
663 assigns(:page).should eq 1
665 it '与えられたpage_sizeがセットされている' do
666 get :sheet_panels, :id => @other_author.id, :page_size => 15
667 assigns(:page_size).should eq 15
669 it '省略されると@page_sizeにデフォルト値が入る' do
670 get :sheet_panels, :id => @other_author.id
671 assigns(:page_size).should eq Author.default_sheet_panel_page_size
673 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
674 get :sheet_panels, :id => @other_author.id, :page_size => 1500
675 assigns(:page_size).should eq Author.sheet_panel_max_page_size
677 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
678 get :sheet_panels, :id => @other_author.id, :page_size => 0
679 assigns(:page_size).should eq Author.default_sheet_panel_page_size
682 context 'つつがなく終わるとき' do
683 it 'ステータスコード200 OKを返す' do
684 get :sheet_panels, :id => @other_author.id
685 response.should be_success
687 it '作家モデルに単体取得を問い合わせている' do
688 Author.should_receive(:show).exactly(1)
689 get :sheet_panels, :id => @other_author.id
691 it '紙コマモデルに他作家の紙コマ一覧を問い合わせている' do
692 SheetPanel.should_receive(:himlist).exactly(1)
693 get :sheet_panels, :id => @other_author.id
695 it '@sheet_panelsにリストを取得している' do
696 get :sheet_panels, :id => @other_author.id
697 assigns(:sheet_panels).should have_at_least(3).items
700 it '@paginateにページ制御を取得している' do
701 get :sheet_panels, :id => @other_author.id
702 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
704 it 'sheet_panelsテンプレートを描画する' do
705 get :sheet_panels, :id => @other_author.id
706 response.should render_template("sheet_panels")
711 get :sheet_panels, :id => @other_author.id, :format => :json
712 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
714 it '紙コマモデルにjson一覧出力オプションを問い合わせている' do
715 SheetPanel.should_receive(:list_json_opt).exactly(1)
716 get :sheet_panels, :id => @other_author.id, :format => :json
718 it 'データがリスト構造になっている' do
719 get :sheet_panels, :id => @other_author.id, :format => :json
720 json = JSON.parse response.body
721 json.should have_at_least(3).items
723 it 'リストの先頭くらいは紙コマっぽいものであって欲しい' do
724 get :sheet_panels, :id => @other_author.id, :format => :json
725 json = JSON.parse response.body
726 json.first.has_key?("panel_id").should be_true
727 json.first.has_key?("sheet_id").should be_true
728 json.first.has_key?("t").should be_true
732 context 'ユーザ権限がないとき' do
737 it 'ステータスコード302 Foundを返す' do
738 get :sheet_panels, :id => @other_author.id
739 response.status.should eq 302
741 it 'サインインページへ遷移する' do
742 get :sheet_panels, :id => @other_author.id
743 response.should redirect_to '/users/sign_in'
747 it 'ステータスコード401 Unauthorizedを返す' do
748 get :sheet_panels, :id => @other_author.id, :format => :json
749 response.status.should eq 401
751 it '応答メッセージにUnauthorizedを返す' do
752 get :sheet_panels, :id => @other_author.id, :format => :json
753 response.message.should match(/Unauthorized/)
757 context 'ユーザ権限はないが管理者権限があるとき' do
762 it 'ステータスコード200 OKを返す' do
763 get :sheet_panels, :id => @other_author.id
764 response.should be_success
767 context 'ユーザだが作家登録していないとき' do
771 it 'ステータスコード200 OKを返す' do
772 get :sheet_panels, :id => @other_author.id
773 response.should be_success
778 describe '対象作家のコマ一覧表示に於いて' do
780 @other_user = FactoryGirl.create( :user_yas)
781 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
782 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
783 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
784 Author.stub(:show).and_return(@other_author)
785 Panel.stub(:himlist).and_return([@panel, @panel, @panel])
788 context 'パラメータpageについて' do
790 get :panels, :id => @other_author.id, :page => 5
791 assigns(:page).should eq 5
793 it '省略されると@pageに1値が入る' do
794 get :panels, :id => @other_author.id
795 assigns(:page).should eq 1
797 it '与えられたpage_sizeがセットされている' do
798 get :panels, :id => @other_author.id, :page_size => 15
799 assigns(:page_size).should eq 15
801 it '省略されると@page_sizeにデフォルト値が入る' do
802 get :panels, :id => @other_author.id
803 assigns(:page_size).should eq Author.default_panel_page_size
805 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
806 get :panels, :id => @other_author.id, :page_size => 1500
807 assigns(:page_size).should eq Author.panel_max_page_size
809 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
810 get :panels, :id => @other_author.id, :page_size => 0
811 assigns(:page_size).should eq Author.default_panel_page_size
814 context 'つつがなく終わるとき' do
815 it 'ステータスコード200 OKを返す' do
816 get :panels, :id => @other_author.id
817 response.should be_success
819 it '作家モデルに単体取得を問い合わせている' do
820 Author.should_receive(:show).exactly(1)
821 get :panels, :id => @other_author.id
823 it 'コマモデルに他作家のコマ一覧を問い合わせている' do
824 Panel.should_receive(:himlist).exactly(1)
825 get :panels, :id => @other_author.id
827 it '@panelsにリストを取得している' do
828 get :panels, :id => @other_author.id
829 assigns(:panels).should have_at_least(3).items
832 it '@paginateにページ制御を取得している' do
833 get :panels, :id => @other_author.id
834 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
836 it 'panelsテンプレートを描画する' do
837 get :panels, :id => @other_author.id
838 response.should render_template("panels")
843 get :panels, :id => @other_author.id, :format => :json
844 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
846 it 'コマモデルにコマリストのjson出力を問い合わせている' do
847 Panel.should_receive(:list_as_json_text).exactly(1)
848 get :panels, :id => @other_author.id, :format => :json
850 it 'データがリスト構造になっている' do
851 get :panels, :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 :panels, :id => @other_author.id, :format => :json
857 json = JSON.parse response.body
858 json.first.has_key?("z").should be_true
862 context 'ユーザ権限がないとき' do
867 it 'ステータスコード302 Foundを返す' do
868 get :panels, :id => @other_author.id
869 response.status.should eq 302
871 it 'サインインページへ遷移する' do
872 get :panels, :id => @other_author.id
873 response.should redirect_to '/users/sign_in'
877 it 'ステータスコード401 Unauthorizedを返す' do
878 get :panels, :id => @other_author.id, :format => :json
879 response.status.should eq 401
881 it '応答メッセージにUnauthorizedを返す' do
882 get :panels, :id => @other_author.id, :format => :json
883 response.message.should match(/Unauthorized/)
887 context 'ユーザ権限はないが管理者権限があるとき' do
892 it 'ステータスコード200 OKを返す' do
893 get :panels, :id => @other_author.id
894 response.should be_success
897 context 'ユーザだが作家登録していないとき' do
901 it 'ステータスコード200 OKを返す' do
902 get :panels, :id => @other_author.id
903 response.should be_success
908 describe '対象作家のコマ絵一覧表示に於いて' do
910 @other_user = FactoryGirl.create( :user_yas)
911 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
912 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
913 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
914 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
915 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
916 @panel = FactoryGirl.create :panel, :author_id => @author.id
917 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
918 Author.stub(:show).and_return(@other_author)
919 PanelPicture.stub(:himlist).and_return([@panel_picture, @panel_picture, @panel_picture])
922 context 'パラメータpageについて' do
924 get :panel_pictures, :id => @other_author.id, :page => 5
925 assigns(:page).should eq 5
927 it '省略されると@pageに1値が入る' do
928 get :panel_pictures, :id => @other_author.id
929 assigns(:page).should eq 1
931 it '与えられたpage_sizeがセットされている' do
932 get :panel_pictures, :id => @other_author.id, :page_size => 15
933 assigns(:page_size).should eq 15
935 it '省略されると@page_sizeにデフォルト値が入る' do
936 get :panel_pictures, :id => @other_author.id
937 assigns(:page_size).should eq Author.default_panel_picture_page_size
939 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
940 get :panel_pictures, :id => @other_author.id, :page_size => 1500
941 assigns(:page_size).should eq Author.panel_picture_max_page_size
943 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
944 get :panel_pictures, :id => @other_author.id, :page_size => 0
945 assigns(:page_size).should eq Author.default_panel_picture_page_size
948 context 'つつがなく終わるとき' do
949 it 'ステータスコード200 OKを返す' do
950 get :panel_pictures, :id => @other_author.id
951 response.should be_success
953 it '作家モデルに単体取得を問い合わせている' do
954 Author.should_receive(:show).exactly(1)
955 get :panel_pictures, :id => @other_author.id
957 it 'コマ絵モデルに他作家のコマ絵一覧を問い合わせている' do
958 PanelPicture.should_receive(:himlist).exactly(1)
959 get :panel_pictures, :id => @other_author.id
961 it '@panel_picturesにリストを取得している' do
962 get :panel_pictures, :id => @other_author.id
963 assigns(:panel_pictures).should have_at_least(3).items
966 it '@paginateにページ制御を取得している' do
967 get :panel_pictures, :id => @other_author.id
968 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
970 it 'panel_picturesテンプレートを描画する' do
971 get :panel_pictures, :id => @other_author.id
972 response.should render_template("panel_pictures")
977 get :panel_pictures, :id => @other_author.id, :format => :json
978 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
980 it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
981 PanelPicture.should_receive(:list_json_opt).exactly(1)
982 get :panel_pictures, :id => @other_author.id, :format => :json
984 it 'データがリスト構造になっている' do
985 get :panel_pictures, :id => @other_author.id, :format => :json
986 json = JSON.parse response.body
987 json.should have_at_least(3).items
989 it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
990 get :panel_pictures, :id => @other_author.id, :format => :json
991 json = JSON.parse response.body
992 json.first.has_key?("link").should be_true
993 json.first.has_key?("x").should be_true
994 json.first.has_key?("y").should be_true
998 context 'ユーザ権限がないとき' do
1003 it 'ステータスコード302 Foundを返す' do
1004 get :panel_pictures, :id => @other_author.id
1005 response.status.should eq 302
1007 it 'サインインページへ遷移する' do
1008 get :panel_pictures, :id => @other_author.id
1009 response.should redirect_to '/users/sign_in'
1013 it 'ステータスコード401 Unauthorizedを返す' do
1014 get :panel_pictures, :id => @other_author.id, :format => :json
1015 response.status.should eq 401
1017 it '応答メッセージにUnauthorizedを返す' do
1018 get :panel_pictures, :id => @other_author.id, :format => :json
1019 response.message.should match(/Unauthorized/)
1023 context 'ユーザ権限はないが管理者権限があるとき' do
1028 it 'ステータスコード200 OKを返す' do
1029 get :panel_pictures, :id => @other_author.id
1030 response.should be_success
1033 context 'ユーザだが作家登録していないとき' do
1037 it 'ステータスコード200 OKを返す' do
1038 get :panel_pictures, :id => @other_author.id
1039 response.should be_success
1044 describe '対象作家のフキダシ一覧表示に於いて' do
1046 @other_user = FactoryGirl.create( :user_yas)
1047 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1048 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1049 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
1050 @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
1051 @speech = @sb.build_speech(
1052 FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
1054 @balloon = @sb.build_balloon(
1055 FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
1059 Author.stub(:show).and_return(@other_author)
1060 SpeechBalloon.stub(:himlist).and_return([@sb, @sb, @sb])
1063 context 'パラメータpageについて' do
1065 get :speech_balloons, :id => @other_author.id, :page => 5
1066 assigns(:page).should eq 5
1068 it '省略されると@pageに1値が入る' do
1069 get :speech_balloons, :id => @other_author.id
1070 assigns(:page).should eq 1
1072 it '与えられたpage_sizeがセットされている' do
1073 get :speech_balloons, :id => @other_author.id, :page_size => 15
1074 assigns(:page_size).should eq 15
1076 it '省略されると@page_sizeにデフォルト値が入る' do
1077 get :speech_balloons, :id => @other_author.id
1078 assigns(:page_size).should eq Author.default_speech_balloon_page_size
1080 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1081 get :speech_balloons, :id => @other_author.id, :page_size => 1500
1082 assigns(:page_size).should eq Author.speech_balloon_max_page_size
1084 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1085 get :speech_balloons, :id => @other_author.id, :page_size => 0
1086 assigns(:page_size).should eq Author.default_speech_balloon_page_size
1089 context 'つつがなく終わるとき' do
1090 it 'ステータスコード200 OKを返す' do
1091 get :speech_balloons, :id => @other_author.id
1092 response.should be_success
1094 it '作家モデルに単体取得を問い合わせている' do
1095 Author.should_receive(:show).exactly(1)
1096 get :speech_balloons, :id => @other_author.id
1098 it 'フキダシモデルに他作家のフキダシ一覧を問い合わせている' do
1099 SpeechBalloon.should_receive(:himlist).exactly(1)
1100 get :speech_balloons, :id => @other_author.id
1102 it '@speech_balloonsにリストを取得している' do
1103 get :speech_balloons, :id => @other_author.id
1104 assigns(:speech_balloons).should have_at_least(3).items
1107 it '@paginateにページ制御を取得している' do
1108 get :speech_balloons, :id => @other_author.id
1109 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1111 it 'speech_balloonsテンプレートを描画する' do
1112 get :speech_balloons, :id => @other_author.id
1113 response.should render_template("speech_balloons")
1118 get :speech_balloons, :id => @other_author.id, :format => :json
1119 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1121 it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
1122 SpeechBalloon.should_receive(:list_json_opt).exactly(1)
1123 get :speech_balloons, :id => @other_author.id, :format => :json
1125 it 'データがリスト構造になっている' do
1126 get :speech_balloons, :id => @other_author.id, :format => :json
1127 json = JSON.parse response.body
1128 json.should have_at_least(3).items
1130 it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
1131 get :speech_balloons, :id => @other_author.id, :format => :json
1132 json = JSON.parse response.body
1133 json.first.has_key?("speech_balloon_template_id").should be_true
1134 json.first.has_key?("z").should be_true
1135 json.first.has_key?("t").should be_true
1139 context 'ユーザ権限がないとき' do
1144 it 'ステータスコード302 Foundを返す' do
1145 get :speech_balloons, :id => @other_author.id
1146 response.status.should eq 302
1148 it 'サインインページへ遷移する' do
1149 get :speech_balloons, :id => @other_author.id
1150 response.should redirect_to '/users/sign_in'
1154 it 'ステータスコード401 Unauthorizedを返す' do
1155 get :speech_balloons, :id => @other_author.id, :format => :json
1156 response.status.should eq 401
1158 it '応答メッセージにUnauthorizedを返す' do
1159 get :speech_balloons, :id => @other_author.id, :format => :json
1160 response.message.should match(/Unauthorized/)
1164 context 'ユーザ権限はないが管理者権限があるとき' do
1169 it 'ステータスコード200 OKを返す' do
1170 get :speech_balloons, :id => @other_author.id
1171 response.should be_success
1174 context 'ユーザだが作家登録していないとき' do
1178 it 'ステータスコード200 OKを返す' do
1179 get :speech_balloons, :id => @other_author.id
1180 response.should be_success
1185 describe '対象作家の絵地一覧表示に於いて' do
1187 @other_user = FactoryGirl.create( :user_yas)
1188 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1189 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1190 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
1191 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
1192 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
1193 @panel = FactoryGirl.create :panel, :author_id => @author.id
1194 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
1195 Author.stub(:show).and_return(@other_author)
1196 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
1199 context 'パラメータpageについて' do
1201 get :ground_pictures, :id => @other_author.id, :page => 5
1202 assigns(:page).should eq 5
1204 it '省略されると@pageに1値が入る' do
1205 get :ground_pictures, :id => @other_author.id
1206 assigns(:page).should eq 1
1208 it '与えられたpage_sizeがセットされている' do
1209 get :ground_pictures, :id => @other_author.id, :page_size => 15
1210 assigns(:page_size).should eq 15
1212 it '省略されると@page_sizeにデフォルト値が入る' do
1213 get :ground_pictures, :id => @other_author.id
1214 assigns(:page_size).should eq Author.default_ground_picture_page_size
1216 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1217 get :ground_pictures, :id => @other_author.id, :page_size => 1500
1218 assigns(:page_size).should eq Author.ground_picture_max_page_size
1220 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1221 get :ground_pictures, :id => @other_author.id, :page_size => 0
1222 assigns(:page_size).should eq Author.default_ground_picture_page_size
1225 context 'つつがなく終わるとき' do
1226 it 'ステータスコード200 OKを返す' do
1227 get :ground_pictures, :id => @other_author.id
1228 response.should be_success
1230 it '作家モデルに単体取得を問い合わせている' do
1231 Author.should_receive(:show).exactly(1)
1232 get :ground_pictures, :id => @other_author.id
1234 it '絵地モデルに他作家の絵地一覧を問い合わせている' do
1235 GroundPicture.should_receive(:himlist).exactly(1)
1236 get :ground_pictures, :id => @other_author.id
1238 it '@ground_picturesにリストを取得している' do
1239 get :ground_pictures, :id => @other_author.id
1240 assigns(:ground_pictures).should have_at_least(3).items
1243 it '@paginateにページ制御を取得している' do
1244 get :ground_pictures, :id => @other_author.id
1245 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1247 it 'ground_picturesテンプレートを描画する' do
1248 get :ground_pictures, :id => @other_author.id
1249 response.should render_template("ground_pictures")
1254 get :ground_pictures, :id => @other_author.id, :format => :json
1255 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1257 it '絵地モデルにjson一覧出力オプションを問い合わせている' do
1258 GroundPicture.should_receive(:list_json_opt).exactly(1)
1259 get :ground_pictures, :id => @other_author.id, :format => :json
1261 it 'データがリスト構造になっている' do
1262 get :ground_pictures, :id => @other_author.id, :format => :json
1263 json = JSON.parse response.body
1264 json.should have_at_least(3).items
1266 it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
1267 get :ground_pictures, :id => @other_author.id, :format => :json
1268 json = JSON.parse response.body
1269 json.first.has_key?("panel_id").should be_true
1270 json.first.has_key?("picture_id").should be_true
1271 json.first.has_key?("z").should be_true
1275 context 'ユーザ権限がないとき' do
1280 it 'ステータスコード302 Foundを返す' do
1281 get :ground_pictures, :id => @other_author.id
1282 response.status.should eq 302
1284 it 'サインインページへ遷移する' do
1285 get :ground_pictures, :id => @other_author.id
1286 response.should redirect_to '/users/sign_in'
1290 it 'ステータスコード401 Unauthorizedを返す' do
1291 get :ground_pictures, :id => @other_author.id, :format => :json
1292 response.status.should eq 401
1294 it '応答メッセージにUnauthorizedを返す' do
1295 get :ground_pictures, :id => @other_author.id, :format => :json
1296 response.message.should match(/Unauthorized/)
1300 context 'ユーザ権限はないが管理者権限があるとき' do
1305 it 'ステータスコード200 OKを返す' do
1306 get :ground_pictures, :id => @other_author.id
1307 response.should be_success
1310 context 'ユーザだが作家登録していないとき' do
1314 it 'ステータスコード200 OKを返す' do
1315 get :ground_pictures, :id => @other_author.id
1316 response.should be_success
1321 describe '対象作家の色地一覧表示に於いて' do
1323 @other_user = FactoryGirl.create( :user_yas)
1324 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1325 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
1326 @gc = FactoryGirl.create :ground_color
1327 @panel = FactoryGirl.create :panel, :author_id => @author.id
1328 Author.stub(:show).and_return(@other_author)
1329 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
1332 context 'パラメータpageについて' do
1334 get :ground_colors, :id => @other_author.id, :page => 5
1335 assigns(:page).should eq 5
1337 it '省略されると@pageに1値が入る' do
1338 get :ground_colors, :id => @other_author.id
1339 assigns(:page).should eq 1
1341 it '与えられたpage_sizeがセットされている' do
1342 get :ground_colors, :id => @other_author.id, :page_size => 15
1343 assigns(:page_size).should eq 15
1345 it '省略されると@page_sizeにデフォルト値が入る' do
1346 get :ground_colors, :id => @other_author.id
1347 assigns(:page_size).should eq Author.default_ground_color_page_size
1349 it '最大を超えると@page_sizeにデフォルト最大値が入る' do
1350 get :ground_colors, :id => @other_author.id, :page_size => 1500
1351 assigns(:page_size).should eq Author.ground_color_max_page_size
1353 it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
1354 get :ground_colors, :id => @other_author.id, :page_size => 0
1355 assigns(:page_size).should eq Author.ground_color_page_size
1358 context 'つつがなく終わるとき' do
1359 it 'ステータスコード200 OKを返す' do
1360 get :ground_colors, :id => @other_author.id
1361 response.should be_success
1363 it '作家モデルに単体取得を問い合わせている' do
1364 Author.should_receive(:show).exactly(1)
1365 get :ground_colors, :id => @other_author.id
1367 it '色地モデルに他作家の色地一覧を問い合わせている' do
1368 GroundColor.should_receive(:himlist).exactly(1)
1369 get :ground_colors, :id => @other_author.id
1371 it '@ground_colorsにリストを取得している' do
1372 get :ground_colors, :id => @other_author.id
1373 assigns(:ground_colors).should have_at_least(3).items
1376 it '@paginateにページ制御を取得している' do
1377 get :ground_colors, :id => @other_author.id
1378 assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
1380 it 'ground_colorsテンプレートを描画する' do
1381 get :ground_colors, :id => @other_author.id
1382 response.should render_template("ground_colors")
1387 get :ground_colors, :id => @other_author.id, :format => :json
1388 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1390 it '色地モデルにjson一覧出力オプションを問い合わせている' do
1391 GroundColor.should_receive(:list_json_opt).exactly(1)
1392 get :ground_colors, :id => @other_author.id, :format => :json
1394 it 'データがリスト構造になっている' do
1395 get :ground_colors, :id => @other_author.id, :format => :json
1396 json = JSON.parse response.body
1397 json.should have_at_least(3).items
1399 it 'リストの先頭くらいは色地っぽいものであって欲しい' do
1400 get :ground_colors, :id => @other_author.id, :format => :json
1401 json = JSON.parse response.body
1402 json.first.has_key?("panel_id").should be_true
1403 json.first.has_key?("code").should be_true
1404 json.first.has_key?("z").should be_true
1408 context 'ユーザ権限がないとき' do
1413 it 'ステータスコード302 Foundを返す' do
1414 get :ground_colors, :id => @other_author.id
1415 response.status.should eq 302
1417 it 'サインインページへ遷移する' do
1418 get :ground_colors, :id => @other_author.id
1419 response.should redirect_to '/users/sign_in'
1423 it 'ステータスコード401 Unauthorizedを返す' do
1424 get :ground_colors, :id => @other_author.id, :format => :json
1425 response.status.should eq 401
1427 it '応答メッセージにUnauthorizedを返す' do
1428 get :ground_colors, :id => @other_author.id, :format => :json
1429 response.message.should match(/Unauthorized/)
1433 context 'ユーザ権限はないが管理者権限があるとき' do
1438 it 'ステータスコード200 OKを返す' do
1439 get :ground_colors, :id => @other_author.id
1440 response.should be_success
1443 context 'ユーザだが作家登録していないとき' do
1447 it 'ステータスコード200 OKを返す' do
1448 get :ground_colors, :id => @other_author.id
1449 response.should be_success
1454 describe '作家数取得に於いて' do
1456 Author.should_receive(:visible_count).and_return(3)
1459 context 'つつがなく終わるとき' do
1460 it 'ステータスコード200 OKを返す' do
1461 get :count, :format => :json
1462 response.should be_success
1466 get :count, :format => :json
1467 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1469 it 'データがHash構造になっていて作家数が3である' do
1470 get :count, :format => :json
1471 json = JSON.parse response.body
1472 json["count"].should == 3
1478 describe '新規作成フォーム表示に於いて' do
1480 @new_user = FactoryGirl.create( :user_yas)
1483 context 'つつがなく終わるとき' do
1484 it 'ステータスコード200 OKを返す' do
1486 response.should be_success
1488 it '@auに新規データを用意している' do
1490 assigns(:au).should be_a_new(Author)
1492 it '作家モデルにデフォルト値補充を依頼している' do
1493 Author.any_instance.should_receive(:supply_default).exactly(1)
1497 it 'newテンプレートを描画する' do
1499 response.should render_template("new")
1503 it 'new.jsテンプレートを描画する' do
1504 get :new, :format => :js
1505 response.should render_template("new")
1510 get :new, :format => :json
1511 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1513 it '作家モデルにjson単体出力オプションを問い合わせている' do
1514 Author.should_receive(:show_json_opt).exactly(1)
1515 get :new, :format => :json
1519 context 'ユーザ権限がないとき' do
1524 it 'ステータスコード302 Foundを返す' do
1526 response.status.should eq 302
1528 it 'サインインページへ遷移する' do
1530 response.body.should redirect_to '/users/sign_in'
1534 it 'ステータスコード401 Unauthorizedを返す' do
1535 get :new, :format => :js
1536 response.status.should eq 401
1538 it '応答メッセージにUnauthorizedを返す' do
1539 get :new, :format => :js
1540 response.message.should match(/Unauthorized/)
1544 it 'ステータスコード401 Unauthorizedを返す' do
1545 get :new, :format => :json
1546 response.status.should eq 401
1548 it '応答メッセージにUnauthorizedを返す' do
1549 get :new, :format => :json
1550 response.message.should match(/Unauthorized/)
1554 context 'ユーザ権限はないが管理者権限があるとき' do
1560 it 'ステータスコード302 Foundを返す' do
1562 response.status.should eq 302
1564 it 'サインインページへ遷移する' do
1566 response.body.should redirect_to '/users/sign_in'
1570 context 'ユーザだが作家登録していないとき' do
1574 it 'ステータスコード200 OKを返す' do
1576 response.should be_success
1581 describe '新規作成に於いて' do
1583 @new_user = FactoryGirl.create( :user_yas)
1585 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
1587 context '事前チェックしておく' do
1588 it '作家モデルにデフォルト値補充を依頼している' do
1589 Author.any_instance.should_receive(:supply_default).exactly(1)
1590 post :create, :author => @attr
1592 it '作家モデルにカラム値復元を依頼している' do
1593 Author.any_instance.should_receive(:attributes=).exactly(1)
1594 post :create, :author => @attr
1596 it '作家モデルに上書き補充を依頼している' do
1597 Author.any_instance.should_receive(:overwrite).exactly(1)
1598 post :create, :author => @attr
1601 Author.any_instance.should_receive(:save).exactly(1)
1602 post :create, :author => @attr
1605 context 'つつがなく終わるとき' do
1606 it "@auに作成された作家を保持していて、それがDBにある" do
1607 post :create, :author => @attr
1608 assigns(:au).should be_a(Author)
1609 assigns(:au).should be_persisted
1612 it 'ステータスコード302 Foundを返す' do
1613 Author.any_instance.stub(:save).and_return(true)
1614 post :create, :author => @attr
1615 response.status.should eq 302
1618 # Author.any_instance.stub(:save).and_return(true)
1619 post :create, :author => @attr
1620 response.should redirect_to(root_path)
1624 it 'ステータスコード200 OKを返す' do
1625 # Author.any_instance.stub(:save).and_return(true)
1626 post :create, :author => @attr, :format => :json
1627 response.should be_success
1629 it '作成された作家をjsonデータで返す' do
1630 post :create, :author => @attr, :format => :json
1631 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1633 it '作家モデルにjson単体出力オプションを問い合わせている' do
1634 Author.should_receive(:show_json_opt).exactly(1)
1635 post :create, :author => @attr, :format => :json
1637 it 'データがアレになっている' do
1638 post :create, :author => @attr, :format => :json
1639 json = JSON.parse response.body
1640 json["name"].should match(/ken/)
1644 context 'ユーザ権限がないとき' do
1649 it 'ステータスコード302 Foundを返す' do
1650 post :create, :author => @attr
1651 response.status.should eq 302
1653 it 'サインインページへ遷移する' do
1654 post :create, :author => @attr
1655 response.body.should redirect_to '/users/sign_in'
1659 it 'ステータスコード401 Unauthorizedを返す' do
1660 post :create, :author => @attr, :format => :json
1661 response.status.should eq 401
1663 it '応答メッセージにUnauthorizedを返す' do
1664 post :create, :author => @attr, :format => :json
1665 response.message.should match(/Unauthorized/)
1669 context 'ユーザ権限はないが管理者権限があるとき' do
1675 it 'ステータスコード302 Foundを返す' do
1676 post :create, :author => @attr
1677 response.status.should eq 302
1679 it 'サインインページへ遷移する' do
1680 post :create, :author => @attr
1681 response.body.should redirect_to '/users/sign_in'
1685 context '検証、保存に失敗した' do
1687 Author.any_instance.stub(:save).and_return(false)
1689 it "未保存の作家を保持している" do
1690 post :create, :author => @attr
1691 assigns(:au).should be_a_new(Author)
1694 it 'ステータスコード200 OKを返す' do
1695 post :create, :author => @attr
1696 response.status.should eq 200
1699 post :create, :author => @attr
1700 response.should render_template("new")
1704 it 'ステータスコード422 unprocessable_entity を返す' do
1705 post :create, :author => @attr, :format => :json
1706 response.status.should eq 422
1708 it '応答メッセージUnprocessable Entityを返す' do
1709 post :create, :author => @attr, :format => :json
1710 response.message.should match(/Unprocessable/)
1716 describe '編集フォーム表示に於いて' do
1719 Author.stub(:edit).and_return(@author)
1721 context 'つつがなく終わるとき' do
1722 it 'ステータスコード200 OKを返す' do
1723 get :edit, :id => @author.id
1724 response.should be_success
1726 it '作家モデルに編集取得を問い合わせている' do
1727 Author.should_receive(:edit).exactly(1)
1728 get :edit, :id => @author.id
1730 #@authorだとログイン中のアカウントと干渉してしまう。
1731 it '@auにデータを用意している' do
1732 get :edit, :id => @author.id
1733 assigns(:au).should eq @author
1736 it 'editテンプレートを描画する' do
1737 get :edit, :id => @author.id
1738 response.should render_template("edit")
1742 it 'edit.jsテンプレートを描画する' do
1743 get :edit, :id => @author.id, :format => :js
1744 response.should render_template("edit")
1748 context 'ユーザ権限がないとき' do
1753 it 'ステータスコード302 Foundを返す' do
1754 get :edit, :id => @author.id
1755 response.status.should eq 302
1757 it 'サインインページへ遷移する' do
1758 get :edit, :id => @author.id
1759 response.body.should redirect_to '/users/sign_in'
1763 it 'ステータスコード401 Unauthorizedを返す' do
1764 get :edit, :id => @author.id, :format => :js
1765 response.status.should eq 401
1767 it '応答メッセージにUnauthorizedを返す' do
1768 get :edit, :id => @author.id, :format => :js
1769 response.message.should match(/Unauthorized/)
1773 context 'ユーザ権限はないが管理者権限があるとき' do
1779 it 'ステータスコード302 Foundを返す' do
1780 get :edit, :id => @author.id
1781 response.status.should eq 302
1783 it 'サインインページへ遷移する' do
1784 get :edit, :id => @author.id
1785 response.body.should redirect_to '/users/sign_in'
1789 context 'ユーザだが作家登録していないとき' do
1791 @other_user = FactoryGirl.create( :user_yas)
1792 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1796 it 'ステータスコード302 Foundを返す' do
1797 get :edit, :id => @other_author.id
1798 response.status.should eq 302
1800 it '作家登録ページへ遷移する' do
1801 get :edit, :id => @other_author.id
1802 response.body.should redirect_to new_author_path
1808 describe '更新に於いて' do
1810 @attr = @author.attributes
1811 @attr['name'] = 'ryu'
1814 context '事前チェックしておく' do
1815 it '作家モデルに編集取得を問い合わせている' do
1816 Author.stub(:edit).with(any_args()).and_return @author
1817 Author.should_receive(:edit).exactly(1)
1818 put :update, :id => @author.id, :author => @attr
1820 it 'モデルにpostデータ転送を依頼する' do
1821 Author.any_instance.stub(:attributes=).with(any_args)
1822 Author.any_instance.should_receive(:attributes=).exactly(1)
1823 put :update, :id => @author.id, :author => @attr
1825 it 'モデルに上書き補充を依頼する' do
1826 Author.any_instance.stub(:overwrite).with(any_args)
1827 Author.any_instance.should_receive(:overwrite).exactly(1)
1828 put :update, :id => @author.id, :author => @attr
1831 Author.any_instance.stub(:save).with(any_args).and_return true
1832 Author.any_instance.should_receive(:save).exactly(1)
1833 put :update, :id => @author.id, :author => @attr
1835 it '@auにアレを取得している' do
1836 put :update, :id => @author.id, :author => @attr
1837 assigns(:au).should eq @author
1840 context 'つつがなく終わるとき' do
1842 put :update, :id => @author.id, :author => @attr
1843 Author.find(@author.id).name.should eq 'ryu'
1846 it 'ステータスコード302 Foundを返す' do
1847 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1848 put :update, :id => @author.id, :author => @attr
1849 response.status.should eq 302
1852 put :update, :id => @author.id, :author => @attr
1853 response.should redirect_to('/home/configure')
1857 it 'ステータスコード200 OKを返す' do
1858 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1859 put :update, :id => @author.id, :author => @attr, :format => :json
1860 response.should be_success
1862 it 'ページ本体は特に返さない' do
1863 Author.any_instance.stub(:save).with(any_args()).and_return(true)
1864 put :update, :id => @author.id, :author => @attr, :format => :json
1865 response.body.should match /./
1869 context 'ユーザ権限がないとき' do
1874 it 'ステータスコード302 Foundを返す' do
1875 put :update, :id => @author.id, :author => @attr
1876 response.status.should eq 302
1878 it 'サインインページへ遷移する' do
1879 put :update, :id => @author.id, :author => @attr
1880 response.body.should redirect_to '/users/sign_in'
1884 it '応答メッセージにUnauthorizedを返す' do
1885 put :update, :id => @author.id, :author => @attr, :format => :json
1886 response.message.should match(/Unauthorized/)
1890 context 'ユーザ権限はないが管理者権限があるとき' do
1896 it 'ステータスコード302 Foundを返す' do
1897 put :update, :id => @author.id, :author => @attr
1898 response.status.should eq 302
1900 it 'サインインページへ遷移する' do
1901 put :update, :id => @author.id, :author => @attr
1902 response.body.should redirect_to '/users/sign_in'
1906 context 'ユーザだが作家登録していないとき' do
1908 @other_user = FactoryGirl.create( :user_yas)
1909 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
1913 it 'ステータスコード302 Foundを返す' do
1914 get :update, :id => @other_author.id
1915 response.status.should eq 302
1917 it '作家登録ページへ遷移する' do
1918 get :update, :id => @other_author.id
1919 response.body.should redirect_to new_author_path
1923 context '検証、保存に失敗したとき' do
1925 Author.any_instance.stub(:save).and_return(false)
1928 it 'ステータスコード200 Okを返す' do
1929 put :update, :id => @author.id, :author => @attr
1930 response.status.should eq 200
1933 put :update, :id => @author.id, :author => @attr
1934 response.should render_template("edit")
1938 it 'ステータスコード422 unprocessable_entity を返す' do
1939 Author.any_instance.stub(:save).and_return(false)
1940 put :update, :id => @author.id, :author => @attr, :format => :json
1941 response.status.should eq 422
1943 it '応答メッセージUnprocessable Entityを返す' do
1944 put :update, :id => @author.id, :author => @attr, :format => :json
1945 response.message.should match(/Unprocessable/)
1952 describe '一覧表示に於いて' do
1954 Author.stub(:list).and_return([@author, @author, @author])
1957 context 'つつがなく終わるとき' do
1958 it 'ステータスコード200 OKを返す' do
1960 response.should be_success
1963 it 'indexテンプレートを描画する' do
1965 response.should render_template("index")
1970 get :index, :format => :json
1971 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1975 context 'ユーザ権限がないとき' do
1979 it 'ステータスコード200 OKを返す' do
1981 response.should be_success
1984 it 'indexテンプレートを描画する' do
1986 response.should render_template("index")
1991 get :index, :format => :json
1992 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
1998 describe '閲覧に於いて' do
2000 Author.stub(:show).and_return(@author)
2003 context 'つつがなく終わるとき' do
2004 it 'ステータスコード200 OKを返す' do
2005 get :show, :id => @author.id
2006 response.should be_success
2009 it 'showテンプレートを描画する' do
2010 get :show, :id => @author.id
2011 response.should render_template("show")
2016 get :show, :id => @author.id, :format => :json
2017 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2021 context 'ユーザ権限がないとき' do
2025 it 'ステータスコード200 OKを返す' do
2026 get :show, :id => @author.id
2027 response.should be_success
2030 it 'showテンプレートを描画する' do
2031 get :show, :id => @author.id
2032 response.should render_template("show")
2037 get :show, :id => @author.id, :format => :json
2038 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2044 describe '対象作家のコミック一覧表示に於いて' do
2046 @other_user = FactoryGirl.create( :user_yas)
2047 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2048 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2049 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
2050 Scroll.stub(:mylist).and_return([@scroll, @scroll, @scroll])
2053 context 'つつがなく終わるとき' do
2054 it 'ステータスコード200 OKを返す' do
2055 get :scrolls, :id => @other_author.id
2056 response.should be_success
2059 it 'scrollテンプレートを描画する' do
2060 get :scrolls, :id => @other_author.id
2061 response.should render_template("scroll")
2066 get :scrolls, :id => @other_author.id, :format => :json
2067 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2071 context 'ユーザ権限がないとき' do
2075 it 'ステータスコード200 OKを返す' do
2076 get :scrolls, :id => @other_author.id
2077 response.should be_success
2080 it 'scrollsテンプレートを描画する' do
2081 get :scrolls, :id => @other_author.id
2082 response.should render_template("scrolls")
2087 get :scrolls, :id => @other_author.id, :format => :json
2088 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2094 describe '対象作家のストーリー一覧表示に於いて' do
2096 @other_user = FactoryGirl.create( :user_yas)
2097 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2098 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2099 @scroll = FactoryGirl.create :scroll, :author_id => @other_user.author.id
2100 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
2101 @scroll_panel = FactoryGirl.create :scroll_panel, :t => 0, :scroll_id => @scroll.id, :panel_id => @panel.id, :author_id => @other_author.id
2102 ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
2105 context 'つつがなく終わるとき' do
2106 it 'ステータスコード200 OKを返す' do
2107 get :scroll_panels, :id => @other_author.id
2108 response.should be_success
2111 it 'scroll_panelsテンプレートを描画する' do
2112 get :scroll_panels, :id => @other_author.id
2113 response.should render_template("scroll_panels")
2118 get :scroll_panels, :id => @other_author.id, :format => :json
2119 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2123 context 'ユーザ権限がないとき' do
2127 it 'ステータスコード200 OKを返す' do
2128 get :scroll_panels, :id => @other_author.id
2129 response.should be_success
2132 it 'scroll_panelsテンプレートを描画する' do
2133 get :scroll_panels, :id => @other_author.id
2134 response.should render_template("scroll_panels")
2139 get :scroll_panels, :id => @other_author.id, :format => :json
2140 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2146 describe '対象作家のコマ一覧表示に於いて' do
2148 @other_user = FactoryGirl.create( :user_yas)
2149 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2150 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2151 @panel = FactoryGirl.create :panel, :author_id => @other_author.id
2152 Panel.stub(:mylist).and_return([@panel, @panel, @panel])
2155 context 'つつがなく終わるとき' do
2156 it 'ステータスコード200 OKを返す' do
2157 get :panels, :id => @other_author.id
2158 response.should be_success
2161 it 'panelsテンプレートを描画する' do
2162 get :panels, :id => @other_author.id
2163 response.should render_template("panels")
2168 get :panels, :id => @other_author.id, :format => :json
2169 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2173 context 'ユーザ権限がないとき' do
2177 it 'ステータスコード200 OKを返す' do
2178 get :panels, :id => @other_author.id
2179 response.should be_success
2182 it 'panelsテンプレートを描画する' do
2183 get :panels, :id => @other_author.id
2184 response.should render_template("panels")
2189 get :panels, :id => @other_author.id, :format => :json
2190 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2196 describe '対象作家のコマ絵一覧表示に於いて' do
2198 @other_user = FactoryGirl.create( :user_yas)
2199 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2200 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2201 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
2202 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
2203 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
2204 @panel = FactoryGirl.create :panel, :author_id => @author.id
2205 @panel_picture = FactoryGirl.create :panel_picture, :picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height
2206 PanelPicture.stub(:list).and_return([@panel_picture, @panel_picture, @panel_picture])
2209 context 'つつがなく終わるとき' do
2210 it 'ステータスコード200 OKを返す' do
2211 get :panel_pictures, :id => @other_author.id
2212 response.should be_success
2215 it 'panel_picturesテンプレートを描画する' do
2216 get :panel_pictures, :id => @other_author.id
2217 response.should render_template("panel_pictures")
2222 get :panel_pictures, :id => @other_author.id, :format => :json
2223 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2227 context 'ユーザ権限がないとき' do
2231 it 'ステータスコード200 OKを返す' do
2232 get :panel_pictures, :id => @other_author.id
2233 response.should be_success
2236 it 'panel_picturesテンプレートを描画する' do
2237 get :panel_pictures, :id => @other_author.id
2238 response.should render_template("panel_pictures")
2243 get :panel_pictures, :id => @other_author.id, :format => :json
2244 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2250 describe '対象作家の絵地一覧表示に於いて' do
2252 @other_user = FactoryGirl.create( :user_yas)
2253 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2254 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2255 @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
2256 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
2257 @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
2258 @panel = FactoryGirl.create :panel, :author_id => @author.id
2259 @ground_picture = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
2260 GroundPicture.stub(:himlist).and_return([@ground_picture, @ground_picture, @ground_picture])
2263 context 'つつがなく終わるとき' do
2264 it 'ステータスコード200 OKを返す' do
2265 get :ground_pictures, :id => @other_author.id
2266 response.should be_success
2269 it 'ground_picturesテンプレートを描画する' do
2270 get :ground_pictures, :id => @other_author.id
2271 response.should render_template("ground_pictures")
2276 get :ground_pictures, :id => @other_author.id, :format => :json
2277 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2281 context 'ユーザ権限がないとき' do
2286 it 'ground_picturesテンプレートを描画する' do
2287 get :ground_pictures, :id => @other_author.id
2288 response.should render_template("ground_pictures")
2293 get :ground_pictures, :id => @other_author.id, :format => :json
2294 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2300 describe '対象作家の色地一覧表示に於いて' do
2302 @other_user = FactoryGirl.create( :user_yas)
2303 @other_author = FactoryGirl.create :author, :user_id => @other_user.id
2304 @other_artist = FactoryGirl.create :artist_yas, :author_id => @other_author.id
2305 @gc = FactoryGirl.create :ground_color
2306 @panel = FactoryGirl.create :panel, :author_id => @author.id
2307 GroundColor.stub(:himlist).and_return([@gc, @gc, @gc])
2310 context 'つつがなく終わるとき' do
2311 it 'ステータスコード200 OKを返す' do
2312 get :ground_colors, :id => @other_author.id
2313 response.should be_success
2316 it 'ground_colorsテンプレートを描画する' do
2317 get :ground_colors, :id => @other_author.id
2318 response.should render_template("ground_colors")
2323 get :ground_colors, :id => @other_author.id, :format => :json
2324 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2328 context 'ユーザ権限がないとき' do
2333 it 'ground_colorsテンプレートを描画する' do
2334 get :ground_colors, :id => @other_author.id
2335 response.should render_template("ground_colors")
2340 get :ground_colors, :id => @other_author.id, :format => :json
2341 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2347 describe '作家数取得に於いて' do
2349 Author.should_receive(:visible_count).and_return(3)
2352 context 'つつがなく終わるとき' do
2353 it 'ステータスコード200 OKを返す' do
2354 get :count, :format => :json
2355 response.should be_success
2359 get :count, :format => :json
2360 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2366 describe '新規作成フォーム表示に於いて' do
2368 @new_user = FactoryGirl.create( :user_yas)
2371 context 'つつがなく終わるとき' do
2372 it 'ステータスコード200 OKを返す' do
2374 response.should be_success
2377 it 'newテンプレートを描画する' do
2379 response.should render_template("new")
2383 it 'new.jsテンプレートを描画する' do
2384 get :new, :format => :js
2385 response.should render_template("new")
2390 get :new, :format => :json
2391 lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
2395 context 'ユーザ権限がないとき' do
2400 it 'ステータスコード302 Foundを返す' do
2402 response.status.should eq 302
2404 it 'サインインページへ遷移する' do
2406 response.body.should redirect_to '/users/sign_in'
2410 it 'ステータスコード401 Unauthorizedを返す' do
2411 get :new, :format => :js
2412 response.status.should eq 401
2414 it '応答メッセージにUnauthorizedを返す' do
2415 get :new, :format => :js
2416 response.message.should match(/Unauthorized/)
2420 it 'ステータスコード401 Unauthorizedを返す' do
2421 get :new, :format => :json
2422 response.status.should eq 401
2424 it '応答メッセージにUnauthorizedを返す' do
2425 get :new, :format => :json
2426 response.message.should match(/Unauthorized/)
2432 describe '新規作成に於いて' do
2434 @new_user = FactoryGirl.create( :user_yas)
2436 @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
2438 context 'つつがなく終わるとき' do
2440 it 'ステータスコード302 Foundを返す' do
2441 Author.any_instance.stub(:save).and_return(true)
2442 post :create, :author => @attr
2443 response.status.should eq 302
2446 # Author.any_instance.stub(:save).and_return(true)
2447 post :create, :author => @attr
2448 response.should redirect_to(root_path)
2452 it 'ステータスコード200 OKを返す' do
2453 # Author.any_instance.stub(:save).and_return(true)
2454 post :create, :author => @attr, :format => :json
2455 response.should be_success
2459 context 'ユーザ権限がないとき' do
2464 it 'ステータスコード302 Foundを返す' do
2465 post :create, :author => @attr
2466 response.status.should eq 302
2468 it 'サインインページへ遷移する' do
2469 post :create, :author => @attr
2470 response.body.should redirect_to '/users/sign_in'
2474 it 'ステータスコード401 Unauthorizedを返す' do
2475 post :create, :author => @attr, :format => :json
2476 response.status.should eq 401
2478 it '応答メッセージにUnauthorizedを返す' do
2479 post :create, :author => @attr, :format => :json
2480 response.message.should match(/Unauthorized/)
2486 describe '編集フォーム表示に於いて' do
2489 Author.stub(:edit).and_return(@author)
2491 context 'つつがなく終わるとき' do
2492 it 'ステータスコード200 OKを返す' do
2493 get :edit, :id => @author.id
2494 response.should be_success
2497 it 'editテンプレートを描画する' do
2498 get :edit, :id => @author.id
2499 response.should render_template("edit")
2503 it 'edit.jsテンプレートを描画する' do
2504 get :edit, :id => @author.id, :format => :js
2505 response.should render_template("edit")
2509 context 'ユーザ権限がないとき' do
2514 it 'ステータスコード302 Foundを返す' do
2515 get :edit, :id => @author.id
2516 response.status.should eq 302
2518 it 'サインインページへ遷移する' do
2519 get :edit, :id => @author.id
2520 response.body.should redirect_to '/users/sign_in'
2524 it 'ステータスコード401 Unauthorizedを返す' do
2525 get :edit, :id => @author.id, :format => :js
2526 response.status.should eq 401
2528 it '応答メッセージにUnauthorizedを返す' do
2529 get :edit, :id => @author.id, :format => :js
2530 response.message.should match(/Unauthorized/)
2536 describe '更新に於いて' do
2538 @attr = @author.attributes
2539 @attr['name'] = 'ryu'
2542 context 'つつがなく終わるとき' do
2544 put :update, :id => @author.id, :author => @attr
2545 Author.find(@author.id).name.should eq 'ryu'
2548 it 'ステータスコード302 Foundを返す' do
2549 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2550 put :update, :id => @author.id, :author => @attr
2551 response.status.should eq 302
2554 put :update, :id => @author.id, :author => @attr
2555 response.should redirect_to('/home/configure')
2559 it 'ステータスコード200 OKを返す' do
2560 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2561 put :update, :id => @author.id, :author => @attr, :format => :json
2562 response.should be_success
2564 it 'ページ本体は特に返さない' do
2565 Author.any_instance.stub(:save).with(any_args()).and_return(true)
2566 put :update, :id => @author.id, :author => @attr, :format => :json
2567 response.body.should match /./
2571 context 'ユーザ権限がないとき' do
2575 it 'ステータスコード302 Foundを返す' do
2576 put :update, :id => @author.id, :author => @attr
2577 response.status.should eq 302
2580 it 'サインインページへ遷移する' do
2581 put :update, :id => @author.id, :author => @attr
2582 response.body.should redirect_to '/users/sign_in'
2586 it '応答メッセージにUnauthorizedを返す' do
2587 put :update, :id => @author.id, :author => @attr, :format => :json
2588 response.message.should match(/Unauthorized/)