1 require "application_system_test_case"
3 class UserEmailChangeTest < ApplicationSystemTestCase
4 include ActionMailer::TestHelper
7 stub_request(:get, /.*gravatar.com.*d=404/).to_return(:status => 404)
10 test "User can change their email address" do
15 visit edit_account_path
16 fill_in "New Email Address", :with => "new_tester@example.com"
17 click_on "Save Changes"
18 assert_equal "new_tester@example.com", user.reload.new_email
21 email = ActionMailer::Base.deliveries.first
22 assert_equal 1, email.to.count
23 assert_equal "new_tester@example.com", email.to.first
24 assert_match %r{/user/confirm-email\?confirm_string=[A-Za-z0-9-_%]+\s}, email.parts[0].parts[0].decoded
26 if email.parts[0].parts[0].decoded =~ %r{(/user/confirm-email\?confirm_string=[A-Za-z0-9-_%]+)\s}
27 visit Regexp.last_match(1)
28 assert page.has_css?("body.accounts-edit")
31 assert_equal "new_tester@example.com", user.reload.email
33 ActionMailer::Base.deliveries.clear