spec/support/gridfs.rb in mongo-2.6.4 vs spec/support/gridfs.rb in mongo-2.7.0.rc0

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (C) 2014-2018 MongoDB, Inc. +# Copyright (C) 2014-2019 MongoDB, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # @@ -231,11 +231,11 @@ id elsif value.is_a?(BSON::ObjectId) value elsif value['$oid'] BSON::ObjectId.from_string(value['$oid']) - else + else BSON::ObjectId.new end end # Convert options. @@ -331,10 +331,11 @@ # # @param [ Mongo::Grid::FSBucket ] fs The Grid::FSBucket to use in the test. # # @since 2.1.0 def run(fs) + clear_collections(fs) setup(fs) @operation.run(fs) end # Clear the files and chunks collection in the FSBucket and other collections used in the test. @@ -345,12 +346,14 @@ # @param [ Mongo::Grid::FSBucket ] fs The Grid::FSBucket whose collections should be cleared. # # @since 2.1.0 def clear_collections(fs) fs.files_collection.delete_many + fs.files_collection.indexes.drop_all rescue nil fs.chunks_collection.delete_many - @operation.clear_collections(fs) + fs.chunks_collection.indexes.drop_all rescue nil + #@operation.clear_collections(fs) end private def setup(fs) @@ -496,11 +499,11 @@ else opts = { files_id: @result } end coll.insert_many(transform_docs(data['documents'], opts)) end - + def delete_exp_data(fs, data) coll = fs.database[data['delete']] data['deletes'].each do |del| id = del['q'].keys.first coll.find(id => to_oid(del['q'][id])).send("delete_#{limit(del['limit'])}") @@ -587,10 +590,10 @@ # @since 2.1.0 def error? false end end - + class UnsuccessfulOp include Convertible include Test::Operable # Whether this operation is expected to raise an error.