X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/a7ba87340d91a6eeef096783b04a9b0a963bfa99..8ecb2c79f7146ecbb69d08cd38954836dc6d1b4c:/test/integration/user_creation_test.rb diff --git a/test/integration/user_creation_test.rb b/test/integration/user_creation_test.rb index 8ec0dc9bc..253f298a5 100644 --- a/test/integration/user_creation_test.rb +++ b/test/integration/user_creation_test.rb @@ -65,6 +65,26 @@ class UserCreationTest < ActionDispatch::IntegrationTest assert_select "form > div > input.is-invalid#user_display_name" end + def test_user_create_submit_mismatched_passwords + email = "newtester@osm.org" + display_name = "new_tester" + assert_difference("User.count", 0) do + assert_difference("ActionMailer::Base.deliveries.size", 0) do + perform_enqueued_jobs do + post "/user/new", + :params => { :user => { :email => email, + :email_confirmation => email, + :display_name => display_name, + :pass_crypt => "testtest", + :pass_crypt_confirmation => "blahblah" } } + end + end + end + assert_response :success + assert_template "users/new" + assert_select "form > div > input.is-invalid#user_pass_crypt_confirmation" + end + def test_user_create_success new_email = "newtester@osm.org" display_name = "new_tester" @@ -94,18 +114,29 @@ class UserCreationTest < ActionDispatch::IntegrationTest end end - # Check the e-mail - register_email = ActionMailer::Base.deliveries.first - - assert_equal register_email.to.first, new_email - # Check that the confirm account url is correct - assert_match(/#{@url}/, register_email.body.to_s) - - # Check the page assert_response :success assert_template "confirmations/confirm" + user = User.find_by(:email => "newtester@osm.org") + assert_not_nil user + assert_not_predicate user, :active? + + register_email = ActionMailer::Base.deliveries.first + assert_equal register_email.to.first, new_email + found_confirmation_url = register_email.parts.first.parts.first.to_s =~ %r{\shttp://test.host(/\S+)\s} + assert found_confirmation_url + confirmation_url = Regexp.last_match(1) ActionMailer::Base.deliveries.clear + + post confirmation_url + + assert_response :redirect + assert_redirected_to welcome_path + + user.reload + assert_predicate user, :active? + + assert_equal user, User.authenticate(:username => new_email, :password => "testtest") end def test_user_create_no_tou_failure