1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #42422 from Shopify/as-time-with-zone-no-method-error

Improve `AS::TimeWithZone` error message on `NoMethodError`
This commit is contained in:
Jean Boussier 2021-06-08 12:19:21 +02:00 committed by GitHub
commit 4493db2109
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -542,7 +542,7 @@ module ActiveSupport
def method_missing(sym, *args, &block)
wrap_with_time_zone time.__send__(sym, *args, &block)
rescue NoMethodError => e
raise e, e.message.sub(time.inspect, inspect), e.backtrace
raise e, e.message.sub(time.inspect, inspect).sub("Time", "ActiveSupport::TimeWithZone"), e.backtrace
end
private

View file

@ -1078,7 +1078,7 @@ class TimeWithZoneTest < ActiveSupport::TestCase
e = assert_raises(NoMethodError) {
@twz.this_method_does_not_exist
}
assert_equal "undefined method `this_method_does_not_exist' for Fri, 31 Dec 1999 19:00:00.000000000 EST -05:00:Time", e.message
assert_equal "undefined method `this_method_does_not_exist' for Fri, 31 Dec 1999 19:00:00.000000000 EST -05:00:ActiveSupport::TimeWithZone", e.message
assert_no_match "rescue", e.backtrace.first
end
end