Filter internal frames in deprecation warnings for Ruby 3.4
Followup to #50923
This commit is contained in:
parent
284baa18c2
commit
c85eca47f0
@ -172,7 +172,7 @@ def _extract_callstack(callstack)
|
||||
LIB_DIR = RbConfig::CONFIG["libdir"]
|
||||
|
||||
def ignored_callstack?(path)
|
||||
path.start_with?(RAILS_GEM_ROOT, LIB_DIR)
|
||||
path.start_with?(RAILS_GEM_ROOT, LIB_DIR) || path.include?("<internal:")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -975,11 +975,22 @@ def generated_method_that_call_deprecation(deprecator)
|
||||
end
|
||||
end
|
||||
|
||||
test "warn deprecation can blame code from internal methods" do
|
||||
@deprecator.behavior = ->(message, *) { @message = message }
|
||||
method_that_emits_deprecation_with_internal_method(@deprecator)
|
||||
|
||||
assert_not_includes(@message, "internal")
|
||||
end
|
||||
|
||||
private
|
||||
def method_that_emits_deprecation(deprecator)
|
||||
deprecator.warn
|
||||
end
|
||||
|
||||
def method_that_emits_deprecation_with_internal_method(deprecator)
|
||||
[1].each { deprecator.warn }
|
||||
end
|
||||
|
||||
def with_rails_application_deprecators(&block)
|
||||
application = Struct.new(:deprecators).new(ActiveSupport::Deprecation::Deprecators.new)
|
||||
rails = Struct.new(:application).new(application)
|
||||
|
Loading…
Reference in New Issue
Block a user