diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-03-02 17:35:05 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-03-02 17:43:01 +0100 |
commit | 3f4964299acd1351a519293991b97dd78b775073 (patch) | |
tree | bc9312a08fae97e2b9d810c9d34653ffd0a62c15 /activerecord/test | |
parent | e20dc1b313303540b44effd94fbc8cf39121ad28 (diff) | |
download | rails-3f4964299acd1351a519293991b97dd78b775073.tar.gz rails-3f4964299acd1351a519293991b97dd78b775073.tar.bz2 rails-3f4964299acd1351a519293991b97dd78b775073.zip |
tests, favor `drop_table` and `:if_exists` over raw SQL.
We've replaced most querues using DROP TABLE in our tests already.
This patch replaces the last couple calls.
Diffstat (limited to 'activerecord/test')
4 files changed, 6 insertions, 14 deletions
diff --git a/activerecord/test/cases/migration/create_join_table_test.rb b/activerecord/test/cases/migration/create_join_table_test.rb index bea9d6b2c9..8fd08fe4ce 100644 --- a/activerecord/test/cases/migration/create_join_table_test.rb +++ b/activerecord/test/cases/migration/create_join_table_test.rb @@ -140,7 +140,7 @@ module ActiveRecord tables_after = connection.tables - tables_before tables_after.each do |table| - connection.execute "DROP TABLE #{table}" + connection.drop_table table end end end diff --git a/activerecord/test/cases/migrator_test.rb b/activerecord/test/cases/migrator_test.rb index c0daa83e9c..1760314099 100644 --- a/activerecord/test/cases/migrator_test.rb +++ b/activerecord/test/cases/migrator_test.rb @@ -312,7 +312,7 @@ class MigratorTest < ActiveRecord::TestCase def test_migrator_db_has_no_schema_migrations_table _, migrator = migrator_class(3) - ActiveRecord::Base.connection.execute("DROP TABLE schema_migrations") + ActiveRecord::Base.connection.drop_table "schema_migrations", if_exists: true assert_not ActiveRecord::Base.connection.table_exists?('schema_migrations') migrator.migrate("valid", 1) assert ActiveRecord::Base.connection.table_exists?('schema_migrations') diff --git a/activerecord/test/schema/mysql2_specific_schema.rb b/activerecord/test/schema/mysql2_specific_schema.rb index a9a6514c9d..d6fd0c4ab0 100644 --- a/activerecord/test/schema/mysql2_specific_schema.rb +++ b/activerecord/test/schema/mysql2_specific_schema.rb @@ -35,9 +35,7 @@ BEGIN END SQL - ActiveRecord::Base.connection.execute <<-SQL -DROP TABLE IF EXISTS collation_tests; -SQL + ActiveRecord::Base.connection.drop_table "collation_tests", if_exists: true ActiveRecord::Base.connection.execute <<-SQL CREATE TABLE collation_tests ( @@ -46,9 +44,7 @@ CREATE TABLE collation_tests ( ) CHARACTER SET utf8 COLLATE utf8_general_ci SQL - ActiveRecord::Base.connection.execute <<-SQL -DROP TABLE IF EXISTS enum_tests; -SQL + ActiveRecord::Base.connection.drop_table "enum_tests", if_exists: true ActiveRecord::Base.connection.execute <<-SQL CREATE TABLE enum_tests ( diff --git a/activerecord/test/schema/mysql_specific_schema.rb b/activerecord/test/schema/mysql_specific_schema.rb index f2cffca52c..b5378341b5 100644 --- a/activerecord/test/schema/mysql_specific_schema.rb +++ b/activerecord/test/schema/mysql_specific_schema.rb @@ -46,9 +46,7 @@ BEGIN END SQL - ActiveRecord::Base.connection.execute <<-SQL -DROP TABLE IF EXISTS collation_tests; -SQL + ActiveRecord::Base.connection.drop_table "collation_tests", if_exists: true ActiveRecord::Base.connection.execute <<-SQL CREATE TABLE collation_tests ( @@ -57,9 +55,7 @@ CREATE TABLE collation_tests ( ) CHARACTER SET utf8 COLLATE utf8_general_ci SQL - ActiveRecord::Base.connection.execute <<-SQL -DROP TABLE IF EXISTS enum_tests; -SQL + ActiveRecord::Base.connection.drop_table "enum_tests", if_exists: true ActiveRecord::Base.connection.execute <<-SQL CREATE TABLE enum_tests ( |