提交 3f496429 编写于 作者: Y Yves Senn

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.
上级 e20dc1b3
......@@ -140,7 +140,7 @@ def with_table_cleanup
tables_after = connection.tables - tables_before
tables_after.each do |table|
connection.execute "DROP TABLE #{table}"
connection.drop_table table
end
end
end
......
......@@ -312,7 +312,7 @@ def test_migrator_rollback
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')
......
......@@ -35,9 +35,7 @@
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 @@
) 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 (
......
......@@ -46,9 +46,7 @@
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 @@
) 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 (
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册