end
end
context 'json形式' do
- it '例外403 forbiddenを返す' do
- lambda{
- get :index, :format => :json
- }.should raise_error(ActiveRecord::Forbidden)
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
end
end
end
end
end
context 'json形式' do
- it '例外403 forbiddenを返す' do
- lambda{
- get :show, :id => @pic.id, :format => :json
- }.should raise_error(ActiveRecord::Forbidden)
+ it '応答メッセージにUnauthorizedを返す' do
+ get :show, :id => @pic.id, :format => :json
+ response.message.should match(/Unauthorized/)
end
end
end
end
end
context 'json形式' do
- it '例外403 forbiddenを返す' do
- lambda{
- get :history, :id => @op.id, :format => :json
- }.should raise_error(ActiveRecord::Forbidden)
+ it '応答メッセージにUnauthorizedを返す' do
+ get :history, :id => @op.id, :format => :json
+ response.message.should match(/Unauthorized/)
end
end
end
end
end
context 'json形式' do
- it '例外403 forbiddenを返す' do
- lambda{
+ it '応答メッセージにUnauthorizedを返す' do
get :new, :format => :json
- }.should raise_error(ActiveRecord::Forbidden)
+ response.message.should match(/Unauthorized/)
end
end
end
before do
@attr.merge!({:format => :json})
end
- it '例外403 forbiddenを返す' do
- lambda{
- post :create, @attr
- }.should raise_error(ActiveRecord::Forbidden)
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, @attr
+ response.message.should match(/Unauthorized/)
end
end
end
end
end
context 'json形式' do
- it '例外403 forbiddenを返す' do
- lambda{
- put :update, :id => @op.id, :original_picture => @attr, :format => :json
- }.should raise_error(ActiveRecord::Forbidden)
+ it '応答メッセージにUnauthorizedを返す' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
end
end
end
end
end
end
+ context '作家が絵師でないとき' do
+ before do
+ Author.any_instance.stub(:artist?).and_return(false)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @op.id
+ response.status.should eq 302
+ end
+ it '絵師登録ページへ遷移する' do
+ delete :destroy, :id => @op.id
+ response.should redirect_to new_artist_path
+ end
+ end
+ context 'json形式' do
+ it '応答メッセージにUnauthorizedを返す' do
+ delete :destroy, :id => @op.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
context '削除に失敗したとき' do
before do
OriginalPicture.any_instance.stub(:destroy_with_resource_picture).and_return(false)
before do
@attr.merge!({:format => :json})
end
- it '例外403 forbiddenを返す' do
- lambda{
- post :create, @attr
- }.should raise_error(ActiveRecord::Forbidden)
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, @attr
+ response.message.should match(/Unauthorized/)
end
end
end
end
end
end
+ context '作家が絵師でないとき' do
+ before do
+ Author.any_instance.stub(:artist?).and_return(false)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @rp.id
+ response.status.should eq 302
+ end
+ it '絵師登録ページへ遷移する' do
+ delete :destroy, :id => @rp.id
+ response.should redirect_to new_artist_path
+ end
+ end
+ context 'json形式' do
+ it '応答メッセージにUnauthorizedを返す' do
+ delete :destroy, :id => @rp.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
context '削除に失敗したとき' do
before do
ResourcePicture.any_instance.stub(:unpublish).and_return(false)