diff --git a/activerecord/test/cases/adapter_test.rb b/activerecord/test/cases/adapter_test.rb index 45fc947f7f..7d804d7452 100644 --- a/activerecord/test/cases/adapter_test.rb +++ b/activerecord/test/cases/adapter_test.rb @@ -213,9 +213,10 @@ module ActiveRecord def test_exceptions_from_notifications_are_not_translated original_error = StandardError.new("This StandardError shouldn't get translated") subscriber = ActiveSupport::Notifications.subscribe("sql.active_record") { raise original_error } - actual_error = assert_raises(StandardError) do + wrapped_error = assert_raises(ActiveSupport::Notifications::InstrumentationSubscriberError) do @connection.execute("SELECT * FROM posts") end + actual_error = wrapped_error.exceptions.first assert_equal original_error, actual_error diff --git a/activerecord/test/cases/query_cache_test.rb b/activerecord/test/cases/query_cache_test.rb index 40d23865e9..92e02707eb 100644 --- a/activerecord/test/cases/query_cache_test.rb +++ b/activerecord/test/cases/query_cache_test.rb @@ -489,11 +489,13 @@ class QueryCacheTest < ActiveRecord::TestCase payload[:sql].downcase! end - assert_raises FrozenError do + error = assert_raises ActiveSupport::Notifications::InstrumentationSubscriberError do ActiveRecord::Base.cache do assert_queries(1) { Task.find(1); Task.find(1) } end end + + assert error.exceptions.first.is_a?(FrozenError) ensure ActiveSupport::Notifications.unsubscribe subscriber end