From 39c6986ffc28c39197fc3909eb7d13d7baffd7df Mon Sep 17 00:00:00 2001 From: bogdanvlviv Date: Fri, 30 Aug 2019 17:35:19 +0300 Subject: [PATCH] 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 --- activerecord/test/cases/database_selector_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activerecord/test/cases/database_selector_test.rb b/activerecord/test/cases/database_selector_test.rb index 11e4436d8b..f45086ed20 100644 --- a/activerecord/test/cases/database_selector_test.rb +++ b/activerecord/test/cases/database_selector_test.rb @@ -62,7 +62,11 @@ module ActiveRecord 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