tests: fix password reset tests.
This commit is contained in:
@@ -2,10 +2,6 @@ require 'test_helper'
|
|||||||
|
|
||||||
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
||||||
context "The passwords resets controller" do
|
context "The passwords resets controller" do
|
||||||
setup do
|
|
||||||
@user = create(:user)
|
|
||||||
end
|
|
||||||
|
|
||||||
context "show action" do
|
context "show action" do
|
||||||
should "work" do
|
should "work" do
|
||||||
get password_reset_path
|
get password_reset_path
|
||||||
@@ -14,12 +10,21 @@ class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "create action" do
|
context "create action" do
|
||||||
should "work" do
|
should "should send a password reset email if the user has a verified email address" do
|
||||||
|
@user = create(:user, email_address: build(:email_address))
|
||||||
post password_reset_path, params: { user: { name: @user.name } }
|
post password_reset_path, params: { user: { name: @user.name } }
|
||||||
|
|
||||||
assert_redirected_to new_session_path
|
assert_redirected_to new_session_path
|
||||||
assert_enqueued_email_with UserMailer, :password_reset, args: [@user]
|
assert_enqueued_email_with UserMailer, :password_reset, args: [@user]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "should fail if the user doesn't have a verified email address" do
|
||||||
|
@user = create(:user)
|
||||||
|
post password_reset_path, params: { user: { name: @user.name } }
|
||||||
|
|
||||||
|
assert_redirected_to @user
|
||||||
|
assert_no_enqueued_emails
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user