Merge remote-tracking branch 'upstream/pull/4455'

This commit is contained in:
Tom Hughes 2024-05-06 09:15:03 +01:00
commit b625eefdeb
20 changed files with 857 additions and 677 deletions

View file

@ -38,7 +38,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
def test_confirm_get
user = build(:user, :pending)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
get user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
@ -50,7 +49,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
# Get the confirmation page
@ -71,7 +69,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post logout_path
@ -85,7 +82,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string }
@ -96,7 +92,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post logout_path
@ -111,7 +106,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post logout_path
@ -125,7 +119,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string, :referer => new_diary_entry_path }
@ -136,7 +129,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post logout_path
@ -151,7 +143,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
travel 2.weeks do
@ -165,7 +156,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
post user_confirm_path, :params => { :display_name => user.display_name, :confirm_string => confirm_string, :referer => new_diary_entry_path }
@ -183,7 +173,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
user = build(:user, :pending)
stub_gravatar_request(user.email)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
confirm_string = User.find_by(:email => user.email).generate_token_for(:new_user)
User.find_by(:display_name => user.display_name).hide!
@ -201,7 +190,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
def test_confirm_resend_success
user = build(:user, :pending)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
@ -220,25 +208,9 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
ActionMailer::Base.deliveries.clear
end
def test_confirm_resend_no_token
user = build(:user, :pending)
# only complete first half of registration
post user_new_path, :params => { :user => user.attributes }
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
get user_confirm_resend_path(user)
end
end
assert_redirected_to login_path
assert_match "User #{user.display_name} not found.", flash[:error]
end
def test_confirm_resend_deleted
user = build(:user, :pending)
post user_new_path, :params => { :user => user.attributes }
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
User.find_by(:display_name => user.display_name).hide!

View file

@ -82,7 +82,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "div#content", :count => 1 do
assert_select "form[action='/user/new'][method='post']", :count => 1 do
assert_select "input[id='user_email']", :count => 1
assert_select "input[id='user_email_confirmation']", :count => 1
assert_select "input[id='user_display_name']", :count => 1
assert_select "input[id='user_pass_crypt'][type='password']", :count => 1
assert_select "input[id='user_pass_crypt_confirmation'][type='password']", :count => 1
@ -106,18 +105,10 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
def test_new_success
user = build(:user, :pending)
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
assert_difference "User.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
perform_enqueued_jobs do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
post user_new_path, :params => { :user => user.attributes }
end
end
end
@ -151,55 +142,14 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "form > div > input.is-invalid#user_email"
end
def test_save_duplicate_email
def test_new_duplicate_email_uppercase
user = build(:user, :pending)
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
# Now create another user with that email
create(:user, :email => user.email)
# Check that the second half of registration fails
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
end
end
end
assert_response :success
assert_template "new"
assert_select "form > div > input.is-invalid#user_email"
end
def test_save_duplicate_email_uppercase
user = build(:user, :pending)
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
# Now create another user with that email, but uppercased
create(:user, :email => user.email.upcase)
# Check that the second half of registration fails
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
post user_new_path, :params => { :user => user.attributes }
end
end
end
@ -209,26 +159,14 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "form > div > input.is-invalid#user_email"
end
def test_save_duplicate_name
def test_new_duplicate_name
user = build(:user, :pending)
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
# Now create another user with that display name
create(:user, :display_name => user.display_name)
# Check that the second half of registration fails
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
post user_new_path, :params => { :user => user.attributes }
end
end
end
@ -238,26 +176,14 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "form > div > input.is-invalid#user_display_name"
end
def test_save_duplicate_name_uppercase
def test_new_duplicate_name_uppercase
user = build(:user, :pending)
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
# Now create another user with that display_name, but uppercased
create(:user, :display_name => user.display_name.upcase)
# Check that the second half of registration fails
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
post user_new_path, :params => { :user => user.attributes }
end
end
end
@ -267,18 +193,9 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_select "form > div > input.is-invalid#user_display_name"
end
def test_save_blocked_domain
def test_new_blocked_domain
user = build(:user, :pending, :email => "user@example.net")
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
# Now block that domain
create(:acl, :domain => "example.net", :k => "no_account_creation")
@ -286,7 +203,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
post user_new_path, :params => { :user => user.attributes }
end
end
end
@ -298,18 +215,9 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
def test_save_referer_params
user = build(:user, :pending)
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes, :referer => "/edit?editor=id#map=1/2/3" }
end
end
end
assert_difference "User.count", 1 do
assert_difference "ActionMailer::Base.deliveries.size", 1 do
post user_save_path, :params => { :read_ct => 1, :read_tou => 1 }
post user_new_path, :params => { :user => user.attributes, :referer => "/edit?editor=id#map=1/2/3" }
assert_enqueued_with :job => ActionMailer::MailDeliveryJob,
:args => proc { |args| args[3][:args][2] == welcome_path(:editor => "id", :zoom => 1, :lat => 2, :lon => 3) }
perform_enqueued_jobs
@ -319,24 +227,6 @@ class UsersControllerTest < ActionDispatch::IntegrationTest
ActionMailer::Base.deliveries.clear
end
def test_terms_new_user
user = build(:user, :pending)
# Set up our user as being half-way through registration
assert_no_difference "User.count" do
assert_no_difference "ActionMailer::Base.deliveries.size" do
perform_enqueued_jobs do
post user_new_path, :params => { :user => user.attributes }
end
end
end
get user_terms_path
assert_response :success
assert_template :terms
end
def test_terms_agreed
user = create(:user, :terms_seen => true, :terms_agreed => Date.yesterday)

