File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
spec/activerecord/debug_errors/ext/connection_adapters Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -58,11 +58,15 @@ def cause_deadlock(role:)
5858
5959 context "when the user doesn't have the permission to execute 'SHOW ENGINE INNODB STATUS'" do
6060 it "displays an error message" do
61+ # In ActiveRecord 8.1+, replica connections cannot execute lock queries,
62+ # so it raises ActiveRecord::ReadOnlyError instead of ActiveRecord::Deadlocked.
63+ expected_error = ActiveRecord . version < Gem ::Version . new ( "8.1" ) ? ActiveRecord ::Deadlocked : ActiveRecord ::ReadOnlyError
64+
6165 expect {
6266 ActiveRecord ::Base . connected_to ( role : :reading ) do
6367 cause_deadlock ( role : :reading )
6468 end
65- } . to raise_error ( ActiveRecord :: Deadlocked )
69+ } . to raise_error ( expected_error )
6670 expect ( log . string ) . to include ( "Failed to execute" )
6771 end
6872 end
You can’t perform that action at this time.
0 commit comments