Add track/{new,create} with file upload for the track
This commit is contained in:
@@ -15,4 +15,24 @@ describe Track do
|
||||
|
||||
it { should_not be_valid }
|
||||
end
|
||||
|
||||
describe '#uploaded_file=' do
|
||||
let(:track) { Track.new :name => 'Mega song' }
|
||||
|
||||
it 'saves an uploaded file' do
|
||||
filepath = "#{Rails.root}/spec/fixtures/test.mp3"
|
||||
file = mock(Rack::Test::UploadedFile)
|
||||
file.stub(
|
||||
:tempfile => File.new(filepath),
|
||||
:content_type => 'audio/mpeg'
|
||||
)
|
||||
track.uploaded_file = file
|
||||
track.save
|
||||
File.read("#{Rails.root}/data/tracks/#{track.id.to_s}").should == File.read(filepath)
|
||||
end
|
||||
|
||||
after do
|
||||
`rm -rf #{Rails.root}/data/tracks/*`
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user