diff --git a/lib/mongo/collection.rb b/lib/mongo/collection.rb index 462226f..c4184fc 100644 --- a/lib/mongo/collection.rb +++ b/lib/mongo/collection.rb @@ -264,7 +264,7 @@ module Mongo message.put_array(BSON.serialize(selector, false).to_a) if opts[:safe] - @connection.send_message_with_safe_check(Mongo::Constants::OP_DELETE, message, + @connection.send_message_with_safe_check(Mongo::Constants::OP_DELETE, message, @db.name, "db.#{@db.name}.remove(#{selector.inspect})") # the return value of send_message_with_safe_check isn't actually meaningful -- # only the fact that it didn't raise an error is -- so just return true diff --git a/lib/mongo/gridfs/grid_io.rb b/lib/mongo/gridfs/grid_io.rb index b54142e..9802b35 100644 --- a/lib/mongo/gridfs/grid_io.rb +++ b/lib/mongo/gridfs/grid_io.rb @@ -152,10 +152,11 @@ module Mongo chunk['n'] = n chunk['files_id'] = @files_id chunk['data'] = '' - @chunk_position = 0 + @chunk_position = 0 chunk end + # TODO: Perhaps use an upsert here instead? def save_chunk(chunk) @chunks.remove('_id' => chunk['_id']) @chunks.insert(chunk) diff --git a/test/test_collection.rb b/test/test_collection.rb index e71bb98..eb0ed4e 100644 --- a/test/test_collection.rb +++ b/test/test_collection.rb @@ -191,7 +191,7 @@ class TestCollection < Test::Unit::TestCase end end - def test_safe_remove + def test_mocked_safe_remove @conn = Connection.new @db = @conn['mongo-ruby-test'] @test = @db['test-safe-remove'] @@ -204,6 +204,15 @@ class TestCollection < Test::Unit::TestCase @test.drop end + def test_safe_remove + @conn = Connection.new + @db = @conn['mongo-ruby-test'] + @test = @db['test-safe-remove'] + @test.save({:a => 50}) + @test.remove({}, :safe => true) + @test.drop + end + def test_count @@test.drop diff --git a/test/test_db.rb b/test/test_db.rb index 20ad39f..3cbd9e6 100644 --- a/test/test_db.rb +++ b/test/test_db.rb @@ -204,8 +204,8 @@ class DBTest < Test::Unit::TestCase def test_user_management @@db.add_user("bob", "secret") - @@db.logout assert @@db.authenticate("bob", "secret") + @@db.logout assert @@db.remove_user("bob") assert !@@db.authenticate("bob", "secret") end