View file

@ -116,8 +116,8 @@ class UserHelperTest < ActionView::TestCase
def test_auth_button
button = auth_button("google", "google")
img_tag = "<img alt=\"Log in with a Google OpenID\" class=\"rounded-3\" src=\"/images/google.svg\" width=\"36\" height=\"36\" />"
assert_equal("<a class=\"auth_button\" title=\"Log in with Google\" rel=\"nofollow\" data-method=\"post\" href=\"/auth/google\">#{img_tag}</a>", button)
img_tag = "<img alt=\"Log in with a Google OpenID\" class=\"rounded-1\" src=\"/images/google.svg\" width=\"24\" height=\"24\" />"
assert_equal("<a class=\"auth_button p-2 d-block\" title=\"Log in with Google\" rel=\"nofollow\" data-method=\"post\" href=\"/auth/google\">#{img_tag}</a>", button)
end
private

File diff suppressed because it is too large Load diff

View file

@ -7,16 +7,11 @@ class ConfirmationResendSystemTest < ApplicationSystemTestCase
within ".new_user" do
fill_in "Email", :with => @user.email
fill_in "Email Confirmation", :with => @user.email
fill_in "Display Name", :with => @user.display_name
fill_in "Password", :with => "testtest"
fill_in "Confirm Password", :with => "testtest"
click_on "Sign Up"
end
check "I have read and agree to the above contributor terms"
check "I have read and agree to the Terms of Use"
click_on "Continue"
end
test "flash message should not contain raw html" do

View file

@ -4,29 +4,8 @@ class UserSignupTest < ApplicationSystemTestCase
test "Sign up from login page" do
visit login_path
click_on "Register now"
click_on "Sign up"
assert_content "Confirm Password"
end
test "externally redirect when contributor terms declined" do
user = build(:user)
visit root_path
click_on "Sign Up"
within ".new_user" do
fill_in "Email", :with => user.email
fill_in "Email Confirmation", :with => user.email
fill_in "Display Name", :with => user.display_name
fill_in "Password", :with => "testtest"
fill_in "Confirm Password", :with => "testtest"
click_on "Sign Up"
end
assert_content "Contributor terms"
click_on "Cancel"
assert_current_path "https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined"
end
end