From ce29624c6df83699a01808d68c19a2492864ffe8 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 12 Sep 2016 18:22:43 +0200 Subject: Fixing image upload limits, allowing webm, merge/unmerge events trigger timeline reload in UI, other small fixes --- spec/controllers/api/media_controller_spec.rb | 50 +++++++++++++++++++------- spec/fixtures/files/attachment.webm | Bin 0 -> 653991 bytes 2 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 spec/fixtures/files/attachment.webm (limited to 'spec') diff --git a/spec/controllers/api/media_controller_spec.rb b/spec/controllers/api/media_controller_spec.rb index 2f216c1d5..e6c44cc9f 100644 --- a/spec/controllers/api/media_controller_spec.rb +++ b/spec/controllers/api/media_controller_spec.rb @@ -11,24 +11,48 @@ RSpec.describe Api::MediaController, type: :controller do end describe 'POST #create' do - before do - post :create, params: { file: fixture_file_upload('files/attachment.jpg', 'image/jpeg') } + context 'image/jpeg' do + before do + post :create, params: { file: fixture_file_upload('files/attachment.jpg', 'image/jpeg') } + end + + it 'returns http success' do + expect(response).to have_http_status(:success) + end + + it 'creates a media attachment' do + expect(MediaAttachment.first).to_not be_nil + end + + it 'uploads a file' do + expect(MediaAttachment.first).to have_attached_file(:file) + end + + it 'returns media ID in JSON' do + expect(body_as_json[:id]).to eq MediaAttachment.first.id + end end - it 'returns http success' do - expect(response).to have_http_status(:success) - end + context 'video/webm' do + before do + post :create, params: { file: fixture_file_upload('files/attachment.webm', 'video/webm') } + end - it 'creates a media attachment' do - expect(MediaAttachment.first).to_not be_nil - end + xit 'returns http success' do + expect(response).to have_http_status(:success) + end - it 'uploads a file' do - expect(MediaAttachment.first).to have_attached_file(:file) - end + xit 'creates a media attachment' do + expect(MediaAttachment.first).to_not be_nil + end + + xit 'uploads a file' do + expect(MediaAttachment.first).to have_attached_file(:file) + end - it 'returns media ID in JSON' do - expect(body_as_json[:id]).to eq MediaAttachment.first.id + xit 'returns media ID in JSON' do + expect(body_as_json[:id]).to eq MediaAttachment.first.id + end end end end diff --git a/spec/fixtures/files/attachment.webm b/spec/fixtures/files/attachment.webm new file mode 100644 index 000000000..3babe5cf5 Binary files /dev/null and b/spec/fixtures/files/attachment.webm differ -- cgit