diff --git a/test/collection_test.rb b/test/collection_test.rb index 480931e..fe66e00 100644 --- a/test/collection_test.rb +++ b/test/collection_test.rb @@ -130,6 +130,11 @@ class TestCollection < Test::Unit::TestCase end end + def test_safe_responses + response = @@test.insert({:a => 1}, :safe => true) + assert_equal false, response + end + def test_maximum_insert_size docs = [] 16.times do @@ -556,7 +561,7 @@ class TestCollection < Test::Unit::TestCase end context "Grouping" do - setup do + setup do @@test.remove @@test.save("a" => 1) @@test.save("b" => 1) @@ -576,6 +581,23 @@ class TestCollection < Test::Unit::TestCase end end + context "Grouping with key" do + setup do + @@test.remove + @@test.save("a" => 1, "pop" => 100) + @@test.save("a" => 1, "pop" => 100) + @@test.save("a" => 2, "pop" => 100) + @@test.save("a" => 2, "pop" => 100) + @initial = {"count" => 0, "foo" => 1} + @reduce_function = "function (obj, prev) { prev.count += obj.pop; }" + end + + should "group" do + result = @@test.group([:a], {}, @initial, @reduce_function, nil) + assert result.all? { |r| r['count'] == 200 } + end + end + context "Grouping with a key function" do setup do @@test.remove