Ensure related sound is created when saving a track with a file
This commit is contained in:
parent
37735a354d
commit
ab1af50be6
@ -3,14 +3,26 @@ require 'spec_helper'
|
|||||||
describe Track do
|
describe Track do
|
||||||
subject { track }
|
subject { track }
|
||||||
let(:track) { Factory.build(:track) }
|
let(:track) { Factory.build(:track) }
|
||||||
|
let(:file) { Factory.attributes_for(:track_with_sound)[:file] }
|
||||||
|
|
||||||
it { should be_valid }
|
it { should be_valid }
|
||||||
it { should have_many :sounds }
|
it { should have_many :sounds }
|
||||||
it { should validate_presence_of :name }
|
it { should validate_presence_of :name }
|
||||||
|
|
||||||
|
context 'with a file' do
|
||||||
|
before do
|
||||||
|
track.file = file
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates a sound for the track' do
|
||||||
|
expect {
|
||||||
|
track.save
|
||||||
|
}.to change(track.sounds, :count).by(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#file=' do
|
describe '#file=' do
|
||||||
it 'builds a new related sound with the file' do
|
it 'builds a new related sound with the file' do
|
||||||
file = Factory.attributes_for(:track_with_sound)[:file]
|
|
||||||
sounds = mock('sounds association proxy')
|
sounds = mock('sounds association proxy')
|
||||||
track.stub(:sounds => sounds)
|
track.stub(:sounds => sounds)
|
||||||
sounds.should_receive(:build).with({:file => file})
|
sounds.should_receive(:build).with({:file => file})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user