From 6c0b3723e9bec25dd32b65ae6c69b6f5611b1f47 Mon Sep 17 00:00:00 2001 From: John Ewart Date: Thu, 15 Dec 2011 08:06:01 -0800 Subject: [PATCH] =?UTF-8?q?Adding=20test=20for=20the=20:out=20=3D>=20{:db?= =?UTF-8?q?=20=E2=80=A6}=20key?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Forgot to add the test in the last commit. --- test/collection_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/collection_test.rb b/test/collection_test.rb index df61389..d3f46a9 100644 --- a/test/collection_test.rb +++ b/test/collection_test.rb @@ -546,6 +546,19 @@ class TestCollection < Test::Unit::TestCase @@test.map_reduce(m, r, :raw => true, :out => {:inline => 1}) assert res["results"] end + + def test_map_reduce_with_collection_output_to_other_db + @@test << {:user_id => 1} + @@test << {:user_id => 2} + + m = Code.new("function() { emit(this.user_id, 1); }") + r = Code.new("function(k,vals) { return 1; }") + res = @@test.map_reduce(m, r, :out => {:replace => 'foo', :db => 'somedb'}) + assert res["result"] + assert res["counts"] + assert res["timeMillis"] + assert res.find.to_a.any? {|doc| doc["_id"] == 2 && doc["value"] == 1} + end end end