VRFS-2463 added tests for excluding currently viewed sessions/recordings

This commit is contained in:
Brian Smith 2014-12-07 21:35:30 -05:00
parent 354f6320fc
commit 605bdbcbf6
4 changed files with 23 additions and 6 deletions

View File

@ -78,9 +78,9 @@ module JamRuby
lng
end
def recent_history(session_id, recording_id)
def recent_history(session_id, claimed_recording_id)
recording_exclusion = "claimed_recordings.id != '#{recording_id}'" if recording_id
recording_exclusion = "claimed_recordings.id != '#{claimed_recording_id}'" if claimed_recording_id
recordings = Recording
.joins(:claimed_recordings)
.where(:band_id => self.id)

View File

@ -439,9 +439,9 @@ module JamRuby
mods_json[:connection_expire_time_client]
end
def recent_history(session_id, recording_id)
def recent_history(session_id, claimed_recording_id)
# used to exclude currently viewed recording
recording_exclusion = "claimed_recordings.id != '#{recording_id}'" if recording_id
recording_exclusion = "claimed_recordings.id != '#{claimed_recording_id}'" if claimed_recording_id
recordings = Recording
.joins(:claimed_recordings)
.where(:owner_id => self.id)

View File

@ -150,9 +150,13 @@ describe Band do
Recording.where(:owner_id => user.id).size.should == 2
Recording.where(:band_id => band.id).size.should == 2
history = band.recent_history
history = band.recent_history(nil, nil)
history.size.should == 1
history.first.id.should == claimed_recording.recording.id
# exclude the claimed recording
history = band.recent_history(nil, claimed_recording.id)
history.size.should == 0
end
end
end

View File

@ -560,9 +560,22 @@ describe User do
Recording.where(:owner_id => user.id).size.should == 2
history = user.recent_history
history = user.recent_history(nil, nil)
history.size.should == 1
history.first.id.should == claimed_recording.recording.id
# exclude the claimed recording
history = user.recent_history(nil, claimed_recording.id)
history.size.should == 0
end
it "should not retrieve excluded session" do
music_session = FactoryGirl.create(:music_session)
history = music_session.creator.recent_history(nil, nil)
history.size.should == 1
history = music_session.creator.recent_history(music_session.id, nil)
history.size.should == 0
end
end