From 94f5214e454e440ec9cd718071f3fb36fc3efc3f Mon Sep 17 00:00:00 2001 From: Jim Menard Date: Fri, 16 Jan 2009 13:24:49 -0500 Subject: [PATCH] Simplified DB#collection logic. Removed assert that only worked coincidentally. --- lib/mongo/db.rb | 8 ++------ tests/test_db_api.rb | 1 - 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/mongo/db.rb b/lib/mongo/db.rb index 2459250..84a5d9e 100644 --- a/lib/mongo/db.rb +++ b/lib/mongo/db.rb @@ -148,12 +148,8 @@ module XGen # new collection. If +strict+ is true, will raise an error if # collection +name+ does not already exists. def collection(name) - return Collection.new(self, name) if collection_names.include?(full_coll_name(name)) - if strict? - raise "Collection #{name} doesn't exist. Currently in strict mode." - else - create_collection(name) - end + return Collection.new(self, name) if !strict? || collection_names.include?(full_coll_name(name)) + raise "Collection #{name} doesn't exist. Currently in strict mode." end # Drop collection +name+. Returns +true+ on success or if the diff --git a/tests/test_db_api.rb b/tests/test_db_api.rb index abbf10f..f69cc27 100644 --- a/tests/test_db_api.rb +++ b/tests/test_db_api.rb @@ -232,7 +232,6 @@ class DBAPITest < Test::Unit::TestCase assert rows.length >= 1 row = rows.detect { |r| r['name'] == @coll_full_name } assert_not_nil row - assert_equal @coll.name, row['options']['create'] end def test_collection_options