Skip to content

Commit

Permalink
Stub also select_all
Browse files Browse the repository at this point in the history
In Rails 7.1 :select no longer depends on :exect_query but relies on :internal_exec_query instead.
So let's stub directly :select_all to fix the tests.
  • Loading branch information
intrip committed Nov 15, 2023
1 parent fdae98e commit 631dba4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/unit/solid_cache_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ def emulating_unavailability
stub_matcher = ActiveRecord::Base.connection.class.any_instance
stub_matcher.stubs(:exec_query).raises(ActiveRecord::StatementInvalid)
stub_matcher.stubs(:exec_delete).raises(ActiveRecord::StatementInvalid)
stub_matcher.stubs(:select_all).raises(ActiveRecord::StatementInvalid)
yield ActiveSupport::Cache::SolidCacheStore.new(namespace: @namespace)
ensure
stub_matcher.unstub(:exec_query)
stub_matcher.unstub(:exec_delete)
stub_matcher.unstub(:select_all)
end
end

Expand All @@ -82,10 +84,12 @@ def emulating_unavailability
stub_matcher = ActiveRecord::Base.connection.class.any_instance
stub_matcher.stubs(:exec_query).raises(ActiveRecord::StatementInvalid)
stub_matcher.stubs(:exec_delete).raises(ActiveRecord::StatementInvalid)
stub_matcher.stubs(:select_all).raises(ActiveRecord::StatementInvalid)
yield ActiveSupport::Cache::SolidCacheStore.new(namespace: @namespace,
error_handler: ->(method:, returning:, exception:) { raise exception })
ensure
stub_matcher.unstub(:exec_query)
stub_matcher.unstub(:exec_delete)
stub_matcher.unstub(:select_all)
end
end

0 comments on commit 631dba4

Please sign in to comment.