minor: removed deprecated @grid.put syntax
This commit is contained in:
parent
1e13187db6
commit
60f72937fd
|
@ -56,14 +56,8 @@ module Mongo
|
|||
# will be validated using an md5 hash. If validation fails, an exception will be raised.
|
||||
#
|
||||
# @return [Mongo::ObjectID] the file's id.
|
||||
def put(data, opts={}, old_opts={})
|
||||
if opts.is_a?(String)
|
||||
warn "The filename is now optional. Please pass the filename as a hash option: Grid#put(data, :filename => 'file.jpg')."
|
||||
filename = opts
|
||||
opts = old_opts
|
||||
else
|
||||
filename = opts[:filename]
|
||||
end
|
||||
def put(data, opts={})
|
||||
filename = opts[:filename]
|
||||
opts.merge!(default_grid_io_opts)
|
||||
file = GridIO.new(@files, @chunks, filename, 'w', opts=opts)
|
||||
file.write(data)
|
||||
|
|
|
@ -275,7 +275,7 @@ class DBAPITest < Test::Unit::TestCase
|
|||
def test_index_information
|
||||
assert_equal @@coll.index_information.length, 1
|
||||
|
||||
name = @@db.create_index(@@coll.name, 'a')
|
||||
name = @@coll.create_index('a')
|
||||
info = @@db.index_information(@@coll.name)
|
||||
assert_equal name, "a_1"
|
||||
assert_equal @@coll.index_information, info
|
||||
|
@ -303,7 +303,7 @@ class DBAPITest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_multiple_index_cols
|
||||
name = @@db.create_index(@@coll.name, [['a', DESCENDING], ['b', ASCENDING], ['c', DESCENDING]])
|
||||
name = @@coll.create_index([['a', DESCENDING], ['b', ASCENDING], ['c', DESCENDING]])
|
||||
info = @@db.index_information(@@coll.name)
|
||||
assert_equal 2, info.length
|
||||
|
||||
|
@ -315,7 +315,7 @@ class DBAPITest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_multiple_index_cols_with_symbols
|
||||
name = @@db.create_index(@@coll.name, [[:a, DESCENDING], [:b, ASCENDING], [:c, DESCENDING]])
|
||||
name = @@coll.create_index([[:a, DESCENDING], [:b, ASCENDING], [:c, DESCENDING]])
|
||||
info = @@db.index_information(@@coll.name)
|
||||
assert_equal 2, info.length
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class GridTest < Test::Unit::TestCase
|
|||
setup do
|
||||
@data = "GRIDDATA" * 50000
|
||||
@grid = Grid.new(@db, 'test-fs')
|
||||
@id = @grid.put(@data, 'sample', :metadata => {'app' => 'photos'})
|
||||
@id = @grid.put(@data, :filename => 'sample', :metadata => {'app' => 'photos'})
|
||||
end
|
||||
|
||||
should "retrieve the stored data" do
|
||||
|
@ -58,7 +58,7 @@ class GridTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "store the file with the old filename api" do
|
||||
id = @grid.put(@data, 'sample', :metadata => @metadata)
|
||||
id = @grid.put(@data, :filename => 'sample', :metadata => @metadata)
|
||||
file = @grid.get(id)
|
||||
assert_equal 'sample', file.filename
|
||||
assert_equal @metadata, file.metadata
|
||||
|
@ -106,7 +106,7 @@ class GridTest < Test::Unit::TestCase
|
|||
context "Storing data with a length of zero" do
|
||||
setup do
|
||||
@grid = Grid.new(@db, 'test-fs')
|
||||
@id = @grid.put('', 'sample', :metadata => {'app' => 'photos'})
|
||||
@id = @grid.put('', :filename => 'sample', :metadata => {'app' => 'photos'})
|
||||
end
|
||||
|
||||
should "return the zero length" do
|
||||
|
@ -119,7 +119,7 @@ class GridTest < Test::Unit::TestCase
|
|||
setup do
|
||||
def read_and_write_stream(filename, read_length, opts={})
|
||||
io = File.open(File.join(File.dirname(__FILE__), 'data', filename), 'r')
|
||||
id = @grid.put(io, filename + read_length.to_s, opts)
|
||||
id = @grid.put(io, opts.merge!(:filename => filename + read_length.to_s))
|
||||
file = @grid.get(id)
|
||||
io.rewind
|
||||
data = io.read
|
||||
|
|
Loading…
Reference in New Issue