1 # -*- encoding: utf-8 -*-
5 describe SystemController do
9 describe 'システム初期化要請に於いて' do
10 context '要請の必要がないとき' do
12 #要請の必要がない=管理者登録済み かつ ライセンス登録済み
13 @admin = FactoryGirl.create :admin
14 @sp = FactoryGirl.create :system_picture
15 @lg = FactoryGirl.create :license_group
16 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
18 it 'リクエスト通りのページを開く' do
20 response.should_not redirect_to 'system/start'
22 context 'userがサインインしているなら' do
24 @user = FactoryGirl.create( :user_yas)
25 @author = FactoryGirl.create :author, :user_id => @user.id
28 it 'userにサインイン中のアカウントをセットしている' do
30 assigns(:user).should eq @user
32 it 'authorに作家をセットしている' do
34 assigns(:author).should eq @author
36 it 'artistに絵師をセットしている' do
37 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
39 assigns(:artist).should eq @artist
41 it 'ただし、絵師登録されてなければnilをセットしている' do
43 assigns(:artist).should be_nil
46 context 'userがサインインしていないなら' do
48 @user = FactoryGirl.create( :user_yas)
49 @author = FactoryGirl.create :author, :user_id => @user.id
50 @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
54 assigns(:user).should eq nil
56 it 'authorが空になっている' do
58 assigns(:author).should eq nil
60 it 'artistが空になっている' do
62 assigns(:artist).should eq nil
66 #要請の必要がある=管理者がいない または ライセンスがない
67 context '管理者がいないとき' do
69 @sp = FactoryGirl.create :system_picture
70 @lg = FactoryGirl.create :license_group
71 @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
73 context '本機能を開こうとしているなら' do
76 response.should redirect_to '/system/start'
78 it 'ステータスコード302 Foundを返す' do
80 response.status.should eq 302
83 context '初期化要請ページを開こうとしているなら' do
86 response.should_not redirect_to 'system/start'
90 response.status.should eq 200
94 response.should render_template("system/start")
98 context 'ライセンスがないとき' do
100 @admin = FactoryGirl.create :admin
102 context '本機能を開こうとしているなら' do
103 it '初期化要請ページに遷移する' do
105 response.should redirect_to '/system/start'
107 it 'ステータスコード302 Foundを返す' do
109 response.status.should eq 302
112 context '初期化要請ページを開こうとしているなら' do
115 response.should_not redirect_to 'system/start'
119 response.status.should eq 200
121 it '初期化要請ページを描画する' do
123 response.should render_template("system/start")