openstreetmap-website/test/system/user_email_change_test.rb
Andy Allan 31805df53f Remove some unnecessary calls to clear the mail queue
These were not needed at the end of most tests for quite some time,
since rails clears them by default for controller and integration tests,
and also no longer required in system tests after #5691
2025-02-16 16:16:13 +00:00

33 lines
1 KiB
Ruby

require "application_system_test_case"
class UserEmailChangeTest < ApplicationSystemTestCase
include ActionMailer::TestHelper
def setup
stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
end
test "User can change their email address" do
user = create(:user)
sign_in_as(user)
assert_emails 1 do
visit edit_account_path
fill_in "New Email Address", :with => "new_tester@example.com"
click_on "Save Changes"
assert_equal "new_tester@example.com", user.reload.new_email
end
email = ActionMailer::Base.deliveries.first
assert_equal 1, email.to.count
assert_equal "new_tester@example.com", email.to.first
assert_match %r{/user/confirm-email\?confirm_string=[A-Za-z0-9\-_%]+\s}, email.parts[0].parts[0].decoded
if email.parts[0].parts[0].decoded =~ %r{(/user/confirm-email\?confirm_string=[A-Za-z0-9\-_%]+)\s}
visit Regexp.last_match(1)
assert page.has_css?("body.accounts-edit")
end
assert_equal "new_tester@example.com", user.reload.email
end
end