Fix new rubocop warnings

This commit is contained in:
Tom Hughes 2024-01-09 18:23:28 +00:00
parent 6067200e5b
commit 55a793150d
20 changed files with 82 additions and 72 deletions

View file

@ -14,6 +14,11 @@ require:
- rubocop-rails
- rubocop-rake
# Offense count: 11
# Configuration parameters: Include, MaxAmount
FactoryBot/ExcessiveCreateList:
MaxAmount: 200
# Offense count: 557
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.

View file

@ -9,9 +9,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
test "the status is deleted and the personal data removed" do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
accept_confirm do
click_link "Delete Account"
click_on "Delete Account"
end
assert_current_path root_path
@ -23,9 +23,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
test "the user is signed out after deletion" do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
accept_confirm do
click_link "Delete Account"
click_on "Delete Account"
end
assert_content "Log In"
@ -34,9 +34,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
test "the user is shown a confirmation flash message" do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
accept_confirm do
click_link "Delete Account"
click_on "Delete Account"
end
assert_content "Account Deleted"
@ -47,7 +47,7 @@ class AccountDeletionTest < ApplicationSystemTestCase
travel 1.hour do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
assert_no_content "cannot currently be deleted"
end
@ -61,7 +61,7 @@ class AccountDeletionTest < ApplicationSystemTestCase
travel 1.hour do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
assert_no_content "cannot currently be deleted"
end
@ -75,7 +75,7 @@ class AccountDeletionTest < ApplicationSystemTestCase
travel 12.hours do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
assert_no_content "cannot currently be deleted"
end
@ -89,7 +89,7 @@ class AccountDeletionTest < ApplicationSystemTestCase
travel 10.hours do
visit edit_account_path
click_link "Delete Account..."
click_on "Delete Account..."
assert_content "cannot currently be deleted"
assert_content "in about 1 hour"

View file

@ -5,16 +5,18 @@ class ConfirmationResendSystemTest < ApplicationSystemTestCase
@user = build(:user)
visit user_new_path
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_button "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
check "I have read and agree to the above contributor terms"
check "I have read and agree to the Terms of Use"
click_button "Continue"
click_on "Continue"
end
test "flash message should not contain raw html" do

View file

@ -13,7 +13,7 @@ class DiaryEntrySystemTest < ApplicationSystemTestCase
sign_in_as(create(:user))
visit diary_entries_path
click_link "Send a message to the author"
click_on "Send a message to the author"
assert_content "Send a new message"
assert_equal "Re: #{@diary_entry.title}", page.find_field("Subject").value

View file

@ -80,21 +80,21 @@ class IssuesTest < ApplicationSystemTestCase
# No issues against the user
visit issues_path
fill_in "search_by_user", :with => good_user.display_name
click_button "Search"
click_on "Search"
assert_no_content I18n.t("issues.index.user_not_found")
assert_content I18n.t("issues.index.issues_not_found")
# User doesn't exist
visit issues_path
fill_in "search_by_user", :with => "Nonexistent User"
click_button "Search"
click_on "Search"
assert_content I18n.t("issues.index.user_not_found")
assert_content I18n.t("issues.index.issues_not_found")
# Find Issue against bad_user
visit issues_path
fill_in "search_by_user", :with => bad_user.display_name
click_button "Search"
click_on "Search"
assert_no_content I18n.t("issues.index.user_not_found")
assert_no_content I18n.t("issues.index.issues_not_found")
end
@ -106,7 +106,7 @@ class IssuesTest < ApplicationSystemTestCase
visit issue_path(issue)
fill_in :issue_comment_body, :with => "test comment"
click_button "Add Comment"
click_on "Add Comment"
assert_content I18n.t("issue_comments.create.comment_created")
assert_content "test comment"
@ -123,7 +123,7 @@ class IssuesTest < ApplicationSystemTestCase
fill_in :issue_comment_body, :with => "reassigning to moderators"
check :reassign
click_button "Add Comment"
click_on "Add Comment"
assert_content "and the issue was reassigned"
assert_current_path issues_path(:status => "open")
@ -140,7 +140,7 @@ class IssuesTest < ApplicationSystemTestCase
fill_in :issue_comment_body, :with => "reassigning to moderators"
check :reassign
click_button "Add Comment"
click_on "Add Comment"
assert_content "and the issue was reassigned"
assert_current_path issue_path(issue)

View file

