deprecate mongo, mongoid, and redis truncation strategies in favor of deletion.
This commit is contained in:
parent
bb7de6f836
commit
a076e1e442
|
@ -3,12 +3,14 @@
|
|||
== Changes
|
||||
* Remove unnecessary dependency on database_cleaner-mongo from database_cleaner-mongoid: @botandrose
|
||||
* Enable the :cache_tables option for the mongo truncation strategy, and default to true: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
||||
* Introduce deletion aliases for truncation strategies for mongo, mongoid, and redis adapters. https://github.com/DatabaseCleaner/database_cleaner/pull/654
|
||||
|
||||
== Deprecations
|
||||
* Deprecate all #orm= setter methods: https://github.com/DatabaseCleaner/database_cleaner/pull/643
|
||||
* Deprecate non-functional :reset_ids option in ActiveRecord truncation strategy: https://github.com/DatabaseCleaner/database_cleaner/issues/559
|
||||
* Deprecate mongo truncation's `:cache_tables => true` option in favor of `false`, to prep for caching removal in v2.0: https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
||||
* Deprecate redis truncation's #url method in favor of #db: @botandrose
|
||||
* Deprecate mongo, mongoid, and redis truncation strategies in favor of deletion. https://github.com/DatabaseCleaner/database_cleaner/pull/654
|
||||
|
||||
== Bugfixes
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'database_cleaner/mongo/version'
|
||||
require 'database_cleaner'
|
||||
require 'database_cleaner/mongo/truncation'
|
||||
require 'database_cleaner/mongo/deletion'
|
||||
|
||||
module DatabaseCleaner::Mongo
|
||||
def self.default_strategy
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
module DatabaseCleaner
|
||||
module Mongo
|
||||
def self.available_strategies
|
||||
%w[truncation]
|
||||
%w[truncation deletion]
|
||||
end
|
||||
module Base
|
||||
def db=(desired_db)
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
require 'database_cleaner/mongo/truncation'
|
||||
|
||||
module DatabaseCleaner
|
||||
module Mongo
|
||||
class Deletion < Truncation
|
||||
end
|
||||
end
|
||||
end
|
|
@ -15,7 +15,7 @@ module DatabaseCleaner
|
|||
def initialize(opts={})
|
||||
super
|
||||
if !opts.has_key?(:cache_tables) || opts[:cache_tables]
|
||||
DatabaseCleaner.deprecate "The mongo adapter caches collection names between cleanings. However, this behavior can introduce test-order-dependency issues, because the collections that exist after the first test has executed are saved and used for the remainder of the suite. This means that any collection created during the subsequent tests are not cleaned! This is fixed in database_cleaner-mongo 2.0 by removing this collection caching functionality altogether. To ease the transition into this new behavior, it can be opted into by specifying the `:cache_tables` option to false: `DatabaseCleaner[:mongo].strategy = :truncation, cache_tables: false`. For more information, see https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
||||
DatabaseCleaner.deprecate "The mongo adapter caches collection names between cleanings. However, this behavior can introduce test-order-dependency issues, because the collections that exist after the first test has executed are saved and used for the remainder of the suite. This means that any collection created during the subsequent tests are not cleaned! This is fixed in database_cleaner-mongo 2.0 by removing this collection caching functionality altogether. To ease the transition into this new behavior, it can be opted into by specifying the `:cache_tables` option to false: `DatabaseCleaner[:mongo].strategy = :deletion, cache_tables: false`. For more information, see https://github.com/DatabaseCleaner/database_cleaner/pull/646"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require "database_cleaner/mongoid/version"
|
||||
require "database_cleaner"
|
||||
require "database_cleaner/mongoid/truncation"
|
||||
require "database_cleaner/mongoid/deletion"
|
||||
|
||||
module DatabaseCleaner::Mongoid
|
||||
def self.default_strategy
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'database_cleaner/generic/base'
|
|||
module DatabaseCleaner
|
||||
module Mongoid
|
||||
def self.available_strategies
|
||||
%w[truncation]
|
||||
%w[truncation deletion]
|
||||
end
|
||||
|
||||
module Base
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
require 'database_cleaner/mongoid/truncation'
|
||||
|
||||
module DatabaseCleaner
|
||||
module Mongoid
|
||||
class Deletion < Truncation
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
require "database_cleaner/redis/version"
|
||||
require "database_cleaner"
|
||||
require "database_cleaner/redis/truncation"
|
||||
require "database_cleaner/redis/deletion"
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ require 'database_cleaner/deprecation'
|
|||
module DatabaseCleaner
|
||||
module Redis
|
||||
def self.available_strategies
|
||||
%w{truncation}
|
||||
%w{truncation deletion}
|
||||
end
|
||||
|
||||
def self.default_strategy
|
||||
|
@ -23,7 +23,7 @@ module DatabaseCleaner
|
|||
end
|
||||
|
||||
def url
|
||||
DatabaseCleaner.deprecate "The redis truncation strategy's #url method is deprecated. It will be removed in database_cleaner-redis 2.0 in favor of #db."
|
||||
DatabaseCleaner.deprecate "The redis deletion strategy's #url method is deprecated. It will be removed in database_cleaner-redis 2.0 in favor of #db."
|
||||
db
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
require 'database_cleaner/redis/truncation'
|
||||
|
||||
module DatabaseCleaner
|
||||
module Redis
|
||||
class Deletion < Truncation
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -30,6 +30,13 @@ module DatabaseCleaner
|
|||
|
||||
def strategy=(args)
|
||||
strategy, *strategy_args = args
|
||||
|
||||
if DatabaseCleaner.called_externally?(__FILE__, caller) \
|
||||
&& [:redis, :mongo, :mongoid].include?(orm) \
|
||||
&& strategy == :truncation
|
||||
DatabaseCleaner.deprecate "The #{orm} adapter's :truncation strategy will be renamed to :deletion in database_cleaner-#{orm} 2.0. Please specify the :deletion adapter to resolve this deprecation notice."
|
||||
end
|
||||
|
||||
@strategy = if strategy.is_a?(Symbol)
|
||||
create_strategy(*args)
|
||||
elsif strategy_args.empty?
|
||||
|
|
|
@ -458,5 +458,27 @@ No known ORM was detected! Is ActiveRecord, DataMapper, MongoMapper, Mongoid, M
|
|||
cleaner.orm = :mongoid
|
||||
end
|
||||
end
|
||||
|
||||
describe "deprecations regarding renaming truncation to deletion" do
|
||||
it "shows a deprecation warning if truncation strategy is explicitly specified" do
|
||||
expect(DatabaseCleaner).to receive(:deprecate)
|
||||
cleaner = DatabaseCleaner::Base.new(:mongoid)
|
||||
cleaner.strategy = :truncation
|
||||
expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Mongoid::Truncation
|
||||
end
|
||||
|
||||
it "defaults to truncation without a deprecation warning strategy is not specified" do
|
||||
expect(DatabaseCleaner).to_not receive(:deprecate)
|
||||
cleaner = DatabaseCleaner::Base.new(:mongoid)
|
||||
expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Mongoid::Truncation
|
||||
end
|
||||
|
||||
it "accepts new deletion strategy without a deprecation warning" do
|
||||
expect(DatabaseCleaner).to_not receive(:deprecate)
|
||||
cleaner = DatabaseCleaner::Base.new(:mongoid)
|
||||
cleaner.strategy = :deletion
|
||||
expect(cleaner.strategy).to be_instance_of DatabaseCleaner::Mongoid::Deletion
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue