]> git.openstreetmap.org Git - rails.git/blobdiff - test/integration/user_creation_test.rb
Update minimum ruby version to 3.2
[rails.git] / test / integration / user_creation_test.rb
index 4611860d02552705267c588419d8e275353d1faa..4aae1046b586b97a4d25e25edc7031aa1a689c8c 100644 (file)
@@ -30,12 +30,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => dup_email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "testtest",
-                                       :consider_pd => "1" } }
+                                       :pass_crypt_confirmation => "testtest" } }
         end
       end
     end
@@ -45,61 +44,19 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_select "form > div > input.is-invalid#user_email"
   end
 
-  def test_user_create_association_bad_auth_provider
-    assert_difference("User.count", 0) do
-      assert_no_difference("ActionMailer::Base.deliveries.size") do
-        perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => "test@example.com",
-                                       :display_name => "new_tester",
-                                       :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "testtest",
-                                       :auth_provider => "noprovider",
-                                       :auth_uid => "123454321",
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "noprovider", :origin => "/user/new")
-          post response.location
-        end
-      end
-    end
-    assert_response :not_found
-  end
-
-  def test_user_create_association_no_auth_uid
-    OmniAuth.config.mock_auth[:google] = :invalid_credentials
-    assert_difference("User.count", 0) do
-      assert_no_difference("ActionMailer::Base.deliveries.size") do
-        perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => "test@example.com",
-                                       :display_name => "new_tester",
-                                       :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "testtest",
-                                       :auth_provider => "google",
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
-          post response.location
-        end
-      end
-    end
-    follow_redirect!
-    assert_redirected_to auth_failure_path(:strategy => "google", :message => "invalid_credentials", :origin => "/user/new")
-  end
-
   def test_user_create_association_submit_duplicate_email
     dup_email = create(:user).email
     display_name = "new_tester"
     assert_difference("User.count", 0) do
       assert_no_difference("ActionMailer::Base.deliveries.size") do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => dup_email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
                                        :pass_crypt_confirmation => "testtest",
                                        :auth_provider => "google",
-                                       :auth_uid => "123454321",
-                                       :consider_pd => "1" } }
+                                       :auth_uid => "123454321" } }
         end
       end
     end
@@ -115,7 +72,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => email,
                                        :display_name => dup_display_name,
                                        :pass_crypt => "testtest",
@@ -134,12 +91,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "blahblah",
-                                       :consider_pd => "1" } }
+                                       :pass_crypt_confirmation => "blahblah" } }
         end
       end
     end
@@ -154,12 +110,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 0) do
       assert_no_difference("ActionMailer::Base.deliveries.size") do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => email,
                                        :display_name => dup_display_name,
                                        :auth_provider => "google",
-                                       :auth_uid => "123454321",
-                                       :consider_pd => "1" } }
+                                       :auth_uid => "123454321" } }
         end
       end
     end
@@ -175,12 +130,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count", 1) do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :pass_crypt => "testtest",
-                                       :pass_crypt_confirmation => "testtest",
-                                       :consider_pd => "1" } }
+                                       :pass_crypt_confirmation => "testtest" } }
           assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
           follow_redirect!
         end
@@ -199,7 +153,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     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
 
@@ -212,13 +165,13 @@ class UserCreationTest < ActionDispatch::IntegrationTest
   end
 
   # Check that the user can successfully recover their password
-  def test_lost_password_recovery_success
-    # Open the lost password form
-    # Submit the lost password form
-    # Check the e-mail
-    # Submit the reset password token
-    # Check that the password has changed, and the user can login
-  end
+  def test_lost_password_recovery_success
+  #   Open the lost password form
+  #   Submit the lost password form
+  #   Check the e-mail
+  #   Submit the reset password token
+  #   Check that the password has changed, and the user can login
+  end
 
   def test_user_create_redirect
     new_email = "redirect_tester@osm.org"
@@ -229,12 +182,11 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count") do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :pass_crypt => password,
-                                       :pass_crypt_confirmation => password,
-                                       :consider_pd => "1" },
+                                       :pass_crypt_confirmation => password },
                             :referer => referer }
           assert_response(:redirect)
           assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
@@ -258,8 +210,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success
@@ -275,6 +225,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
   def test_user_create_openid_success
     new_email = "newtester-openid@osm.org"
     display_name = "new_tester-openid"
+    openid_url = "http://localhost:1000/new.tester"
     auth_uid = "http://localhost:1123/new.tester"
 
     OmniAuth.config.add_mock(:openid,
@@ -284,29 +235,23 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count") do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
+          post auth_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
+          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => new_email,
                                :auth_provider => "openid", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "openid",
-                                       :auth_uid => "http://localhost:1123/new.tester",
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          post response.location
-          follow_redirect!
+                                       :auth_uid => auth_uid } }
         end
       end
     end
 
     # Check the page
     assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_openid_duplicate_email
@@ -328,29 +273,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "users/new"
     assert_select "form > div > input.is-invalid#user_email"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_openid_failure
     OmniAuth.config.mock_auth[:openid] = :connection_failed
 
-    new_email = "newtester-openid2@osm.org"
-    display_name = "new_tester-openid2"
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => new_email,
-                                       :email_confirmation => new_email,
-                                       :display_name => display_name,
-                                       :auth_provider => "openid",
-                                       :auth_uid => "http://localhost:1123/new.tester",
-                                       :pass_crypt => "",
-                                       :pass_crypt_confirmation => "" } }
-          assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
+          post auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
           follow_redirect!
           assert_redirected_to auth_failure_path(:strategy => "openid", :message => "connection_failed", :origin => "/user/new")
           follow_redirect!
@@ -358,11 +289,10 @@ class UserCreationTest < ActionDispatch::IntegrationTest
         end
       end
     end
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_openid_redirect
+    openid_url = "http://localhost:1000/new.tester"
     auth_uid = "http://localhost:1123/new.tester"
     new_email = "redirect_tester_openid@osm.org"
     display_name = "redirect_tester_openid"
@@ -374,23 +304,17 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_difference("User.count") do
       assert_difference("ActionMailer::Base.deliveries.size", 1) do
         perform_enqueued_jobs do
-          post auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
+          post auth_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
+          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => openid_url, :origin => "/user/new")
           follow_redirect!
           assert_redirected_to :controller => :users, :action => "new", :nickname => display_name, :email => new_email,
                                :auth_provider => "openid", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "openid",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "openid", :openid_url => "http://localhost:1123/new.tester", :origin => "/user/new")
-          follow_redirect!
-          assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
+                                       :auth_uid => auth_uid } }
           follow_redirect!
         end
       end
@@ -411,8 +335,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success
@@ -447,17 +369,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :auth_provider => "google", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "google",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" },
+                                       :auth_uid => auth_uid },
                             :email_hmac => email_hmac }
-          assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "google")
-          follow_redirect!
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -467,8 +384,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     # Check the page
     assert_response :success
     assert_template "site/welcome"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_google_duplicate_email
@@ -492,29 +407,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "users/new"
     assert_select "form > div > input.is-invalid#user_email"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_google_failure
     OmniAuth.config.mock_auth[:google] = :connection_failed
 
-    new_email = "newtester-google2@osm.org"
-    display_name = "new_tester-google2"
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => new_email,
-                                       :email_confirmation => new_email,
-                                       :display_name => display_name,
-                                       :auth_provider => "google",
-                                       :auth_uid => "123454321",
-                                       :pass_crypt => "",
-                                       :pass_crypt_confirmation => "" } }
-          assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "google")
+          post auth_path(:provider => "google", :origin => "/user/new")
+          assert_response :redirect
           follow_redirect!
           assert_redirected_to auth_failure_path(:strategy => "google", :message => "connection_failed", :origin => "/user/new")
           follow_redirect!
