-
Notifications
You must be signed in to change notification settings - Fork 162
Skip ActiveSupport deprecation proxies when gathering DSL constants #2701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,23 @@ def before_setup | |
| end | ||
|
|
||
| describe "gather_constants" do | ||
| it "does not gather ActiveSupport deprecation proxies and does not warn" do | ||
| require "active_support/concurrency/load_interlock_aware_monitor" | ||
|
|
||
| warnings = [] | ||
| previous_behavior = ActiveSupport.deprecator.behavior | ||
| ActiveSupport.deprecator.behavior = ->(message, *) { warnings << message.to_s } | ||
|
|
||
| begin | ||
| constants = gathered_constants | ||
| ensure | ||
| ActiveSupport.deprecator.behavior = previous_behavior | ||
| end | ||
|
|
||
| refute_includes(constants, "ActiveSupport::Concurrency::LoadInterlockAwareMonitor") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't dive into it but agent suggested this diff instead and claimed that current |
||
| assert_empty(warnings.grep(/LoadInterlockAwareMonitor/)) | ||
| end | ||
|
|
||
| it "does not gather anonymous constants" do | ||
| add_ruby_file("test_case.rb", <<~RUBY) | ||
| module TestCase | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's better to abide by the requested constants even if they result in warnings. Can you move this reject above?
ObjectSpace.each_object(Module).reject { |mod| deprecated_constant_proxy?(mod) }