35 lines
1.0 KiB
Ruby
35 lines
1.0 KiB
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
require "test_helper"
|
||
|
|
||
|
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
||
|
test "should get new" do
|
||
|
get new_password_reset_path
|
||
|
assert_response :success
|
||
|
end
|
||
|
|
||
|
test "should send a password reset email" do
|
||
|
user = users(:trevor)
|
||
|
assert_emails(+1) do
|
||
|
post password_resets_path, params: { username: user.username }
|
||
|
assert_redirected_to new_session_path
|
||
|
end
|
||
|
end
|
||
|
|
||
|
test "should get edit" do
|
||
|
user = users(:trevor)
|
||
|
token = user.generate_token_for(:password_reset)
|
||
|
get edit_password_reset_path(token: token, id: user.username)
|
||
|
assert_response :success
|
||
|
end
|
||
|
|
||
|
test "should update password" do
|
||
|
user = users(:trevor)
|
||
|
token = user.generate_token_for(:password_reset)
|
||
|
put password_reset_path(id: user.username, token: token),
|
||
|
params: { password: "password", password_confirmation: "password" }
|
||
|
assert_redirected_to new_session_path
|
||
|
assert user.reload.authenticate("password")
|
||
|
end
|
||
|
end
|