fix tests
This commit is contained in:
parent
fab83707b7
commit
6dec9a5239
|
|
@ -177,9 +177,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
# stops any active recording
|
||||
def stop_recording(user)
|
||||
def stop_recording
|
||||
current_recording = self.recording
|
||||
current_recording.stop(user) unless current_recording.nil?
|
||||
current_recording.stop unless current_recording.nil?
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
# Stop recording a session
|
||||
def stop(owner)
|
||||
def stop
|
||||
# Use a transaction and lock to avoid races.
|
||||
music_session = MusicSession.find_by_id(music_session_id)
|
||||
locker = music_session.nil? ? self : music_session
|
||||
|
|
@ -75,8 +75,8 @@ module JamRuby
|
|||
self.save
|
||||
end
|
||||
|
||||
connection = Connection.where(:user_id => owner.id).where(:music_session_id => music_session.id).first
|
||||
Notification.send_recording_ended(music_session, connection, owner)
|
||||
connection = Connection.where(:user_id => self.owner.id).where(:music_session_id => music_session.id).first
|
||||
Notification.send_recording_ended(music_session, connection, self.owner)
|
||||
|
||||
self
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ describe Mix do
|
|||
@music_session.connections << @connection
|
||||
@music_session.save
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.claim(@user, "name", "description", Genre.first, true, true)
|
||||
@mix = Mix.schedule(@recording, "{}")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -414,7 +414,7 @@ describe MusicSession do
|
|||
|
||||
describe "not recording" do
|
||||
it "stop_recording should return nil if not recording" do
|
||||
@music_session.stop_recording(@user1).should be_nil
|
||||
@music_session.stop_recording.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -428,7 +428,7 @@ describe MusicSession do
|
|||
end
|
||||
|
||||
it "stop_recording should return recording object if recording" do
|
||||
@music_session.stop_recording(@user1).should == @recording
|
||||
@music_session.stop_recording.should == @recording
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ describe 'Musician search' do
|
|||
music_session.connections << connection
|
||||
music_session.save
|
||||
recording = Recording.start(music_session, usr)
|
||||
recording.stop(usr)
|
||||
recording.stop
|
||||
recording.reload
|
||||
genre = FactoryGirl.create(:genre)
|
||||
recording.claim(usr, "name", "description", genre, true, true)
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ describe Recording do
|
|||
|
||||
it "should return the state to normal properly when you stop a recording" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@music_session.reload
|
||||
@music_session.is_recording?.should be_false
|
||||
end
|
||||
|
|
@ -60,15 +60,15 @@ describe Recording do
|
|||
|
||||
it "should error when you stop a recording twice" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.errors.any?.should be_false
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.errors.any?.should be_true
|
||||
end
|
||||
|
||||
it "should be able to start, stop then start a recording again for the same music session" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording2 = Recording.start(@music_session, @user)
|
||||
@music_session.recordings.exists?(@recording2).should be_true
|
||||
end
|
||||
|
|
@ -92,7 +92,7 @@ describe Recording do
|
|||
it "should report correctly whether its tracks have been uploaded" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.uploaded?.should == false
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@recording.uploaded?.should == false
|
||||
@recording.recorded_tracks.first.fully_uploaded = true
|
||||
|
|
@ -101,7 +101,7 @@ describe Recording do
|
|||
|
||||
it "should destroy a recording and all its recorded tracks properly" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@recorded_track = @recording.recorded_tracks.first
|
||||
@recording.destroy
|
||||
|
|
@ -111,7 +111,7 @@ describe Recording do
|
|||
|
||||
it "should allow a user to claim a recording" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@recording.claim(@user, "name", "description", @genre, true, true)
|
||||
|
|
@ -131,7 +131,7 @@ describe Recording do
|
|||
|
||||
it "should fail if a user who was not in the session claims a recording" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
user2 = FactoryGirl.create(:user)
|
||||
expect { @recording.claim(user2, "name", "description", @genre, true, true) }.to raise_error
|
||||
|
|
@ -139,7 +139,7 @@ describe Recording do
|
|||
|
||||
it "should allow editing metadata for claimed recordings" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true)
|
||||
|
|
@ -155,7 +155,7 @@ describe Recording do
|
|||
|
||||
it "should only allow the owner to edit a claimed recording" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true)
|
||||
|
|
@ -166,7 +166,7 @@ describe Recording do
|
|||
it "should record the duration of the recording properly" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.duration.should be_nil
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@recording.duration.should_not be_nil
|
||||
# Note: it will be 0 since this was fast. You can see something non-zero by just
|
||||
|
|
@ -181,7 +181,7 @@ describe Recording do
|
|||
@music_session.connections << @connection2
|
||||
@music_session.save
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true)
|
||||
|
|
@ -194,7 +194,7 @@ describe Recording do
|
|||
|
||||
it "should destroy the entire recording if there was only one claimed_recording which is discarded" do
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@claimed_recording = @recording.claim(@user, "name", "description", @genre, true, true)
|
||||
|
|
@ -206,7 +206,7 @@ describe Recording do
|
|||
it "should use the since parameter when restricting uploads" do
|
||||
stub_const("APP_CONFIG", app_config)
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@recording.claim(@user, "Recording", "Recording Description", @genre, true, true)
|
||||
|
|
@ -233,7 +233,7 @@ describe Recording do
|
|||
pending
|
||||
stub_const("APP_CONFIG", app_config)
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@recording.claim(@user, "Recording", "Recording Description", @genre, true, true)
|
||||
|
|
@ -279,7 +279,7 @@ describe Recording do
|
|||
@music_session.save
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
#sleep 4
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.recorded_tracks.length.should == 2
|
||||
@recorded_track = @recording.recorded_tracks.first
|
||||
@recorded_track.upload_start(25000, "md5hash")
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class ApiRecordingsController < ApiController
|
|||
|
||||
def stop
|
||||
|
||||
@recording.stop(current_user)
|
||||
@recording.stop
|
||||
|
||||
if @recording.errors.any?
|
||||
response.status = :unprocessable_entity
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ MusicSessionManager < BaseManager
|
|||
end
|
||||
|
||||
ConnectionManager.new.leave_music_session(user, connection, music_session) do
|
||||
recording = music_session.stop_recording(user) # stop any ongoing recording, if there is one
|
||||
recording = music_session.stop_recording # stop any ongoing recording, if there is one
|
||||
recordingId = recording.id unless recording.nil?
|
||||
Notification.send_session_depart(music_session, connection.client_id, user, recordingId)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ describe ApiClaimedRecordingsController do
|
|||
@music_session.connections << @connection
|
||||
@music_session.save
|
||||
@recording = Recording.start(@music_session, @user)
|
||||
@recording.stop(@user)
|
||||
@recording.stop
|
||||
@recording.reload
|
||||
@genre = FactoryGirl.create(:genre)
|
||||
@recording.claim(@user, "name", "description", @genre, true, true)
|
||||
|
|
|
|||
|
|
@ -349,7 +349,7 @@ module JamWebsockets
|
|||
Notification.send_friend_update(user_id, false, conn) if count == 0
|
||||
music_session = MusicSession.find_by_id(music_session_id) unless music_session_id.nil?
|
||||
user = User.find_by_id(user_id) unless user_id.nil?
|
||||
recording = music_session.stop_recording(user) unless music_session.nil? # stop any ongoing recording, if there is one
|
||||
recording = music_session.stop_recording unless music_session.nil? # stop any ongoing recording, if there is one
|
||||
recordingId = recording.id unless recording.nil?
|
||||
Notification.send_session_depart(music_session, cid, user, recordingId) unless music_session.nil? || user.nil?
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ module JamWebsockets
|
|||
# if this is a reclaim of a connection, but music_session_id comes back null, then we need to check if this connection was IN a music session before.
|
||||
# if so, then we need to tell the others in the session that this user is now departed
|
||||
unless context.nil? || music_session_upon_reentry.nil? || music_session_upon_reentry.destroyed?
|
||||
recording = music_session_upon_reentry.stop_recording(user)
|
||||
recording = music_session_upon_reentry.stop_recording
|
||||
recordingId = recording.id unless recording.nil?
|
||||
Notification.send_session_depart(music_session_upon_reentry, client.client_id, context.user, recordingId)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue