tabletop-companion/test/controllers/password_resets_controller_...

35 lines
1.0 KiB
Ruby
Raw Normal View History

2024-06-03 10:54:38 +00:00
# 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