Add track/{new,create} with file upload for the track

This commit is contained in:
Thibault Jouan
2011-07-23 17:55:25 +00:00
parent 34b38b77cf
commit 6af96b0f75
12 changed files with 159 additions and 0 deletions

View File

@@ -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