Skip to content
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

Use a dedicated ActiveSupport::Deprecation instance #2479

Merged
merged 4 commits into from
Jan 15, 2024

Conversation

maciek-rr
Copy link
Contributor

@maciek-rr maciek-rr commented Dec 28, 2023

Description

Rails 7.1 started deprecating the direct usage of ActiveSupport::Deprecation methods. Instead, the preferred way is to instantiate the class and use the custom instance.

This PR adds the deprecator instance and switches the warn calls to use it.
Compatible with Rails 4.0+

Deprecation example

Each deprecation originating from Administrate is accompanied by a Rails 7.1 deprecation.

DEPRECATION WARNING: The method `valid_action?` is deprecated. Please use `accessible_action?` instead, or see the documentation for other options. (called from index at /backend/app/controllers/concerns/admin_search.rb:13)
DEPRECATION WARNING: Calling warn on ActiveSupport::Deprecation is deprecated and will be removed from Rails (use your own Deprecation object instead) (called from index at /backend/app/controllers/concerns/admin_search.rb:13)

Rails 7.1 started deprecating the direct usage of ActiveSupport::Deprecate methods.
Instead, the preferred way is to instantiate the class and use the custom instance.

Compatible with Rails 4.0+
@nickcharlton nickcharlton force-pushed the use-dedicated-deprecator branch from ad02038 to 7c3f6c4 Compare January 4, 2024 17:45
@nickcharlton
Copy link
Member

Nice, thanks!

@nickcharlton
Copy link
Member

Ah, hmm. I tried this out just to see if we'd missed a few, and it seems like we did. I pushed a commit with those, which I caught, but I'm also getting these:

DEPRECATION WARNING: Calling warn on ActiveSupport::Deprecation is deprecated and will be removed from Rails (use your own Deprecation object instead) (called from block (3 levels) in <top (required)> at /Users/nickcharlton/projects/thoughtbot/administrate/spec/generators/install_generator_spec.rb:30)

(It might be best to run with appraisal rails70 rspec to be sure you're calling it.)

I am partial to ignoring it as there's no direct calls, but I'll have another look tomorrow.

@maciek-rr
Copy link
Contributor Author

Hey @nickcharlton thanks a ton, I've missed it, will take a better look at it during the weekend.

@nickcharlton
Copy link
Member

Cool, thanks! Let me know how you get on, but I'll leave this with you until I hear otherwise!

Deprecations fixed:
- RSpec exist deprecated matcher
- Rails 7 cache version deprecation
@maciek-rr
Copy link
Contributor Author

Hey @nickcharlton, I think I've addressed all the remaining deprecation warnings. One type was coming from RSpec and the usage of a deprecated file exists matcher, another one was about using an old Rails cache format, I've modified the test.rb of the example app to use the new format in Rails 7+. Please take a look when you have a moment, thanks.

@nickcharlton
Copy link
Member

Excellent, thanks! This looks good to me now and I'm not seeing any deprecation warnings now so I'm going to merge it.

@nickcharlton nickcharlton merged commit 0b740c4 into thoughtbot:main Jan 15, 2024
4 checks passed
nickcharlton pushed a commit to JohnnyKei/administrate that referenced this pull request Jan 24, 2024
In thoughtbot#2479, we switched to using a dedicated `ActiveSupport::Deprecation`
instance to handle a deprecation warning. Unfortunately, in some
circumstances, we reference the `VERSION` constant when it's not been
loaded, which seems to happen when we render the deprecation warnings.
nickcharlton pushed a commit that referenced this pull request Jan 24, 2024
In #2479, we switched to using a dedicated `ActiveSupport::Deprecation`
instance to handle a deprecation warning. Unfortunately, in some
circumstances, we reference the `VERSION` constant when it's not been
loaded, which seems to happen when we render the deprecation warnings.
@maciek-rr maciek-rr deleted the use-dedicated-deprecator branch March 8, 2024 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants