Skip to content

Commit afb87c7

Browse files
committed
Fixed calls to coerce tests
1 parent b5190d4 commit afb87c7

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

test/cases/coerced_tests.rb

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,27 +48,29 @@ def test_value_limit_violations_are_translated_to_specific_exception_coerced
4848
assert_not_nil error.cause
4949
end
5050
end
51+
end
52+
end
5153

52-
class AdapterTestWithoutTransaction
53-
# SQL Server does not allow truncation of tables that are referenced by foreign key
54-
# constraints. So manually remove/add foreign keys in test.
55-
coerce_tests! test_truncate_tables
56-
def test_truncate_tables_coerced
57-
@connection.remove_foreign_key :authors, :author_addresses
58-
59-
assert_operator Post.count, :>, 0
60-
assert_operator Author.count, :>, 0
61-
assert_operator AuthorAddress.count, :>, 0
62-
63-
@connection.truncate_tables("author_addresses", "authors", "posts")
64-
65-
assert_equal 0, Post.count
66-
assert_equal 0, Author.count
67-
assert_equal 0, AuthorAddress.count
68-
ensure
69-
@connection.add_foreign_key :authors, :author_addresses
70-
reset_fixtures("posts", "authors", "author_addresses")
71-
end
54+
module ActiveRecord
55+
class AdapterTestWithoutTransaction < ActiveRecord::TestCase
56+
# SQL Server does not allow truncation of tables that are referenced by foreign key
57+
# constraints. So manually remove/add foreign keys in test.
58+
coerce_tests! :test_truncate_tables
59+
def test_truncate_tables_coerced
60+
@connection.remove_foreign_key :authors, :author_addresses
61+
62+
assert_operator Post.count, :>, 0
63+
assert_operator Author.count, :>, 0
64+
assert_operator AuthorAddress.count, :>, 0
65+
66+
@connection.truncate_tables("author_addresses", "authors", "posts")
67+
68+
assert_equal 0, Post.count
69+
assert_equal 0, Author.count
70+
assert_equal 0, AuthorAddress.count
71+
ensure
72+
@connection.add_foreign_key :authors, :author_addresses
73+
reset_fixtures("posts", "authors", "author_addresses")
7274
end
7375
end
7476
end
@@ -1210,7 +1212,7 @@ class DatabaseTasksTruncateAllTest < ActiveRecord::TestCase
12101212

12111213
# SQL Server does not allow truncation of tables that are referenced by foreign key
12121214
# constraints. So manually remove/add foreign keys in test.
1213-
coerce_tests! test_truncate_tables
1215+
coerce_tests! :test_truncate_tables
12141216
def test_truncate_tables_coerced
12151217
connection = ActiveRecord::Base.connection
12161218
connection.remove_foreign_key :authors, :author_addresses

0 commit comments

Comments
 (0)