1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

tests, use drop_table if_exists: true in our test suite.

This commit is contained in:
Yves Senn 2015-01-20 13:25:33 +01:00
parent 6b2be718f6
commit 7675364fe0
9 changed files with 13 additions and 13 deletions

View file

@ -16,7 +16,7 @@ module ActiveRecord
def test_initializes_schema_migrations_for_encoding_utf8mb4
smtn = ActiveRecord::Migrator.schema_migrations_table_name
connection.drop_table(smtn) if connection.table_exists?(smtn)
connection.drop_table smtn, if_exists: true
config = connection.instance_variable_get(:@config)
original_encoding = config[:encoding]

View file

@ -18,8 +18,8 @@ class RequiredAssociationsTest < ActiveRecord::TestCase
end
teardown do
@connection.drop_table 'parents' if @connection.table_exists? 'parents'
@connection.drop_table 'children' if @connection.table_exists? 'children'
@connection.drop_table 'parents', if_exists: true
@connection.drop_table 'children', if_exists: true
end
test "belongs_to associations are not required by default" do

View file

@ -28,7 +28,7 @@ module ActiveRecord
teardown do
return unless @connection
@connection.drop_table 'attribute_decorators_model' if @connection.table_exists? 'attribute_decorators_model'
@connection.drop_table 'attribute_decorators_model', if_exists: true
Model.attribute_type_decorations.clear
Model.reset_column_information
end

View file

@ -40,7 +40,7 @@ class DefaultNumbersTest < ActiveRecord::TestCase
end
teardown do
@connection.drop_table "default_numbers" if @connection.table_exists? 'default_numbers'
@connection.drop_table :default_numbers, if_exists: true
end
def test_default_positive_integer

View file

@ -437,7 +437,7 @@ module ActiveRecord
teardown do
[:wagons, :trains].each do |table|
@connection.drop_table(table) if @connection.table_exists?(table)
@connection.drop_table table, if_exists: true
end
end

View file

@ -29,8 +29,8 @@ module ActiveRecord
teardown do
if defined?(@connection)
@connection.drop_table "astronauts" if @connection.table_exists? 'astronauts'
@connection.drop_table "rockets" if @connection.table_exists? 'rockets'
@connection.drop_table "astronauts", if_exists: true
@connection.drop_table "rockets", if_exists: true
end
end

View file

@ -86,8 +86,8 @@ module ActiveRecord
assert connection.table_exists? :felines
ensure
disable_extension!('uuid-ossp', connection)
connection.drop_table :cats if connection.table_exists? :cats
connection.drop_table :felines if connection.table_exists? :felines
connection.drop_table :cats, if_exists: true
connection.drop_table :felines, if_exists: true
end
end
end

View file

@ -6,11 +6,11 @@ module ActiveRecord
def test_add_schema_info_respects_prefix_and_suffix
conn = ActiveRecord::Base.connection
conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name)
conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name, if_exists: true)
# Use shorter prefix and suffix as in Oracle database identifier cannot be larger than 30 characters
ActiveRecord::Base.table_name_prefix = 'p_'
ActiveRecord::Base.table_name_suffix = '_s'
conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name)
conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name, if_exists: true)
conn.initialize_schema_migrations_table

View file

@ -90,7 +90,7 @@ class MigrationTest < ActiveRecord::TestCase
end
def test_migration_detection_without_schema_migration_table
ActiveRecord::Base.connection.drop_table('schema_migrations') if ActiveRecord::Base.connection.table_exists?('schema_migrations')
ActiveRecord::Base.connection.drop_table 'schema_migrations', if_exists: true
migrations_path = MIGRATIONS_ROOT + "/valid"
old_path = ActiveRecord::Migrator.migrations_paths