failing test case + fix for Collection#[]

This commit is contained in:
Mike Dirolf 2009-09-14 10:03:26 -04:00
parent 78f0b181e2
commit 833e0eb7da
2 changed files with 5 additions and 1 deletions

View File

@ -53,7 +53,7 @@ module Mongo
# :name :: the name of the collection to get
def [](name)
name = "#{self.name}.#{name}"
return Collection.new(self, name) if !db.strict? || db.collection_names.include?(name)
return Collection.new(db, name) if !db.strict? || db.collection_names.include?(name)
raise "Collection #{name} doesn't exist. Currently in strict mode."
end

View File

@ -42,6 +42,10 @@ class TestCollection < Test::Unit::TestCase
assert_kind_of Collection, @@db["test"]["foo"]
assert_equal @@db["test"]["foo"].name(), @@db.collection("test.foo").name()
assert_equal @@db["test"]["foo"].name(), @@db["test.foo"].name()
@@db["test"]["foo"].clear
@@db["test"]["foo"].insert("x" => 5)
assert_equal 5, @@db.collection("test.foo").find_one()["x"]
end
def test_safe_insert