@@ -522,8 +424,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
         end
       end
     end
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_google_redirect
@@ -548,18 +448,13 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "google", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "google",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "google", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "google")
-          follow_redirect!
-          assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
+                                       :auth_uid => auth_uid } }
+          assert_response :redirect
           follow_redirect!
         end
       end
@@ -580,8 +475,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success
@@ -615,17 +508,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :auth_provider => "facebook", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "facebook",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" },
+                                       :auth_uid => auth_uid },
                             :email_hmac => email_hmac }
-          assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "facebook")
-          follow_redirect!
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -635,8 +523,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     # Check the page
     assert_response :success
     assert_template "site/welcome"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_facebook_duplicate_email
@@ -659,29 +545,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "users/new"
     assert_select "form > div > input.is-invalid#user_email"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_facebook_failure
     OmniAuth.config.mock_auth[:facebook] = :connection_failed
 
-    new_email = "newtester-facebook2@osm.org"
-    display_name = "new_tester-facebook2"
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => new_email,
-                                       :email_confirmation => new_email,
-                                       :display_name => display_name,
-                                       :auth_provider => "facebook",
-                                       :auth_uid => "123454321",
-                                       :pass_crypt => "",
-                                       :pass_crypt_confirmation => "" } }
-          assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "facebook")
+          post auth_path(:provider => "facebook", :origin => "/user/new")
+          assert_response :redirect
           follow_redirect!
           assert_redirected_to auth_failure_path(:strategy => "facebook", :message => "connection_failed", :origin => "/user/new")
           follow_redirect!
@@ -689,8 +562,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
         end
       end
     end
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_facebook_redirect
@@ -716,18 +587,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :auth_provider => "facebook", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "facebook",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "facebook", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "facebook")
-          follow_redirect!
-          assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -749,8 +614,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success
@@ -783,17 +646,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "microsoft", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "microsoft",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" },
+                                       :auth_uid => auth_uid },
                             :email_hmac => email_hmac }
-          assert_redirected_to auth_path(:provider => "microsoft", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "microsoft")
-          follow_redirect!
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -803,8 +661,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     # Check the page
     assert_response :success
     assert_template "site/welcome"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_microsoft_duplicate_email
@@ -827,29 +683,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "users/new"
     assert_select "form > div > input.is-invalid#user_email"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_microsoft_failure
     OmniAuth.config.mock_auth[:microsoft] = :connection_failed
 
-    new_email = "newtester-microsoft2@osm.org"
-    display_name = "new_tester-microsoft2"
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => new_email,
-                                       :email_confirmation => new_email,
-                                       :display_name => display_name,
-                                       :auth_provider => "microsoft",
-                                       :auth_uid => "123454321",
-                                       :pass_crypt => "",
-                                       :pass_crypt_confirmation => "" } }
-          assert_redirected_to auth_path(:provider => "microsoft", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "microsoft")
+          post auth_path(:provider => "microsoft", :origin => "/user/new")
+          assert_response :redirect
           follow_redirect!
           assert_redirected_to auth_failure_path(:strategy => "microsoft", :message => "connection_failed", :origin => "/user/new")
           follow_redirect!
@@ -857,8 +700,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
         end
       end
     end
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_microsoft_redirect
@@ -883,18 +724,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :auth_provider => "microsoft", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "microsoft",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "microsoft", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "microsoft")
-          follow_redirect!
-          assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -916,8 +751,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success
@@ -952,7 +785,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :auth_provider => "github", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "github",
@@ -962,10 +795,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                             :read_ct => 1,
                             :read_tou => 1,
                             :email_hmac => email_hmac }
-          assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "github")
-          follow_redirect!
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -975,8 +804,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     # Check the page
     assert_response :success
     assert_template "site/welcome"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_github_duplicate_email
@@ -1000,29 +827,15 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "users/new"
     assert_select "form > div > input.is-invalid#user_email"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_github_failure
     OmniAuth.config.mock_auth[:github] = :connection_failed
 
