Use rails configuration for sounds file path
* Add sounds_path initializer
This commit is contained in:
parent
6af1540640
commit
a8067404f4
@ -7,7 +7,7 @@ class Sound < ActiveRecord::Base
|
|||||||
validates_presence_of :mime_type
|
validates_presence_of :mime_type
|
||||||
|
|
||||||
def path
|
def path
|
||||||
"#{Rails.root}/data/sounds/#{sha256}"
|
"#{Rails.configuration.sounds_path}/#{sha256}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def file=(file)
|
def file=(file)
|
||||||
|
1
config/initializers/sounds_path.rb
Normal file
1
config/initializers/sounds_path.rb
Normal file
@ -0,0 +1 @@
|
|||||||
|
Scube::Application.config.sounds_path = "#{Rails.root}/data/sounds"
|
@ -10,8 +10,12 @@ describe Sound do
|
|||||||
it { should validate_presence_of :mime_type }
|
it { should validate_presence_of :mime_type }
|
||||||
|
|
||||||
describe '#path' do
|
describe '#path' do
|
||||||
|
it 'starts by the path specified in Rails.configuration.sound_path' do
|
||||||
|
sound.path.should match(/\A#{Rails.configuration.sounds_path}/)
|
||||||
|
end
|
||||||
|
|
||||||
it 'returns the sound file path based on the SHA256 digest' do
|
it 'returns the sound file path based on the SHA256 digest' do
|
||||||
sound.path.should == "#{Rails.root}/data/sounds/#{sound.sha256}"
|
sound.path.should == "#{Rails.configuration.sounds_path}/#{sound.sha256}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ Spork.prefork do
|
|||||||
config.mock_with :rspec
|
config.mock_with :rspec
|
||||||
config.use_transactional_fixtures = true
|
config.use_transactional_fixtures = true
|
||||||
config.after(:all) do
|
config.after(:all) do
|
||||||
`rm -f #{Rails.root}/data/sounds/*`
|
`rm -f #{Rails.configuration.sounds_path}/*`
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user