GridStore#mv
This commit is contained in:
parent
8a8d6716b3
commit
3b30cde0fb
@ -128,6 +128,10 @@ module GridFS
|
||||
end
|
||||
alias_method :delete, :unlink
|
||||
|
||||
def mv(db, src, dest, root_collection=DEFAULT_ROOT_COLLECTION)
|
||||
db.collection("#{root_collection}.files").update({ :filename => src }, { '$set' => { :filename => dest } })
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#---
|
||||
|
@ -152,6 +152,16 @@ class GridStoreTest < Test::Unit::TestCase
|
||||
assert_equal 0, @@chunks.count
|
||||
end
|
||||
|
||||
def test_mv
|
||||
assert_equal 1, @@files.count
|
||||
assert_equal 1, @@chunks.count
|
||||
GridStore.mv(@@db, 'foobar', 'bazqux')
|
||||
assert_equal 1, @@files.count
|
||||
assert_equal 1, @@chunks.count
|
||||
assert !GridStore.exist?(@@db, 'foobar')
|
||||
assert GridStore.exist?(@@db, 'bazqux')
|
||||
end
|
||||
|
||||
def test_append
|
||||
GridStore.open(@@db, 'foobar', 'w+') { |f| f.write(" how are you?") }
|
||||
assert_equal 1, @@chunks.count
|
||||
|
Loading…
Reference in New Issue
Block a user