-    new_email = "newtester-github2@osm.org"
-    display_name = "new_tester-github2"
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => new_email,
-                                       :email_confirmation => new_email,
-                                       :display_name => display_name,
-                                       :auth_provider => "github",
-                                       :auth_uid => "123454321",
-                                       :pass_crypt => "",
-                                       :pass_crypt_confirmation => "" } }
-          assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "github")
+          post auth_path(:provider => "github", :origin => "/user/new")
           follow_redirect!
           assert_redirected_to auth_failure_path(:strategy => "github", :message => "connection_failed", :origin => "/user/new")
           follow_redirect!
@@ -1030,8 +843,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
         end
       end
     end
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_github_redirect
@@ -1055,18 +866,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :email => orig_email, :email_hmac => email_hmac,
                                :auth_provider => "github", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "github",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "github", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "github")
-          follow_redirect!
-          assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -1088,8 +893,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success
@@ -1123,7 +926,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :email => new_email, :email_hmac => email_hmac,
                                :auth_provider => "wikipedia", :auth_uid => auth_uid
           follow_redirect!
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :display_name => display_name,
                                        :auth_provider => "wikipedia",
@@ -1133,10 +936,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                             :read_ct => 1,
                             :read_tou => 1,
                             :email_hmac => email_hmac }
-          assert_redirected_to auth_path(:provider => "wikipedia", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "wikipedia", :origin => "/user/new")
-          follow_redirect!
           assert_redirected_to welcome_path
           follow_redirect!
         end
@@ -1168,29 +967,16 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "users/new"
     assert_select "form > div > input.is-invalid#user_email"
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_wikipedia_failure
     OmniAuth.config.mock_auth[:wikipedia] = :connection_failed
 
-    new_email = "newtester-wikipedia2@osm.org"
-    display_name = "new_tester-wikipedia2"
     assert_difference("User.count", 0) do
       assert_difference("ActionMailer::Base.deliveries.size", 0) do
         perform_enqueued_jobs do
-          post "/user/new",
-               :params => { :user => { :email => new_email,
-                                       :email_confirmation => new_email,
-                                       :display_name => display_name,
-                                       :auth_provider => "wikipedia",
-                                       :auth_uid => "123454321",
-                                       :pass_crypt => "",
-                                       :pass_crypt_confirmation => "" } }
-          assert_redirected_to auth_path(:provider => "wikipedia", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "wikipedia", :origin => "/user/new")
+          post auth_path(:provider => "wikipedia", :origin => "/user/new")
+          assert_response :redirect
           follow_redirect!
           assert_redirected_to auth_failure_path(:strategy => "wikipedia", :message => "connection_failed", :origin => "/user/new")
           follow_redirect!
@@ -1198,8 +984,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
         end
       end
     end
-
-    ActionMailer::Base.deliveries.clear
   end
 
   def test_user_create_wikipedia_redirect
@@ -1225,18 +1009,12 @@ class UserCreationTest < ActionDispatch::IntegrationTest
                                :auth_provider => "wikipedia", :auth_uid => auth_uid
           follow_redirect!
 
-          post "/user/new",
+          post "/user",
                :params => { :user => { :email => new_email,
                                        :email_hmac => email_hmac,
                                        :display_name => display_name,
                                        :auth_provider => "wikipedia",
-                                       :auth_uid => auth_uid,
-                                       :consider_pd => "1" } }
-          assert_redirected_to auth_path(:provider => "wikipedia", :origin => "/user/new")
-          post response.location
-          assert_redirected_to auth_success_path(:provider => "wikipedia", :origin => "/user/new")
-          follow_redirect!
-          assert_redirected_to :controller => :confirmations, :action => :confirm, :display_name => display_name
+                                       :auth_uid => auth_uid } }
           assert_response :redirect
           follow_redirect!
         end
@@ -1258,8 +1036,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template "confirmations/confirm"
 
-    ActionMailer::Base.deliveries.clear
-
     # Go to the confirmation page
     get "/user/#{display_name}/confirm", :params => { :referer => "/welcome", :confirm_string => confirm_string }
     assert_response :success