mirror of
https://github.com/DatabaseCleaner/database_cleaner
synced 2023-03-27 23:22:03 -04:00
Get schema_migrations table name from ActiveRecord
This makes ActiveRecord responsible for determining the table name to handle subtle nuisances like table_name_prefix and table_name_suffix.
This commit is contained in:
parent
a44abba53d
commit
30db965a99
2 changed files with 11 additions and 1 deletions
|
@ -244,7 +244,7 @@ module DatabaseCleaner::ActiveRecord
|
|||
|
||||
# overwritten
|
||||
def migration_storage_names
|
||||
%w[schema_migrations]
|
||||
[::ActiveRecord::Migrator.schema_migrations_table_name]
|
||||
end
|
||||
|
||||
def pre_count?
|
||||
|
|
|
@ -39,6 +39,16 @@ module DatabaseCleaner
|
|||
Truncation.new.clean
|
||||
end
|
||||
|
||||
it "should use ActiveRecord's schema_migrations_table_name" do
|
||||
connection.stub!(:database_cleaner_table_cache).and_return(%w[pre_schema_migrations_suf widgets dogs])
|
||||
::ActiveRecord::Base.stub!(:table_name_prefix).and_return('pre_')
|
||||
::ActiveRecord::Base.stub!(:table_name_suffix).and_return('_suf')
|
||||
|
||||
connection.should_receive(:truncate_tables).with(['widgets', 'dogs'])
|
||||
|
||||
Truncation.new.clean
|
||||
end
|
||||
|
||||
it "should only truncate the tables specified in the :only option when provided" do
|
||||
connection.stub!(:database_cleaner_table_cache).and_return(%w[schema_migrations widgets dogs])
|
||||
|
||||
|
|
Loading…
Reference in a new issue