fixed bug on safe remove; style fixes
This commit is contained in:
parent
f176a45a20
commit
5d1d110280
|
@ -264,7 +264,7 @@ module Mongo
|
||||||
message.put_array(BSON.serialize(selector, false).to_a)
|
message.put_array(BSON.serialize(selector, false).to_a)
|
||||||
|
|
||||||
if opts[:safe]
|
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})")
|
"db.#{@db.name}.remove(#{selector.inspect})")
|
||||||
# the return value of send_message_with_safe_check isn't actually meaningful --
|
# 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
|
# only the fact that it didn't raise an error is -- so just return true
|
||||||
|
|
|
@ -152,10 +152,11 @@ module Mongo
|
||||||
chunk['n'] = n
|
chunk['n'] = n
|
||||||
chunk['files_id'] = @files_id
|
chunk['files_id'] = @files_id
|
||||||
chunk['data'] = ''
|
chunk['data'] = ''
|
||||||
@chunk_position = 0
|
@chunk_position = 0
|
||||||
chunk
|
chunk
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO: Perhaps use an upsert here instead?
|
||||||
def save_chunk(chunk)
|
def save_chunk(chunk)
|
||||||
@chunks.remove('_id' => chunk['_id'])
|
@chunks.remove('_id' => chunk['_id'])
|
||||||
@chunks.insert(chunk)
|
@chunks.insert(chunk)
|
||||||
|
|
|
@ -191,7 +191,7 @@ class TestCollection < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_safe_remove
|
def test_mocked_safe_remove
|
||||||
@conn = Connection.new
|
@conn = Connection.new
|
||||||
@db = @conn['mongo-ruby-test']
|
@db = @conn['mongo-ruby-test']
|
||||||
@test = @db['test-safe-remove']
|
@test = @db['test-safe-remove']
|
||||||
|
@ -204,6 +204,15 @@ class TestCollection < Test::Unit::TestCase
|
||||||
@test.drop
|
@test.drop
|
||||||
end
|
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
|
def test_count
|
||||||
@@test.drop
|
@@test.drop
|
||||||
|
|
||||||
|
|
|
@ -204,8 +204,8 @@ class DBTest < Test::Unit::TestCase
|
||||||
|
|
||||||
def test_user_management
|
def test_user_management
|
||||||
@@db.add_user("bob", "secret")
|
@@db.add_user("bob", "secret")
|
||||||
@@db.logout
|
|
||||||
assert @@db.authenticate("bob", "secret")
|
assert @@db.authenticate("bob", "secret")
|
||||||
|
@@db.logout
|
||||||
assert @@db.remove_user("bob")
|
assert @@db.remove_user("bob")
|
||||||
assert !@@db.authenticate("bob", "secret")
|
assert !@@db.authenticate("bob", "secret")
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue