Leave hash arguments unmodified.
This commit is contained in:
parent
8887402ca8
commit
ba1e4679fa
@ -296,6 +296,7 @@ module Mongo
|
|||||||
if strict? && !collection_names.include?(name)
|
if strict? && !collection_names.include?(name)
|
||||||
raise Mongo::MongoDBError, "Collection #{name} doesn't exist. Currently in strict mode."
|
raise Mongo::MongoDBError, "Collection #{name} doesn't exist. Currently in strict mode."
|
||||||
else
|
else
|
||||||
|
opts = opts.dup
|
||||||
opts[:safe] = opts.fetch(:safe, @safe)
|
opts[:safe] = opts.fetch(:safe, @safe)
|
||||||
opts.merge!(:pk => @pk_factory) unless opts[:pk]
|
opts.merge!(:pk => @pk_factory) unless opts[:pk]
|
||||||
Collection.new(name, self, opts)
|
Collection.new(name, self, opts)
|
||||||
|
@ -65,6 +65,7 @@ module Mongo
|
|||||||
#
|
#
|
||||||
# @return [Mongo::ObjectId] the file's id.
|
# @return [Mongo::ObjectId] the file's id.
|
||||||
def put(data, opts={})
|
def put(data, opts={})
|
||||||
|
opts = opts.dup
|
||||||
filename = opts[:filename]
|
filename = opts[:filename]
|
||||||
opts.merge!(default_grid_io_opts)
|
opts.merge!(default_grid_io_opts)
|
||||||
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)
|
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)
|
||||||
|
@ -12,6 +12,22 @@ class GridFileSystemTest < Test::Unit::TestCase
|
|||||||
@db.drop_collection('fs.chunks')
|
@db.drop_collection('fs.chunks')
|
||||||
end
|
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
|
context "When reading:" do
|
||||||
setup do
|
setup do
|
||||||
@chunks_data = "CHUNKS" * 50000
|
@chunks_data = "CHUNKS" * 50000
|
||||||
|
Loading…
Reference in New Issue
Block a user