-
-
Save Danielpk/3491d0f560e8e4335f13 to your computer and use it in GitHub Desktop.
Devise Params + RSpec + Shoulda Matcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Users::RegistrationsController < Devise::RegistrationsController | |
before_action :configure_permitted_parameters | |
def configure_permitted_parameters | |
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:email, info_attributes: [:name]) } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
RSpec.describe Users::RegistrationsController do | |
before { request.env["devise.mapping"] = Devise.mappings[:user] } | |
describe 'POST #create' do | |
it { should permit(:name, :email).for(:create) } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Test output: