Skip to content

Rails 6.1: Fix randomly failing prevent writes test #912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,40 @@ def test_errors_when_an_insert_query_is_called_while_preventing_writes_coerced
Subscriber.send(:load_schema!)
original_test_errors_when_an_insert_query_is_called_while_preventing_writes
end

# Fix randomly failing test. The loading of the model's schema was affecting the test.
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced
Subscriber.send(:load_schema!)
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
end

# Fix randomly failing test. The loading of the model's schema was affecting the test.
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes_coerced
Subscriber.send(:load_schema!)
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
end
end
end

module ActiveRecord
class AdapterPreventWritesLegacyTest < ActiveRecord::TestCase
# We do some read queries. Remove assert_no_queries
# Fix randomly failing test. The loading of the model's schema was affecting the test.
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes
def test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes_coerced
@connection_handler.while_preventing_writes do
@connection.transaction do
assert_raises(ActiveRecord::ReadOnlyError) do
@connection.insert("/* some comment */ INSERT INTO subscribers(nick) VALUES ('138853948594')", nil, false)
end
end
end
Subscriber.send(:load_schema!)
original_test_errors_when_an_insert_query_prefixed_by_a_slash_star_comment_is_called_while_preventing_writes
end

# Fix randomly failing test. The loading of the model's schema was affecting the test.
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes_coerced
Subscriber.send(:load_schema!)
original_test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_is_called_while_preventing_writes
end

# Fix randomly failing test. The loading of the model's schema was affecting the test.
coerce_tests! :test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes
def test_errors_when_an_insert_query_prefixed_by_a_double_dash_comment_containing_read_command_is_called_while_preventing_writes_coerced
Subscriber.send(:load_schema!)
Expand Down