From: Tom Hughes Date: Tue, 9 Jan 2024 18:23:28 +0000 (+0000) Subject: Fix new rubocop warnings X-Git-Tag: live~316 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/55a793150dbb2caa0bc2d6ad69a85515fa23e58d Fix new rubocop warnings --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index deaea8e2d..8a196f52e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -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. diff --git a/test/system/account_deletion_test.rb b/test/system/account_deletion_test.rb index e6517dccc..ca5ef7fe8 100644 --- a/test/system/account_deletion_test.rb +++ b/test/system/account_deletion_test.rb @@ -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" diff --git a/test/system/confirmation_resend_test.rb b/test/system/confirmation_resend_test.rb index f615a6321..31b9ed7bb 100644 --- a/test/system/confirmation_resend_test.rb +++ b/test/system/confirmation_resend_test.rb @@ -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 diff --git a/test/system/diary_entry_test.rb b/test/system/diary_entry_test.rb index 290b94207..ba091c538 100644 --- a/test/system/diary_entry_test.rb +++ b/test/system/diary_entry_test.rb @@ -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 diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index a40306e3c..b9b989c07 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -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) diff --git a/test/system/messages_test.rb b/test/system/messages_test.rb index 60011e4d6..dea0d2208 100644 --- a/test/system/messages_test.rb +++ b/test/system/messages_test.rb @@ -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 diff --git a/test/system/note_comments_test.rb b/test/system/note_comments_test.rb index 7666f69e2..70cfc417c 100644 --- a/test/system/note_comments_test.rb +++ b/test/system/note_comments_test.rb @@ -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" diff --git a/test/system/oauth2_test.rb b/test/system/oauth2_test.rb index ed5ec1532..0b9213aaa 100644 --- a/test/system/oauth2_test.rb +++ b/test/system/oauth2_test.rb @@ -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." diff --git a/test/system/preferences_test.rb b/test/system/preferences_test.rb index b071b1f73..59a7209f5 100644 --- a/test/system/preferences_test.rb +++ b/test/system/preferences_test.rb @@ -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 diff --git a/test/system/report_diary_comment_test.rb b/test/system/report_diary_comment_test.rb index 15ef1ad3c..3504ab061 100644 --- a/test/system/report_diary_comment_test.rb +++ b/test/system/report_diary_comment_test.rb @@ -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" diff --git a/test/system/report_diary_entry_test.rb b/test/system/report_diary_entry_test.rb index 545723ebb..dde06cffc 100644 --- a/test/system/report_diary_entry_test.rb +++ b/test/system/report_diary_entry_test.rb @@ -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 diff --git a/test/system/report_note_test.rb b/test/system/report_note_test.rb index b7e1bfc9e..79894eb89 100644 --- a/test/system/report_note_test.rb +++ b/test/system/report_note_test.rb @@ -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" diff --git a/test/system/report_user_test.rb b/test/system/report_user_test.rb index 9a0abe9ea..7a9e800c8 100644 --- a/test/system/report_user_test.rb +++ b/test/system/report_user_test.rb @@ -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" diff --git a/test/system/user_blocks_test.rb b/test/system/user_blocks_test.rb index 957ecb662..f710f74aa 100644 --- a/test/system/user_blocks_test.rb +++ b/test/system/user_blocks_test.rb @@ -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?" diff --git a/test/system/user_logout_test.rb b/test/system/user_logout_test.rb index fc27b7c18..2f5331711 100644 --- a/test/system/user_logout_test.rb +++ b/test/system/user_logout_test.rb @@ -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 diff --git a/test/system/user_muting_test.rb b/test/system/user_muting_test.rb index ce4346115..e70005e64 100644 --- a/test/system/user_muting_test.rb +++ b/test/system/user_muting_test.rb @@ -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) diff --git a/test/system/user_signup_test.rb b/test/system/user_signup_test.rb index 88899d710..e97046800 100644 --- a/test/system/user_signup_test.rb +++ b/test/system/user_signup_test.rb @@ -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 diff --git a/test/system/user_status_change_test.rb b/test/system/user_status_change_test.rb index e4cca1eab..30b923732 100644 --- a/test/system/user_status_change_test.rb +++ b/test/system/user_status_change_test.rb @@ -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" diff --git a/test/system/view_communities_test.rb b/test/system/view_communities_test.rb index 539daaa30..349d0a5bf 100644 --- a/test/system/view_communities_test.rb +++ b/test/system/view_communities_test.rb @@ -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/" diff --git a/test/test_helper.rb b/test/test_helper.rb index 19e1a2784..9d06d2353 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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)