heartcombo / devise

Flexible authentication solution for Rails with Warden.
http://blog.plataformatec.com.br/tag/devise/
MIT License
23.83k stars 5.53k forks source link

Deprecation warning about Rails.application.secrets on rails 7.1 #5676

Closed mikehale closed 3 months ago

mikehale commented 4 months ago

Environment

Current behavior

I see a deprecation warning when running tests. This should be reproducible on any rails 7.1 install with devise.

$ bundle exec rspec spec
DEPRECATION WARNING: `Rails.application.secrets` is deprecated in favor of `Rails.application.credentials` and will be removed in Rails 7.2. (called from <top (required)> at rails-project/config/environment.rb:7)

Expected behavior

No deprecation warning when running tests locally.

I think the https://github.com/heartcombo/devise/blob/main/lib/devise/secret_key_finder.rb will need to be updated to not attempt to call application.secrets, before calling application.config.secret_key_base (which is what development and test) seem to defer to.

Javierchik commented 3 months ago

Hey just make it like:

Devise.setup do |config|
    config.secret_key = ENV['DEVISE_SECRET_KEY']
 end
mikehale commented 3 months ago

Good idea. This worked for me:

Devise.setup do |config|
  config.secret_key = '' if Rails.env.test?
end