Permalink
Browse files

Fixed a bug in remove_member that would remove all of the optional me…

…mber data
  • Loading branch information...
1 parent e9c4e6b commit 5a1197dc7e939366930e6c0663935617d04cc572 @czarneckid czarneckid committed Dec 19, 2012
Showing with 19 additions and 3 deletions.
  1. +4 −0 CHANGELOG.markdown
  2. +1 −1 lib/leaderboard.rb
  3. +1 −1 lib/leaderboard/version.rb
  4. +12 −0 spec/leaderboard_spec.rb
  5. +1 −1 spec/version_spec.rb
View
@@ -1,5 +1,9 @@
# CHANGELOG
+## leaderboard 3.0.1 (2012-12-19)
+
+* Fixed a bug in `remove_member` that would remove all of the optional member data.
+
## leaderboard 3.0.0 (2012-12-03)
* Added `rank_member_if` and `rank_member_if_in` methods that allow you to rank a member in the leaderboard based on execution of a lambda.
View
@@ -255,7 +255,7 @@ def remove_member(member)
def remove_member_from(leaderboard_name, member)
@redis_connection.multi do |transaction|
transaction.zrem(leaderboard_name, member)
- transaction.del(member_data_key(leaderboard_name), member)
+ transaction.hdel(member_data_key(leaderboard_name), member)
end
end
@@ -1,4 +1,4 @@
class Leaderboard
# Leaderboard version
- VERSION = '3.0.0'.freeze
+ VERSION = '3.0.1'.freeze
end
View
@@ -659,4 +659,16 @@
@leaderboard.rank_member_if(highscore_check, 'david', 1338)
@leaderboard.score_for('david').should eql(1338.0)
end
+
+ it 'should not delete all the member data when calling remove_member' do
+ rank_members_in_leaderboard
+
+ @redis_connection.exists("name:member_data").should be_true
+ @redis_connection.hgetall("name:member_data").size.should be(5)
+ @leaderboard.total_members.should be(5)
+ @leaderboard.remove_member('member_1')
+ @redis_connection.exists("name:member_data").should be_true
+ @redis_connection.hgetall("name:member_data").size.should be(4)
+ @leaderboard.total_members.should be(4)
+ end
end
View
@@ -2,6 +2,6 @@
describe 'Leaderboard::VERSION' do
it 'should be the correct version' do
- Leaderboard::VERSION.should == '3.0.0'
+ Leaderboard::VERSION.should == '3.0.1'
end
end

0 comments on commit 5a1197d

Please sign in to comment.