require "test_helper"

class PasswordResetMailerTest < ActionMailer::TestCase
  test "reset email contains token and expiry" do
    user = users(:admin_user)
    user.update!(
      reset_password_token: "reset_token_123",
      reset_password_sent_at: Time.current
    )

    email = PasswordResetMailer.reset(user)
    assert_emails 1 do
      email.deliver_now
    end

    assert_equal [ user.email ], email.to
    assert_equal "Reset your Sanasto Wiki password", email.subject
    assert_includes email.content_type, "text/html"
    assert_includes email.body.encoded, "reset_token_123"
    assert_includes email.body.encoded, "Password Reset Request"
    assert_includes email.body.encoded, "will expire on"
  end
end
