+ 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",
+ :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" } }
+ end
+ end
+ end
+ assert_response :success
+ assert_template "users/new"
+ assert_select "form"
+ assert_select "form > div > input.is-invalid#user_email"
+ end
+