mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Update tests to support guarded InstrumentationSubscriberError
This commit is contained in:
parent
8afcbb6f21
commit
f4a7942de1
2 changed files with 5 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue