Had been in the process of getting a Rails Engine upgraded to Rails 5.1 and now in the process of getting the rspec tests back working.
I have a controller, and in that controller I have the following:
module Users
class SessionsController < Devise::SessionsController
skip_before_action :authenticate_user!
skip_before_action :authorize_user!
def create
super
flash[:analytics] = { "data-analytics-form-completed-name" => "#{StewardshipUser.app_slug}/sign-in", "data-analytics-form-completed-type" => "login" }
end
def repopulate_email
(params[:user] && params[:user][:email]) ? params[:user][:email] : ''
end
helper_method :repopulate_email
end
end
If I remove the skip_before_action :authorize_user!
the tests run, but not all successfully.
With the line I'm getting the following error:
An error occurred while loading ./spec/validators/rfc_compliant_validator_spec.rb.
Failure/Error: Dummy::Application.initialize!
RuntimeError:
can't modify frozen Array
# /Users/ahcarpenter/.rvm/gems/ruby-2.2.2/gems/railties-5.1.4/lib/rails/engine.rb:579:in `unshift'
# /Users/ahcarpenter/.rvm/gems/ruby-2.2.2/gems/railties-5.1.4/lib/rails/engine.rb:579:in `block in <class:Engine>'
Any thoughts on why the initializer would be breaking down with that line in there?
Additionally, when I had initially gone to reinitialize rspec, I had to comment out that method to get the initializer to run as it was not found any longer for some reason (I don't seem to have bumped any gem versions up that contained that method, but maybe so)
I'm sure you've fixed this by now, but I had this error, I realized that my test database was not initialized properly. I fixed the error by running the following command:
rails db:migrate RAILS_ENV=test
I hope this is helpful for anyone who stumbles across this post.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With