test/test-tallyable.rb in ohm-tallyable-0.1.4 vs test/test-tallyable.rb in ohm-tallyable-0.1.5
- old
+ new
@@ -43,10 +43,19 @@
def test_delete
Event[1].delete
l = Event.leaderboard(:location)
assert_equal [], l
end
+
+ def test_retally
+ Event.create(location: "Buenos Aires")
+ Event.create(location: "Rosario")
+ Event.retally(:location)
+
+ l = Event.leaderboard(:location)
+ assert_equal [["Buenos Aires", 2], ["Rosario", 1]], l
+ end
end
class Post < Ohm::Model
include Ohm::Callbacks
include Ohm::Tallyable
@@ -94,7 +103,19 @@
Post.leaderboard(:category)
end
assert_raise(ArgumentError) do
Post.leaderboard(:category, foo: "bar")
end
+ end
+
+ def test_retally
+ Post.retally(:category)
+ l = Post.leaderboard(:category, site: "ar")
+ assert_equal [["Personal", 2], ["Work", 1]], l
+ end
+
+ def post_retally_all
+ Post.retally(:category)
+ l = Post.leaderboard(:category, site: "ar")
+ assert_equal [["Personal", 2], ["Work", 1]], l
end
end