Fix API sounds/show action
This commit is contained in:
parent
7b44e90814
commit
464a16e964
@ -1,9 +1,11 @@
|
||||
module API
|
||||
class SoundsController < ApplicationController
|
||||
skip_before_filter :json_filter!, only: :show
|
||||
|
||||
before_action :set_sound, only: :show
|
||||
|
||||
def show
|
||||
send_file sound.path, type: sound.mime_type
|
||||
send_file @sound.path, type: @sound.mime_type
|
||||
end
|
||||
|
||||
|
||||
|
21
spec/integration/api/sounds_spec.rb
Normal file
21
spec/integration/api/sounds_spec.rb
Normal file
@ -0,0 +1,21 @@
|
||||
describe 'API sounds' do
|
||||
before { api_sign_in }
|
||||
|
||||
describe 'sound show' do
|
||||
let(:sound) { create :sound }
|
||||
let(:request_show) { get api_sound_path sound }
|
||||
subject { response }
|
||||
|
||||
before { request_show }
|
||||
|
||||
it { is_expected.to have_http_status 200 }
|
||||
|
||||
it 'has the sound mime type as content type' do
|
||||
expect(response.content_type).to eq sound.mime_type
|
||||
end
|
||||
|
||||
it 'returns the sound file as the body' do
|
||||
expect(response.body).to eq File.read(sound.path, mode: 'rb')
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user