Leave hash arguments unmodified.

This commit is contained in:
Kyle Banker 2011-04-27 11:10:48 -04:00
parent 8887402ca8
commit ba1e4679fa
3 changed files with 18 additions and 0 deletions

View File

@ -296,6 +296,7 @@ module Mongo
if strict? && !collection_names.include?(name)
raise Mongo::MongoDBError, "Collection #{name} doesn't exist. Currently in strict mode."
else
opts = opts.dup
opts[:safe] = opts.fetch(:safe, @safe)
opts.merge!(:pk => @pk_factory) unless opts[:pk]
Collection.new(name, self, opts)

View File

@ -65,6 +65,7 @@ module Mongo
#
# @return [Mongo::ObjectId] the file's id.
def put(data, opts={})
opts = opts.dup
filename = opts[:filename]
opts.merge!(default_grid_io_opts)
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)

View File

@ -12,6 +12,22 @@ class GridFileSystemTest < Test::Unit::TestCase
@db.drop_collection('fs.chunks')
end
context "Initialization" do
setup do
@chunks_data = "CHUNKS" * 50000
@grid = GridFileSystem.new(@db)
@opts = {:safe => true}
@original_opts = @opts.dup
@grid.open('sample.file', 'w', @opts) do |f|
f.write @chunks_data
end
end
should "not modify original opts" do
assert_equal @original_opts, @opts
end
end
context "When reading:" do
setup do
@chunks_data = "CHUNKS" * 50000