Skip to content

Commit 4aaf783

Browse files
author
Aidan Haran
committed
Load table schema before running tests
1 parent 34b9273 commit 4aaf783

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

test/cases/coerced_tests.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,21 @@ def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containin
6464

6565
module ActiveRecord
6666
class AdapterPreventWritesLegacyTest < ActiveRecord::TestCase
67-
# We do some read queries. Remove assert_no_queries
67+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
6868
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes
6969
def test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes_coerced
70-
@connection_handler.while_preventing_writes do
71-
@connection.transaction do
72-
assert_raises(ActiveRecord::ReadOnlyError) do
73-
@connection.insert("/* some comment */ INSERT INTO subscribers(nick) VALUES ('138853948594')", nil, false)
74-
end
75-
end
76-
end
70+
Subscriber.send(:load_schema!)
71+
original_test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes
7772
end
7873

74+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
75+
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
76+
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes_coerced
77+
Subscriber.send(:load_schema!)
78+
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
79+
end
80+
81+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
7982
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
8083
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced
8184
Subscriber.send(:load_schema!)

0 commit comments

Comments
 (0)