-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug fix for password not being required when used in tandem with the …
…`database_authenticatable` and `validatable` modules. This fix properly ensures that the `#password_required?` and `#password` methods are not redefined by `Devise::Models::MagicLinkAuthenticatable` if they already exist in the model. The check for the existing methods via `instance_methods.include?` must be done in the context of the class the module is being included into and not in the module itself. See #13 for full context.
- Loading branch information
1 parent
7d48def
commit 041b662
Showing
2 changed files
with
42 additions
and
18 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,25 @@ | |
expect(page).to have_css("p.combined_user span.email", text: email) | ||
expect(page).to have_text("Welcome! You have signed up successfully.") | ||
end | ||
|
||
it "validates password" do | ||
email = "[email protected]" | ||
|
||
visit "/combined_users/sign_up" | ||
|
||
expect(page.status_code).to be(200) | ||
expect(page).to have_css("h2", text: "Sign up") | ||
|
||
# It creates a user in the database | ||
fill_in "Email", with: email | ||
expect { click_button "Sign up" }.not_to change { CombinedUser.count } | ||
|
||
# No emails are sent | ||
expect(ActionMailer::Base.deliveries).to be_empty | ||
|
||
# Sign in fails with custom error message | ||
expect(page).to have_css("h2", text: "Sign up") | ||
expect(page).to have_css("#error_explanation", text: "1 error prohibited this combined user from being saved:\nPassword can't be blank") | ||
expect(page).not_to have_text("Welcome! You have signed up successfully.") | ||
end | ||
end |