After installing the Devise Security Extension to add password expiration to my Devise models, I started getting the following error on an RSpec test for a controller that does not perform authentication of the user:
Failure/Error: get :index
NoMethodError:
undefined method `authenticate?' for nil:NilClass
After a bit of digging, I found that the helpers.rb in the gem includes an additional before_filter
that needs to be skipped:
module DeviseSecurityExtension
module Controllers
module Helpers
extend ActiveSupport::Concern
included do
before_filter :handle_password_change
end
So while I’m skipping authenticate_user!
in my controller, I still needed an additional:
skip_before_filter :handle_password_change
Interestingly enough, the controller itself doesn’t break, just the tests. The downside is that I’m referencing two different Devise filters/actions just to not use them.