test/test_mongoo.rb in mongoo-0.4.1 vs test/test_mongoo.rb in mongoo-0.4.2
- old
+ new
@@ -335,7 +335,21 @@
should "be able to set the collection name manually" do
assert_equal "people", Person.collection.name
assert_equal "spacemen", SpacePerson.collection.name
end
+
+ should "be able to use find_and_modify" do
+ p = Person.new(name: "Ben", interests: ["skydiving", "coding"])
+ p.insert!
+ p2 = Person.find_and_modify({
+ query: { name: "Ben" },
+ update: { "$push" => { "interests" => "swimming" } },
+ new: true
+ })
+ assert_equal ["skydiving", "coding", "swimming"], p2.interests
+ assert_equal ["skydiving", "coding"], p.interests
+ p.reload
+ assert_equal ["skydiving", "coding", "swimming"], p.interests
+ end
end