Log the following information in email headers: * X-Danbooru-User: the user's name and ID. * X-Danbooru-IP: the user's IP. * X-Danbooru-Session: the users' session ID. * X-Danbooru-URL: the page that triggered the email. * X-Danbooru-Job-Id: the ID of the background job that sent the email. * X-Danbooru-Enqueued-At: when the email was queued as a background job. * X-Danbooru-Dmail: for Dmail notifications, the link to the Dmail. * X-Request-Id: the request ID of the HTTP request that triggered the email. Also make it so we log an event in the APM when we send an email.
41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
require 'test_helper'
|
|
|
|
class PasswordResetsControllerTest < ActionDispatch::IntegrationTest
|
|
context "The passwords resets controller" do
|
|
context "show action" do
|
|
should "work" do
|
|
get password_reset_path
|
|
assert_response :success
|
|
end
|
|
end
|
|
|
|
context "create action" 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 } }
|
|
|
|
assert_redirected_to new_session_path
|
|
assert_equal(true, @user.user_events.password_reset.exists?)
|
|
|
|
perform_enqueued_jobs
|
|
assert_performed_jobs(1, only: MailDeliveryJob)
|
|
#assert_enqueued_email_with UserMailer.with_request(request), :password_reset, args: [@user], queue: "default"
|
|
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
|
|
|
|
should "fail if the user does not exist" do
|
|
post password_reset_path, params: { user: { name: "qoi23oti" } }
|
|
|
|
assert_redirected_to password_reset_path
|
|
end
|
|
end
|
|
end
|
|
end
|