describe OriginalPictureLicenseGroupsController do
before do
- Factory :admin
- @user = Factory( :user_yas)
- @author = @user.author
- @artist = Factory :artist_yas, :author_id => @author.id
- @sp = Factory :system_picture
- @lg = Factory :license_group, :classname => 'OriginalPicture'
- @license = Factory :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
- @op = Factory :original_picture, :artist_id => @artist.id
+ @admin = FactoryGirl.create :admin
+ @user = FactoryGirl.create( :user_yas)
+ @author = FactoryGirl.create :author, :user_id => @user.id
+ @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
+ @sp = FactoryGirl.create :system_picture
+ @lg = FactoryGirl.create :license_group, :classname => 'PettanrUnknownV01License'
+ @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
+if MagicNumber['run_mode'] == 1
describe '新規作成フォーム表示に於いて' do
before do
sign_in @user
end
it '原画モデルに単体取得を問い合わせている' do
OriginalPicture.stub(:show).with(any_args()).and_return(@op)
- OriginalPicture.should_receive(:show).with(any_args()).exactly(1)\r
+ OriginalPicture.should_receive(:show).with(any_args()).exactly(1)
get :new, @attr
end
it '@original_pictureにデータを用意している' do
assigns(:original_picture_license_group).should be_a_new(OriginalPictureLicenseGroup)
end
it '原画ライセンスグループモデルにデフォルト値補充を依頼している' do
- OriginalPictureLicenseGroup.any_instance.should_receive(:supply_default).exactly(1)\r
+ OriginalPictureLicenseGroup.any_instance.should_receive(:supply_default).exactly(1)
get :new, @attr
end
context 'html形式' do
end
it '原画モデルに単体取得を問い合わせている' do
OriginalPicture.stub(:show).with(any_args()).and_return(@op)
- OriginalPicture.should_receive(:show).exactly(1)\r
+ OriginalPicture.should_receive(:show).exactly(1)
post :create, @attr
end
it '@original_pictureにデータを用意している' do
end
it 'ライセンスグループモデルに単体取得を問い合わせている' do
LicenseGroup.stub(:show).with(any_args()).and_return(@lg)
- LicenseGroup.should_receive(:show).exactly(1)\r
+ LicenseGroup.should_receive(:show).exactly(1)
post :create, @attr
end
it '@license_groupにデータを用意している' do
end
it '@ctlにコントローラを用意している' do
post :create, @attr
- assigns(:ctl).should eq 'original_pictures'
+ assigns(:ctl).should eq 'pettanr_unknown_v01_licenses'
end
it '@original_picture_license_groupにデータを用意している' do
post :create, @attr
end
it 'ライセンスクラスの新規作成テンプレートnewを描画する' do
post :create, @attr
- response.should render_template("original_pictures/new")
+ response.should render_template("pettanr_unknown_v01_licenses/attributes/new")
end
end
context 'js形式' do
end
it 'ライセンスクラスの新規作成部分テンプレートnew.jsを描画する' do
post :create, @attrj
- response.should render_template("original_pictures/new")
+ response.should render_template("pettanr_unknown_v01_licenses/attributes/new")
end
end
end
end
end
end
+
+else
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ @attr = {:original_picture_id => @op.id}
+ @attrj = @attr.merge({:format => :js})
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :new, @attr
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ページテンプレートnewを描画する' do
+ get :new, @attr
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ it '部分テンプレートnew.jsを描画する' do
+ get :new, @attrj
+ response.should render_template("new")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ @attr = {:original_picture_id => @op.id}
+ @attrj = @attr.merge({:format => :js})
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :new, @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :new, @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, @attrj
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, @attrj
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => @lg.id}}
+ @attrj = @attr.merge({:format => :js})
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ post :create, @attr
+ response.should be_success
+ end
+ it 'ライセンスクラスの新規作成テンプレートnewを描画する' do
+ post :create, @attr
+ response.should render_template("pettanr_unknown_v01_licenses/attributes/new")
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード200 OKを返す' do
+ post :create, @attrj
+ response.should be_success
+ end
+ it 'ライセンスクラスの新規作成部分テンプレートnew.jsを描画する' do
+ post :create, @attrj
+ response.should render_template("pettanr_unknown_v01_licenses/attributes/new")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => @lg.id}}
+ @attrj = @attr.merge({:format => :js})
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ post :create, @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ post :create, @attrj
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, @attrj
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+end
end