jam-cloud/ruby/spec/jam_ruby/models/track_spec.rb

96 lines
3.4 KiB
Ruby

require 'spec_helper'
describe Track do
pending "recording_session_landing broken tests"
let (:connection) { FactoryGirl.create(:connection) }
let (:track) { FactoryGirl.create(:track, :connection => connection)}
let (:track2) { FactoryGirl.create(:track, :connection => connection)}
let (:track_hash) { {:client_track_id => 'client_guid', :sound => 'stereo', :instrument_id => 'drums'} }
before(:each) do
end
describe "sync" do
it "create one track" do
tracks = Track.sync(connection.client_id, [track_hash])
tracks.length.should == 1
track = tracks[0]
track.client_track_id.should == track_hash[:client_track_id]
track.sound = track_hash[:sound]
track.instrument.should == Instrument.find('drums')
end
it "create two tracks" do
tracks = Track.sync(connection.client_id, [track_hash, track_hash])
tracks.length.should == 2
track = tracks[0]
track.client_track_id.should == track_hash[:client_track_id]
track.sound = track_hash[:sound]
track.instrument.should == Instrument.find('drums')
track = tracks[1]
track.client_track_id.should == track_hash[:client_track_id]
track.sound = track_hash[:sound]
track.instrument.should == Instrument.find('drums')
end
it "delete only track" do
track.id.should_not be_nil
connection.tracks.length.should == 1
tracks = Track.sync(connection.client_id, [])
tracks.length.should == 0
end
it "delete one of two tracks using .id to correlate" do
track.id.should_not be_nil
track2.id.should_not be_nil
connection.tracks.length.should == 2
tracks = Track.sync(connection.client_id, [{:id => track.id, :client_track_id => 'client_guid_new', :sound => 'mono', :instrument_id => 'drums'}])
tracks.length.should == 1
found = tracks[0]
found.id.should == track.id
found.sound.should == 'mono'
found.client_track_id.should == 'client_guid_new'
end
it "delete one of two tracks using .client_track_id to correlate" do
track.id.should_not be_nil
track2.id.should_not be_nil
connection.tracks.length.should == 2
tracks = Track.sync(connection.client_id, [{:client_track_id => track.client_track_id, :sound => 'mono', :instrument_id => 'drums'}])
tracks.length.should == 1
found = tracks[0]
found.id.should == track.id
found.sound.should == 'mono'
found.client_track_id.should == track.client_track_id
end
it "updates a single track using .id to correlate" do
track.id.should_not be_nil
connection.tracks.length.should == 1
tracks = Track.sync(connection.client_id, [{:id => track.id, :client_track_id => 'client_guid_new', :sound => 'mono', :instrument_id => 'drums'}])
tracks.length.should == 1
found = tracks[0]
found.id.should == track.id
found.sound.should == 'mono'
found.client_track_id.should == 'client_guid_new'
end
it "updates a single track using .client_track_id to correlate" do
track.id.should_not be_nil
connection.tracks.length.should == 1
tracks = Track.sync(connection.client_id, [{:client_track_id => track.client_track_id, :sound => 'mono', :instrument_id => 'drums'}])
tracks.length.should == 1
found = tracks[0]
found.id.should == track.id
found.sound.should == 'mono'
found.client_track_id.should == track.client_track_id
end
end
end