@ -9,7 +9,7 @@ class MessagesTest < ApplicationSystemTestCase
visit inbox_messages_path
assert_text "You have 1 new message and 0 old messages"
click_button "Delete"
click_on "Delete"
assert_text "You have 0 new messages and 0 old messages"
end
@ -21,7 +21,7 @@ class MessagesTest < ApplicationSystemTestCase
visit outbox_messages_path
assert_text "You have 1 sent message"
click_button "Delete"
click_on "Delete"
assert_text "You have 0 sent messages"
end
@ -35,7 +35,7 @@ class MessagesTest < ApplicationSystemTestCase
visit muted_messages_path
assert_text "1 muted message"
click_button "Delete"
click_on "Delete"
assert_text "0 muted messages"
end
end

View file

@ -34,7 +34,7 @@ class NoteCommentsTest < ApplicationSystemTestCase
assert_button "Comment & Resolve"
assert_button "Comment", :disabled => false
click_button "Comment"
click_on "Comment"
assert_content "Comment from #{user.display_name}"
assert_content "Some newly added note comment"

View file

@ -8,7 +8,7 @@ class Oauth2Test < ApplicationSystemTestCase
assert_text "OpenStreetMap Web Site"
accept_alert do
click_link "Revoke Access"
click_on "Revoke Access"
end
assert_text "You have not yet authorized any OAuth 2 applications."

View file

@ -5,7 +5,7 @@ class PreferencesTest < ApplicationSystemTestCase
sign_in_as(create(:user))
visit edit_preferences_path
click_button "Update Preferences"
click_on "Update Preferences"
assert_content "Preferences updated"
end
@ -15,7 +15,7 @@ class PreferencesTest < ApplicationSystemTestCase
visit edit_preferences_path
fill_in "Preferred Languages", :with => "fr"
click_button "Update Preferences"
click_on "Update Preferences"
assert_content "Préférences mises à jour"
end

View file

@ -19,14 +19,14 @@ class ReportDiaryCommentTest < ApplicationSystemTestCase
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert_content @diary_entry.title
click_link I18n.t("diary_entries.diary_comment.report")
click_on I18n.t("diary_entries.diary_comment.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.diary_comment.spam_label")
fill_in "report_details", :with => "This comment is spam"
assert_difference "Issue.count", 1 do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"

View file

@ -18,14 +18,14 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert_content @diary_entry.title
click_link I18n.t("diary_entries.diary_entry.report")
click_on I18n.t("diary_entries.diary_entry.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.diary_entry.spam_label")
fill_in "report_details", :with => "This is advertising"
assert_difference "Issue.count", 1 do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"
@ -42,14 +42,14 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
visit diary_entry_path(@diary_entry.user.display_name, @diary_entry)
assert_content @diary_entry.title
click_link I18n.t("diary_entries.diary_entry.report")
click_on I18n.t("diary_entries.diary_entry.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.diary_entry.spam_label")
fill_in "report_details", :with => "This is advertising"
assert_no_difference "Issue.count" do
click_button "Create Report"
click_on "Create Report"
end
issue.reload

View file

@ -14,14 +14,14 @@ class ReportNoteTest < ApplicationSystemTestCase
sign_in_as(create(:user))
visit note_path(note)
click_link I18n.t("notes.show.report")
click_on I18n.t("notes.show.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.note.spam_label")
fill_in "report_details", :with => "This is spam"
assert_difference "Issue.count", 1 do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"
@ -35,14 +35,14 @@ class ReportNoteTest < ApplicationSystemTestCase
sign_in_as(create(:user))
visit note_path(note)
click_link I18n.t("notes.show.report")
click_on I18n.t("notes.show.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.note.spam_label")
fill_in "report_details", :with => "This is spam"
assert_difference "Issue.count", 1 do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"

View file

@ -14,14 +14,14 @@ class ReportUserTest < ApplicationSystemTestCase
sign_in_as(create(:user))
visit user_path(user)
click_link I18n.t("users.show.report")
click_on I18n.t("users.show.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.user.vandal_label")
fill_in "report_details", :with => "This user is a vandal"
assert_difference "Issue.count", 1 do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"
@ -35,14 +35,14 @@ class ReportUserTest < ApplicationSystemTestCase
sign_in_as(create(:user))
visit user_path(user)
click_link I18n.t("users.show.report")
click_on I18n.t("users.show.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.user.vandal_label")
fill_in "report_details", :with => "This user is a vandal"
assert_difference "Issue.count", 1 do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"
@ -52,14 +52,14 @@ class ReportUserTest < ApplicationSystemTestCase
visit user_path(user)
click_link I18n.t("users.show.report")
click_on I18n.t("users.show.report")
assert_content "Report"
assert_content I18n.t("reports.new.disclaimer.intro")
choose I18n.t("reports.new.categories.user.spam_label")
fill_in "report_details", :with => "This user is a spammer"
assert_no_difference "Issue.count" do
click_button "Create Report"
click_on "Create Report"
end
assert_content "Your report has been registered successfully"

