Update to rails 3.1.0
* Bump rails version to 3.1.0 in Gemfile * Update config files * Fix bcrypt monkey patch for specs * Fix TracksController * Replace track streaming with track download * Remove assets from application layout
This commit is contained in:
@@ -13,21 +13,16 @@ describe TracksController do
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET stream' do
|
||||
describe 'GET download' do
|
||||
let(:track) { Factory.create(:track) }
|
||||
|
||||
it 'streams the requested track' do
|
||||
get :stream, :id => track.id.to_s
|
||||
get :download, :id => track.id.to_s
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'creates a streamer instance' do
|
||||
Streamer.should_receive(:new).with(track.filepath)
|
||||
get :stream, :id => track.id.to_s
|
||||
end
|
||||
|
||||
it 'returns the track mime-type as content-type' do
|
||||
get :stream, :id => track.id.to_s
|
||||
get :download, :id => track.id.to_s
|
||||
response.content_type.should == track.mime_type
|
||||
end
|
||||
end
|
||||
@@ -42,10 +37,7 @@ describe TracksController do
|
||||
describe 'POST create' do
|
||||
let(:track) { mock_model(Track).as_null_object }
|
||||
let(:file) {
|
||||
file = mock(Rack::Test::UploadedFile)
|
||||
file.stub(:tempfile => File.new("#{Rails.root}/spec/fixtures/test.mp3"))
|
||||
file.stub(:content_type => 'audio/ogg')
|
||||
file
|
||||
fixture_file_upload("#{Rails.root}/spec/fixtures/test.mp3", 'audio/mpeg')
|
||||
}
|
||||
before { Track.stub(:new).and_return(track) }
|
||||
|
||||
@@ -62,7 +54,7 @@ describe TracksController do
|
||||
|
||||
it 'saves the track with a file' do
|
||||
track.should_receive(:save_with_file).
|
||||
with(file.tempfile, 'audio/ogg')
|
||||
with(file, 'audio/mpeg')
|
||||
post :create, :track => { :file => file }
|
||||
end
|
||||
|
||||
|
@@ -8,6 +8,10 @@ FactoryGirl.define do
|
||||
name 'Mega song'
|
||||
mime_type 'audio/ogg'
|
||||
sha256 '94a5486a69a7261da350c57f9e5a1eaa789e08752cfc56a1989976a6ad82f7a8'
|
||||
|
||||
after_create do |t|
|
||||
t.save_with_file(File.new("#{Rails.root}/spec/fixtures/test.mp3"), 'audio/mpeg')
|
||||
end
|
||||
end
|
||||
|
||||
factory :user do
|
||||
|
@@ -34,7 +34,7 @@ feature 'Tracks' do
|
||||
|
||||
visit track_path(track)
|
||||
|
||||
page.should have_xpath "//audio[@src='#{stream_track_path(track)}']"
|
||||
page.should have_xpath "//audio[@src='#{download_track_path(track)}']"
|
||||
visit find('audio')[:src]
|
||||
end
|
||||
|
||||
|
@@ -1,19 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Streamer do
|
||||
describe '#each' do
|
||||
let(:stream) { Streamer.new("#{Rails.root}/spec/fixtures/test.mp3") }
|
||||
|
||||
it 'returns file content' do
|
||||
chunks = ''
|
||||
stream.each { |c| chunks << c }
|
||||
chunks.should == File.read("#{Rails.root}/spec/fixtures/test.mp3")
|
||||
end
|
||||
|
||||
it 'returns content in multiple chunks' do
|
||||
count = 0
|
||||
stream.each { count += 1 }
|
||||
count.should be >= 2
|
||||
end
|
||||
end
|
||||
end
|
@@ -2,9 +2,7 @@ require 'bcrypt'
|
||||
|
||||
module BCrypt
|
||||
class Engine
|
||||
[:DEFAULT_COST, :MIN_COST].each do |sym|
|
||||
remove_const sym
|
||||
const_set sym, 1
|
||||
end
|
||||
remove_const :DEFAULT_COST
|
||||
const_set :DEFAULT_COST, 4
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user