diff --git a/ruby/lib/jam_ruby/models/band.rb b/ruby/lib/jam_ruby/models/band.rb index 256829783..cfd554d2b 100644 --- a/ruby/lib/jam_ruby/models/band.rb +++ b/ruby/lib/jam_ruby/models/band.rb @@ -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) diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 4c6bc1a0b..0a9a69881 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -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) diff --git a/ruby/spec/jam_ruby/models/band_spec.rb b/ruby/spec/jam_ruby/models/band_spec.rb index ec48f24be..a74ec1bb6 100644 --- a/ruby/spec/jam_ruby/models/band_spec.rb +++ b/ruby/spec/jam_ruby/models/band_spec.rb @@ -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 diff --git a/ruby/spec/jam_ruby/models/user_spec.rb b/ruby/spec/jam_ruby/models/user_spec.rb index 54797df8c..e32ebc765 100644 --- a/ruby/spec/jam_ruby/models/user_spec.rb +++ b/ruby/spec/jam_ruby/models/user_spec.rb @@ -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