OSDN Git Service

t#29826:up;importer replace
[pettanr/pettanr.git] / spec / controllers / home_controller_spec.rb
1 # -*- encoding: utf-8 -*-
2 require 'spec_helper'
3 #ユーザホーム
4
5 describe HomeController do
6   before do
7     FactoryGirl.create :admin
8     @sp = FactoryGirl.create :system_picture
9     @lg = FactoryGirl.create :license_group
10     @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
11     @user = FactoryGirl.create( :user_yas)
12     @author = @user.author
13     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
14     @color = FactoryGirl.create :color
15     @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
16     @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
17     @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
18     @panel = FactoryGirl.create :panel, :author_id => @author.id
19   end
20   
21   describe '自分のコミック一覧表示に於いて' do
22     before do
23       @comic = FactoryGirl.create :comic, :author_id => @author.id
24       sign_in @user
25       Comic.stub(:mylist).and_return([@comic, @comic, @comic])
26     end
27     context 'パラメータpageについて' do
28       it '@pageに値が入る' do
29         get :comic, :page => 5
30         assigns(:page).should eq 5
31       end
32       it '省略されると@pageに1値が入る' do
33         get :comic
34         assigns(:page).should eq 1
35       end
36       it '与えられたpage_sizeがセットされている' do
37         get :comic, :page_size => 15
38         assigns(:page_size).should eq 15
39       end
40       it '省略されると@page_sizeにデフォルト値が入る' do
41         get :comic
42         assigns(:page_size).should eq Author.default_comic_page_size
43       end
44       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
45         get :comic, :page_size => 1500
46         assigns(:page_size).should eq Author.comic_max_page_size
47       end
48       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
49         get :comic, :page_size => 0
50         assigns(:page_size).should eq Author.default_comic_page_size
51       end
52     end
53     context 'つつがなく終わるとき' do
54       it 'ステータスコード200 OKを返す' do
55         get :comic
56         response.should be_success 
57       end
58       it 'コミックモデルに一覧を問い合わせている' do
59         Comic.should_receive(:mylist).exactly(1)
60         get :comic
61       end
62       it '@comicsにリストを取得している' do
63         get :comic
64         assigns(:comics).should have_at_least(3).items
65       end
66       context 'html形式' do
67         it 'comicテンプレートを描画する' do
68           get :comic
69           response.should render_template("comic")
70         end
71       end
72       context 'json形式' do
73         it 'jsonデータを返す' do
74           get :comic, :format => :json
75           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
76         end
77         it 'コミックモデルにjson一覧出力オプションを問い合わせている' do
78           Comic.should_receive(:list_json_opt).exactly(1)
79           get :comic, :format => :json
80         end
81         it 'データがリスト構造になっている' do
82           get :comic, :format => :json
83           json = JSON.parse response.body
84           json.should have_at_least(3).items
85         end
86         it 'リストの先頭くらいはコミックっぽいものであって欲しい' do
87           get :comic, :format => :json
88           json = JSON.parse response.body
89           json.first.has_key?("title").should be_true
90           json.first.has_key?("visible").should be_true\r
91         end
92       end
93     end
94     context '作家権限がないとき' do
95       before do
96         sign_out @user
97       end
98       context 'html形式' do
99         it 'ステータスコード302 Foundを返す' do
100           get :comic
101           response.status.should eq 302
102         end
103         it 'サインインページへ遷移する' do
104           get :comic
105           response.should redirect_to '/users/sign_in'
106         end
107       end
108       context 'json形式' do
109         it 'ステータスコード401 Unauthorizedを返す' do
110           get :comic, :format => :json
111           response.status.should eq 401
112         end
113         it '応答メッセージにUnauthorizedを返す' do
114           get :comic, :format => :json
115           response.message.should match(/Unauthorized/)
116         end
117       end
118     end
119   end
120   
121   describe '自分のコマ一覧表示に於いて' do
122     before do
123       @panel = FactoryGirl.create :panel, :author_id => @author.id
124       sign_in @user
125       Panel.stub(:mylist).and_return([@panel, @panel, @panel])
126     end
127     context 'パラメータpageについて' do
128       it '@pageに値が入る' do
129         get :panel, :page => 5
130         assigns(:page).should eq 5
131       end
132       it '省略されると@pageに1値が入る' do
133         get :panel
134         assigns(:page).should eq 1
135       end
136       it '与えられたpage_sizeがセットされている' do
137         get :panel, :page_size => 15
138         assigns(:page_size).should eq 15
139       end
140       it '省略されると@page_sizeにデフォルト値が入る' do
141         get :panel
142         assigns(:page_size).should eq Author.default_panel_page_size
143       end
144       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
145         get :panel, :page_size => 1500
146         assigns(:page_size).should eq Author.panel_max_page_size
147       end
148       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
149         get :panel, :page_size => 0
150         assigns(:page_size).should eq Author.default_panel_page_size
151       end
152     end
153     context 'つつがなく終わるとき' do
154       it 'コマモデルに一覧を問い合わせている' do
155         Panel.should_receive(:mylist).exactly(1)
156         get :panel
157       end
158       it '@panelsにリストを取得している' do
159         get :panel
160         assigns(:panels).should have_at_least(3).items
161       end
162       context 'html形式' do
163         it 'ステータスコード200 OKを返す' do
164           get :panel
165           response.should be_success 
166         end
167         it 'panelテンプレートを描画する' do
168           get :panel
169           response.should render_template("panel")
170         end
171       end
172       context 'json形式' do
173         it 'ステータスコード200 OKを返す' do
174           get :panel, :format => :json
175           response.should be_success 
176         end
177         it 'jsonデータを返す' do
178           get :panel, :format => :json
179           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
180         end
181         it 'コマモデルにコマリストのjson出力を問い合わせている' do
182           Panel.should_receive(:list_as_json_text).exactly(1)
183           get :panel, :format => :json
184         end
185         it 'データがリスト構造になっている' do
186           get :panel, :format => :json
187           json = JSON.parse response.body
188           json.should have_at_least(3).items
189         end
190         it 'リストの先頭くらいはコマっぽいものであって欲しい' do
191           get :panel, :format => :json
192           json = JSON.parse response.body
193           json.first.has_key?("z").should be_true
194         end
195       end
196     end
197     context '作家権限がないとき' do
198       before do
199         sign_out @user
200       end
201       context 'html形式' do
202         it 'ステータスコード302 Foundを返す' do
203           get :panel
204           response.status.should eq 302
205         end
206         it 'サインインページへ遷移する' do
207           get :panel
208           response.should redirect_to '/users/sign_in'
209         end
210       end
211       context 'json形式' do
212         it 'ステータスコード401 Unauthorizedを返す' do
213           get :panel, :format => :json
214           response.status.should eq 401
215         end
216         it '応答メッセージにUnauthorizedを返す' do
217           get :panel, :format => :json
218           response.message.should match(/Unauthorized/)
219         end
220       end
221     end
222   end
223   
224   describe '自分のコマ絵一覧表示に於いて' do
225     before do
226       @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
227         :width => @p.width, :height => @p.height
228       sign_in @user
229       PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
230     end
231     context 'パラメータpageについて' do
232       it '@pageに値が入る' do
233         get :panel_picture, :page => 5
234         assigns(:page).should eq 5
235       end
236       it '省略されると@pageに1値が入る' do
237         get :panel_picture
238         assigns(:page).should eq 1
239       end
240       it '与えられたpage_sizeがセットされている' do
241         get :panel_picture, :page_size => 15
242         assigns(:page_size).should eq 15
243       end
244       it '省略されると@page_sizeにデフォルト値が入る' do
245         get :panel_picture
246         assigns(:page_size).should eq Author.default_panel_picture_page_size
247       end
248       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
249         get :panel_picture, :page_size => 1500
250         assigns(:page_size).should eq Author.panel_picture_max_page_size
251       end
252       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
253         get :panel_picture, :page_size => 0
254         assigns(:page_size).should eq Author.default_panel_picture_page_size
255       end
256     end
257     context 'つつがなく終わるとき' do
258       it 'ステータスコード200 OKを返す' do
259         get :panel_picture
260         response.should be_success 
261       end
262       it 'コマ絵モデルに一覧を問い合わせている' do
263         PanelPicture.should_receive(:mylist).exactly(1)
264         get :panel_picture
265       end
266       it '@panel_picturesにリストを取得している' do
267         get :panel_picture
268         assigns(:panel_pictures).should have_at_least(3).items
269       end
270       context 'html形式' do
271         it 'panel_pictureテンプレートを描画する' do
272           get :panel_picture
273           response.should render_template("panel_picture")
274         end
275       end
276       context 'json形式' do
277         it 'jsonデータを返す' do
278           get :panel_picture, :format => :json
279           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
280         end
281         it 'コマ絵モデルにjson一覧出力オプションを問い合わせている' do
282           PanelPicture.should_receive(:list_json_opt).exactly(1)
283           get :panel_picture, :format => :json
284         end
285         it 'データがリスト構造になっている' do
286           get :panel_picture, :format => :json
287           json = JSON.parse response.body
288           json.should have_at_least(3).items
289         end
290         it 'リストの先頭くらいはコマ絵っぽいものであって欲しい' do
291           get :panel_picture, :format => :json
292           json = JSON.parse response.body
293           json.first.has_key?("link").should be_true
294           json.first.has_key?("x").should be_true
295           json.first.has_key?("y").should be_true
296         end
297       end
298     end
299     context '作家権限がないとき' do
300       before do
301         sign_out @user
302       end
303       context 'html形式' do
304         it 'ステータスコード302 Foundを返す' do
305           get :panel_picture
306           response.status.should eq 302
307         end
308         it 'サインインページへ遷移する' do
309           get :panel_picture
310           response.should redirect_to '/users/sign_in'
311         end
312       end
313       context 'json形式' do
314         it 'ステータスコード401 Unauthorizedを返す' do
315           get :panel_picture, :format => :json
316           response.status.should eq 401
317         end
318         it '応答メッセージにUnauthorizedを返す' do
319           get :panel_picture, :format => :json
320           response.message.should match(/Unauthorized/)
321         end
322       end
323     end
324   end
325   
326   describe '自分の原画一覧表示に於いて' do
327     before do
328       sign_in @user
329       OriginalPicture.stub(:mylist).and_return([@op, @op, @op])
330     end
331     context 'パラメータpageについて' do
332       it '@pageに値が入る' do
333         get :picture, :page => 5
334         assigns(:page).should eq 5
335       end
336       it '省略されると@pageに1値が入る' do
337         get :picture
338         assigns(:page).should eq 1
339       end
340       it '与えられたpage_sizeがセットされている' do
341         get :picture, :page_size => 15
342         assigns(:page_size).should eq 15
343       end
344       it '省略されると@page_sizeにデフォルト値が入る' do
345         get :picture
346         assigns(:page_size).should eq OriginalPicture.default_page_size
347       end
348       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
349         get :picture, :page_size => 1500
350         assigns(:page_size).should eq OriginalPicture.max_page_size
351       end
352       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
353         get :picture, :page_size => 0
354         assigns(:page_size).should eq OriginalPicture.default_page_size
355       end
356     end
357     context 'つつがなく終わるとき' do
358       it 'ステータスコード200 OKを返す' do
359         get :picture
360         response.should be_success 
361       end
362       it '原画モデルに一覧を問い合わせている' do
363         #原画は他人が使えないので「自分の」リストはない
364         OriginalPicture.should_receive(:mylist).exactly(1)
365         get :picture
366       end
367       it '@original_picturesにリストを取得している' do
368         get :picture
369         assigns(:original_pictures).should have_at_least(3).items
370       end
371       context 'html形式' do
372         it 'pictureテンプレートを描画する' do
373           get :picture
374           response.should render_template("picture")
375         end
376       end
377       context 'json形式' do
378         it 'jsonデータを返す' do
379           get :picture, :format => :json
380           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
381         end
382         it '原画モデルにjson一覧出力オプションを問い合わせている' do
383           OriginalPicture.should_receive(:list_json_opt).exactly(1)
384           get :picture, :format => :json
385         end
386         it 'データがリスト構造になっている' do
387           get :picture, :format => :json
388           json = JSON.parse response.body
389           json.should have_at_least(3).items
390         end
391         it 'リストの先頭くらいは原画っぽいものであって欲しい' do
392           get :picture, :format => :json
393           json = JSON.parse response.body
394           json.first.has_key?("ext").should be_true
395           json.first.has_key?("md5").should be_true
396           json.first.has_key?("artist_id").should be_true
397           json.first.has_key?("width").should be_true
398         end
399       end
400     end
401     context '作家権限がないとき' do
402       before do
403         sign_out @user
404       end
405       context 'html形式' do
406         it 'ステータスコード302 Foundを返す' do
407           get :picture
408           response.status.should eq 302
409         end
410         it 'サインインページへ遷移する' do
411           get :picture
412           response.should redirect_to '/users/sign_in'
413         end
414       end
415       context 'json形式' do
416         it 'ステータスコード401 Unauthorizedを返す' do
417           get :picture, :format => :json
418           response.status.should eq 401
419         end
420         it '応答メッセージにUnauthorizedを返す' do
421           get :picture, :format => :json
422           response.message.should match(/Unauthorized/)
423         end
424       end
425     end
426     context '作家が絵師でないとき' do
427       before do
428         Author.any_instance.stub(:artist?).and_return(false)
429       end
430       context 'html形式' do
431         it 'ステータスコード302 Foundを返す' do
432           get :picture
433           response.status.should eq 302
434         end
435         it '絵師登録ページへ遷移する' do
436           get :picture
437           response.should redirect_to new_artist_path
438         end
439       end
440       context 'json形式' do
441         it '例外403 forbiddenを返す' do
442           lambda{
443             get :picture, :format => :json
444           }.should raise_error(ActiveRecord::Forbidden)
445         end
446       end
447     end
448   end
449   
450   describe '自分のコマの色背景一覧表示に於いて' do
451     before do
452       @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
453       sign_in @user
454       PanelColor.stub(:mylist).and_return([@pc, @pc, @pc])
455     end
456     context 'パラメータpageについて' do
457       it '@pageに値が入る' do
458         get :panel_color, :page => 5
459         assigns(:page).should eq 5
460       end
461       it '省略されると@pageに1値が入る' do
462         get :panel_color
463         assigns(:page).should eq 1
464       end
465       it '与えられたpage_sizeがセットされている' do
466         get :panel_color, :page_size => 15
467         assigns(:page_size).should eq 15
468       end
469       it '省略されると@page_sizeにデフォルト値が入る' do
470         get :panel_color
471         assigns(:page_size).should eq PanelColor.default_page_size
472       end
473       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
474         get :panel_color, :page_size => 1500
475         assigns(:page_size).should eq PanelColor.max_page_size
476       end
477       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
478         get :panel_color, :page_size => 0
479         assigns(:page_size).should eq PanelColor.default_page_size
480       end
481     end
482     context 'つつがなく終わるとき' do
483       it 'ステータスコード200 OKを返す' do
484         get :panel_color
485         response.should be_success 
486       end
487       it 'コマの色背景モデルに一覧を問い合わせている' do
488         PanelColor.should_receive(:mylist).exactly(1)
489         get :panel_color
490       end
491       it '@panel_colorsにリストを取得している' do
492         get :panel_color
493         assigns(:panel_colors).should have_at_least(3).items
494       end
495       context 'html形式' do
496         it 'panel_colorテンプレートを描画する' do
497           get :panel_color
498           response.should render_template("panel_color")
499         end
500       end
501       context 'json形式' do
502         it 'jsonデータを返す' do
503           get :panel_color, :format => :json
504           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
505         end
506         it 'コマの色背景モデルにjson一覧出力オプションを問い合わせている' do
507           PanelColor.should_receive(:list_json_opt).exactly(1)
508           get :panel_color, :format => :json
509         end
510         it 'データがリスト構造になっている' do
511           get :panel_color, :format => :json
512           json = JSON.parse response.body
513           json.should have_at_least(3).items
514         end
515         it 'リストの先頭くらいはコマの色背景っぽいものであって欲しい' do
516           get :panel_color, :format => :json
517           json = JSON.parse response.body
518           json.first.has_key?("panel_id").should be_true
519           json.first.has_key?("code").should be_true
520           json.first.has_key?("z").should be_true
521         end
522       end
523     end
524     context '作家権限がないとき' do
525       before do
526         sign_out @user
527       end
528       context 'html形式' do
529         it 'ステータスコード302 Foundを返す' do
530           get :panel_color
531           response.status.should eq 302
532         end
533         it 'サインインページへ遷移する' do
534           get :panel_color
535           response.should redirect_to '/users/sign_in'
536         end
537       end
538       context 'json形式' do
539         it 'ステータスコード401 Unauthorizedを返す' do
540           get :panel_color, :format => :json
541           response.status.should eq 401
542         end
543         it '応答メッセージにUnauthorizedを返す' do
544           get :panel_color, :format => :json
545           response.message.should match(/Unauthorized/)
546         end
547       end
548     end
549   end
550   
551   describe '自分のコマの画像背景一覧表示に於いて' do
552     before do
553       @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
554       sign_in @user
555       GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
556     end
557     context 'パラメータpageについて' do
558       it '@pageに値が入る' do
559         get :ground_picture, :page => 5
560         assigns(:page).should eq 5
561       end
562       it '省略されると@pageに1値が入る' do
563         get :ground_picture
564         assigns(:page).should eq 1
565       end
566       it '与えられたpage_sizeがセットされている' do
567         get :ground_picture, :page_size => 15
568         assigns(:page_size).should eq 15
569       end
570       it '省略されると@page_sizeにデフォルト値が入る' do
571         get :ground_picture
572         assigns(:page_size).should eq GroundPicture.default_page_size
573       end
574       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
575         get :ground_picture, :page_size => 1500
576         assigns(:page_size).should eq GroundPicture.max_page_size
577       end
578       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
579         get :ground_picture, :page_size => 0
580         assigns(:page_size).should eq GroundPicture.default_page_size
581       end
582     end
583     context 'つつがなく終わるとき' do
584       it 'ステータスコード200 OKを返す' do
585         get :ground_picture
586         response.should be_success 
587       end
588       it 'コマの画像背景モデルに一覧を問い合わせている' do
589         GroundPicture.should_receive(:mylist).exactly(1)
590         get :ground_picture
591       end
592       it '@ground_picturesにリストを取得している' do
593         get :ground_picture
594         assigns(:ground_pictures).should have_at_least(3).items
595       end
596       context 'html形式' do
597         it 'ground_pictureテンプレートを描画する' do
598           get :ground_picture
599           response.should render_template("ground_picture")
600         end
601       end
602       context 'json形式' do
603         it 'jsonデータを返す' do
604           get :ground_picture, :format => :json
605           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
606         end
607         it 'コマの画像背景モデルにjson一覧出力オプションを問い合わせている' do
608           GroundPicture.should_receive(:list_json_opt).exactly(1)
609           get :ground_picture, :format => :json
610         end
611         it 'データがリスト構造になっている' do
612           get :ground_picture, :format => :json
613           json = JSON.parse response.body
614           json.should have_at_least(3).items
615         end
616         it 'リストの先頭くらいはコマの画像背景っぽいものであって欲しい' do
617           get :ground_picture, :format => :json
618           json = JSON.parse response.body
619           json.first.has_key?("panel_id").should be_true
620           json.first.has_key?("picture_id").should be_true
621           json.first.has_key?("z").should be_true
622         end
623       end
624     end
625     context '作家権限がないとき' do
626       before do
627         sign_out @user
628       end
629       context 'html形式' do
630         it 'ステータスコード302 Foundを返す' do
631           get :ground_picture
632           response.status.should eq 302
633         end
634         it 'サインインページへ遷移する' do
635           get :ground_picture
636           response.should redirect_to '/users/sign_in'
637         end
638       end
639       context 'json形式' do
640         it 'ステータスコード401 Unauthorizedを返す' do
641           get :ground_picture, :format => :json
642           response.status.should eq 401
643         end
644         it '応答メッセージにUnauthorizedを返す' do
645           get :ground_picture, :format => :json
646           response.message.should match(/Unauthorized/)
647         end
648       end
649     end
650   end
651   
652   describe '自分の間接背景一覧表示に於いて' do
653     before do
654       @gc = FactoryGirl.create :ground_color
655       sign_in @user
656       GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
657     end
658     context 'パラメータpageについて' do
659       it '@pageに値が入る' do
660         get :ground_color, :page => 5
661         assigns(:page).should eq 5
662       end
663       it '省略されると@pageに1値が入る' do
664         get :ground_color
665         assigns(:page).should eq 1
666       end
667       it '与えられたpage_sizeがセットされている' do
668         get :ground_color, :page_size => 15
669         assigns(:page_size).should eq 15
670       end
671       it '省略されると@page_sizeにデフォルト値が入る' do
672         get :ground_color
673         assigns(:page_size).should eq GroundColor.default_page_size
674       end
675       it '最大を超えると@page_sizeにデフォルト最大値が入る' do
676         get :ground_color, :page_size => 1500
677         assigns(:page_size).should eq GroundColor.max_page_size
678       end
679       it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
680         get :ground_color, :page_size => 0
681         assigns(:page_size).should eq GroundColor.default_page_size
682       end
683     end
684     context 'つつがなく終わるとき' do
685       it 'ステータスコード200 OKを返す' do
686         get :ground_color
687         response.should be_success 
688       end
689       it '間接背景モデルに一覧を問い合わせている' do
690         GroundColor.should_receive(:mylist).exactly(1)
691         get :ground_color
692       end
693       it '@ground_colorsにリストを取得している' do
694         get :ground_color
695         assigns(:ground_colors).should have_at_least(3).items
696       end
697       context 'html形式' do
698         it 'ground_colorテンプレートを描画する' do
699           get :ground_color
700           response.should render_template("ground_color")
701         end
702       end
703       context 'json形式' do
704         it 'jsonデータを返す' do
705           get :ground_color, :format => :json
706           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
707         end
708         it '間接背景モデルにjson一覧出力オプションを問い合わせている' do
709           GroundColor.should_receive(:list_json_opt).exactly(1)
710           get :ground_color, :format => :json
711         end
712         it 'データがリスト構造になっている' do
713           get :ground_color, :format => :json
714           json = JSON.parse response.body
715           json.should have_at_least(3).items
716         end
717         it 'リストの先頭くらいは間接背景っぽいものであって欲しい' do
718           get :ground_color, :format => :json
719           json = JSON.parse response.body
720           json.first.has_key?("panel_id").should be_true
721           json.first.has_key?("color_id").should be_true
722           json.first.has_key?("z").should be_true
723         end
724       end
725     end
726     context '作家権限がないとき' do
727       before do
728         sign_out @user
729       end
730       context 'html形式' do
731         it 'ステータスコード302 Foundを返す' do
732           get :ground_color
733           response.status.should eq 302
734         end
735         it 'サインインページへ遷移する' do
736           get :ground_color
737           response.should redirect_to '/users/sign_in'
738         end
739       end
740       context 'json形式' do
741         it 'ステータスコード401 Unauthorizedを返す' do
742           get :ground_color, :format => :json
743           response.status.should eq 401
744         end
745         it '応答メッセージにUnauthorizedを返す' do
746           get :ground_color, :format => :json
747           response.message.should match(/Unauthorized/)
748         end
749       end
750     end
751   end
752   
753 end