|
|
|
@ -11,6 +11,30 @@ RSpec.describe Api::V1::MediaController, type: :controller do
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'POST #create' do
|
|
|
|
|
describe 'with paperclip errors' do
|
|
|
|
|
context 'when imagemagick cant identify the file type' do
|
|
|
|
|
before do
|
|
|
|
|
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Errors::NotIdentifiedByImageMagickError)
|
|
|
|
|
post :create, params: { file: fixture_file_upload('files/attachment.jpg', 'image/jpeg') }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns http 422' do
|
|
|
|
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'when there is a generic error' do
|
|
|
|
|
before do
|
|
|
|
|
expect_any_instance_of(Account).to receive_message_chain(:media_attachments, :create!).and_raise(Paperclip::Error)
|
|
|
|
|
post :create, params: { file: fixture_file_upload('files/attachment.jpg', 'image/jpeg') }
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it 'returns http 422' do
|
|
|
|
|
expect(response).to have_http_status(:error)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context 'image/jpeg' do
|
|
|
|
|
before do
|
|
|
|
|
post :create, params: { file: fixture_file_upload('files/attachment.jpg', 'image/jpeg') }
|
|
|
|
|