Permalink
Browse files

Merge pull request #33 from agoragames/fix-remove-member-removes-all-…

…member-data

Fixed a bug in remove_member that would remove all of the optional membe...
  • Loading branch information...
2 parents e9c4e6b + 5a1197d commit 196c1799101c77eb120f2ed285779899eccd704c @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 196c179

Please sign in to comment.