Skip to content

Commit c40659f

Browse files
author
Aidan Haran
committed
Load schema before running Rails test
1 parent 0e0da50 commit c40659f

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

test/cases/coerced_tests.rb

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,40 @@ def test_errors_when_an_insert_query_is_called_while_preventing_writes_coerced
5252
Subscriber.send(:load_schema!)
5353
original_test_errors_when_an_insert_query_is_called_while_preventing_writes
5454
end
55+
56+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
57+
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
58+
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced
59+
Subscriber.send(:load_schema!)
60+
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
61+
end
62+
63+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
64+
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
65+
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes_coerced
66+
Subscriber.send(:load_schema!)
67+
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
68+
end
5569
end
5670
end
5771

5872
module ActiveRecord
5973
class AdapterPreventWritesLegacyTest < ActiveRecord::TestCase
60-
# We do some read queries. Remove assert_no_queries
74+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
6175
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes
6276
def test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes_coerced
63-
@connection_handler.while_preventing_writes do
64-
@connection.transaction do
65-
assert_raises(ActiveRecord::ReadOnlyError) do
66-
@connection.insert("/* some comment */ INSERT INTO subscribers(nick) VALUES ('138853948594')", nil, false)
67-
end
68-
end
69-
end
77+
Subscriber.send(:load_schema!)
78+
original_test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes
7079
end
7180

81+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
82+
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
83+
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes_coerced
84+
Subscriber.send(:load_schema!)
85+
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
86+
end
87+
88+
# Fix randomly failing test. The loading of the model's schema was affecting the test.
7289
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
7390
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced
7491
Subscriber.send(:load_schema!)

0 commit comments

Comments
 (0)