Extend test_can_write_while_reading_from_replicas_if_explicit

- Ensure that explicit method call `connected_to` with `prevent_writes: false`
  turns off 'preventing writes' in the passed block.
- Ensure that after explicit call method call `connected_to` with `prevent_writes: false`
  'preventing writes' is retained

Related to https://github.com/rails/rails/pull/37065
This commit is contained in:
bogdanvlviv 2019-08-30 17:35:19 +03:00
parent ffd74f58b0
commit 39c6986ffc
No known key found for this signature in database
GPG Key ID: E4ACD76A6DB6DFDD

@ -62,7 +62,11 @@ def test_can_write_while_reading_from_replicas_if_explicit
ActiveRecord::Base.connected_to(role: :writing, prevent_writes: false) do
assert ActiveRecord::Base.connected_to?(role: :writing)
assert_not_predicate ActiveRecord::Base.connection, :preventing_writes?
end
assert ActiveRecord::Base.connected_to?(role: :writing)
assert_predicate ActiveRecord::Base.connection, :preventing_writes?
end
assert called
end