@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
+if MagicNumber['run_mode'] == 1
describe '新規作成フォーム表示に於いて' do
before do
sign_in @user
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