View file

@ -45,7 +45,7 @@ class ReportNoteTest < ApplicationSystemTestCase
visit user_path(blocked_user)
assert_link "Revoke all blocks"
click_link "Revoke all blocks"
click_on "Revoke all blocks"
assert_title "Revoking all blocks on #{blocked_user.display_name}"
assert_text "Revoking all blocks on #{blocked_user.display_name}"
assert_unchecked_field "Are you sure you wish to revoke 1 active block?"
@ -62,7 +62,7 @@ class ReportNoteTest < ApplicationSystemTestCase
visit user_path(blocked_user)
assert_link "Revoke all blocks"
click_link "Revoke all blocks"
click_on "Revoke all blocks"
assert_title "Revoking all blocks on #{blocked_user.display_name}"
assert_text "Revoking all blocks on #{blocked_user.display_name}"
assert_unchecked_field "Are you sure you wish to revoke 2 active blocks?"

View file

@ -6,8 +6,8 @@ class UserLogoutTest < ApplicationSystemTestCase
sign_in_as(user)
assert_no_content "Log In"
click_button user.display_name
click_link "Log Out"
click_on user.display_name
click_on "Log Out"
assert_content "Log In"
end
@ -17,8 +17,8 @@ class UserLogoutTest < ApplicationSystemTestCase
visit traces_path
assert_no_content "Log In"
click_button user.display_name
click_link "Log Out"
click_on user.display_name
click_on "Log Out"
assert_content "Log In"
assert_content "Public GPS Traces"
end
@ -30,7 +30,7 @@ class UserLogoutTest < ApplicationSystemTestCase
visit logout_path
assert_content "Logout from OpenStreetMap"
click_button "Logout"
click_on "Logout"
assert_content "Log In"
end
@ -41,7 +41,7 @@ class UserLogoutTest < ApplicationSystemTestCase
visit logout_path(:referer => "/traces")
assert_content "Logout from OpenStreetMap"
click_button "Logout"
click_on "Logout"
assert_content "Log In"
assert_content "Public GPS Traces"
end

View file

@ -10,14 +10,14 @@ class UserMutingTest < ApplicationSystemTestCase
sign_in_as(user)
visit user_path(other_user)
click_link "Mute this User"
click_on "Mute this User"
assert_content "You muted #{other_user.display_name}"
visit edit_account_path
assert_content "Muted Users"
click_link "Muted Users"
click_on "Muted Users"
assert_content "You have muted 1 User"
click_link "Unmute"
click_on "Unmute"
assert_content "You unmuted #{other_user.display_name}"
refute_content "Muted Users"
@ -35,7 +35,7 @@ class UserMutingTest < ApplicationSystemTestCase
fill_in "Body", :with => "some message"
assert_no_emails do
click_button "Send"
click_on "Send"
end
message = Message.find_by(:sender => muted_user, :recipient => user)

View file

@ -4,7 +4,7 @@ class UserSignupTest < ApplicationSystemTestCase
test "Sign up from login page" do
visit login_path
click_link "Register now"
click_on "Register now"
assert_content "Confirm Password"
end
@ -13,16 +13,19 @@ class UserSignupTest < ApplicationSystemTestCase
user = build(:user)
visit root_path
click_link "Sign Up"
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_button "Sign Up"
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_button "Cancel"
click_on "Cancel"
assert_current_path "https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined"
end

View file

@ -10,7 +10,7 @@ class UserStatusChangeTest < ApplicationSystemTestCase
user = create(:user, :suspended)
visit user_path(user)
accept_confirm do
click_link "Unsuspend"
click_on "Unsuspend"
end
assert_no_content "Unsuspend"
@ -22,7 +22,7 @@ class UserStatusChangeTest < ApplicationSystemTestCase
user = create(:user, :suspended)
visit user_path(user)
accept_confirm do
click_link "Confirm"
click_on "Confirm"
end
assert_no_content "Unsuspend"

View file

@ -13,7 +13,7 @@ class ViewCommunitiesTest < ApplicationSystemTestCase
visit edit_preferences_path
fill_in "Preferred Languages", :with => "fr"
click_button "Update Preferences"
click_on "Update Preferences"
visit "/communities"
assert_link "OpenStreetMap États-Unis", :href => "https://www.openstreetmap.us/"

View file

@ -245,7 +245,7 @@ module ActiveSupport
visit login_path
fill_in "username", :with => user.email
fill_in "password", :with => "test"
click_button "Login", :match => :first
click_on "Login", :match => :first
end
def session_for(user)