Fix new rubocop warnings

This commit is contained in:
Tom Hughes 2023-09-26 18:35:05 +01:00
parent a18366903e
commit e8af4b85bf
23 changed files with 57 additions and 60 deletions

View file

@ -199,7 +199,7 @@ module Api
assert_equal Settings.api_version, js["version"] assert_equal Settings.api_version, js["version"]
assert_equal Settings.generator, js["generator"] assert_equal Settings.generator, js["generator"]
assert_equal changeset.id, js["changeset"]["id"] assert_equal changeset.id, js["changeset"]["id"]
assert js["changeset"]["open"] assert_operator js["changeset"], :[], "open"
assert_equal changeset.created_at.xmlschema, js["changeset"]["created_at"] assert_equal changeset.created_at.xmlschema, js["changeset"]["created_at"]
assert_nil js["changeset"]["closed_at"] assert_nil js["changeset"]["closed_at"]
assert_nil js["changeset"]["tags"] assert_nil js["changeset"]["tags"]
@ -215,7 +215,7 @@ module Api
assert_equal Settings.api_version, js["version"] assert_equal Settings.api_version, js["version"]
assert_equal Settings.generator, js["generator"] assert_equal Settings.generator, js["generator"]
assert_equal changeset.id, js["changeset"]["id"] assert_equal changeset.id, js["changeset"]["id"]
assert js["changeset"]["open"] assert_operator js["changeset"], :[], "open"
assert_equal changeset.created_at.xmlschema, js["changeset"]["created_at"] assert_equal changeset.created_at.xmlschema, js["changeset"]["created_at"]
assert_nil js["changeset"]["closed_at"] assert_nil js["changeset"]["closed_at"]
assert_nil js["changeset"]["tags"] assert_nil js["changeset"]["tags"]
@ -697,10 +697,10 @@ module Api
# check that the changeset bbox is within bounds # check that the changeset bbox is within bounds
cs = Changeset.find(changeset_id) cs = Changeset.find(changeset_id)
assert cs.min_lon >= -180 * GeoRecord::SCALE, "Minimum longitude (#{cs.min_lon / GeoRecord::SCALE}) should be >= -180 to be valid." assert_operator cs.min_lon, :>=, -180 * GeoRecord::SCALE, "Minimum longitude (#{cs.min_lon / GeoRecord::SCALE}) should be >= -180 to be valid."
assert cs.max_lon <= 180 * GeoRecord::SCALE, "Maximum longitude (#{cs.max_lon / GeoRecord::SCALE}) should be <= 180 to be valid." assert_operator cs.max_lon, :<=, 180 * GeoRecord::SCALE, "Maximum longitude (#{cs.max_lon / GeoRecord::SCALE}) should be <= 180 to be valid."
assert cs.min_lat >= -90 * GeoRecord::SCALE, "Minimum latitude (#{cs.min_lat / GeoRecord::SCALE}) should be >= -90 to be valid." assert_operator cs.min_lat, :>=, -90 * GeoRecord::SCALE, "Minimum latitude (#{cs.min_lat / GeoRecord::SCALE}) should be >= -90 to be valid."
assert cs.max_lat <= 90 * GeoRecord::SCALE, "Maximum latitude (#{cs.max_lat / GeoRecord::SCALE}) should be <= 90 to be valid." assert_operator cs.max_lat, :<=, 90 * GeoRecord::SCALE, "Maximum latitude (#{cs.max_lat / GeoRecord::SCALE}) should be <= 90 to be valid."
end end
## ##

View file

@ -258,8 +258,7 @@ module Api
# valid delete should return the new version number, which should # valid delete should return the new version number, which should
# be greater than the old version number # be greater than the old version number
assert @response.body.to_i > node.version, assert_operator @response.body.to_i, :>, node.version, "delete request should return a new version number for node"
"delete request should return a new version number for node"
# deleting the same node twice doesn't work # deleting the same node twice doesn't work
xml = xml_for_node(node) xml = xml_for_node(node)

View file

@ -612,8 +612,7 @@ module Api
# valid delete should return the new version number, which should # valid delete should return the new version number, which should
# be greater than the old version number # be greater than the old version number
assert @response.body.to_i > multi_tag_relation.version, assert_operator @response.body.to_i, :>, multi_tag_relation.version, "delete request should return a new version number for relation"
"delete request should return a new version number for relation"
# this won't work since the relation is already deleted # this won't work since the relation is already deleted
xml = update_changeset(xml_for_relation(deleted_relation), changeset.id) xml = update_changeset(xml_for_relation(deleted_relation), changeset.id)

View file

@ -731,7 +731,7 @@ module Api
def check_json_details(js, user, include_private, include_email) def check_json_details(js, user, include_private, include_email)
assert_equal user.id, js["user"]["id"] assert_equal user.id, js["user"]["id"]
assert_equal user.description, js["user"]["description"] assert_equal user.description, js["user"]["description"]
assert js["user"]["contributor_terms"]["agreed"] assert_operator js["user"]["contributor_terms"], :[], "agreed"
if include_private if include_private
assert_not js["user"]["contributor_terms"]["pd"] assert_not js["user"]["contributor_terms"]["pd"]

View file

@ -379,8 +379,7 @@ module Api
# check the returned value - should be the new version number # check the returned value - should be the new version number
# valid delete should return the new version number, which should # valid delete should return the new version number, which should
# be greater than the old version number # be greater than the old version number
assert @response.body.to_i > way.version, assert_operator @response.body.to_i, :>, way.version, "delete request should return a new version number for way"
"delete request should return a new version number for way"
# this won't work since the way is already deleted # this won't work since the way is already deleted
xml = xml_for_way(deleted_way) xml = xml_for_way(deleted_way)

View file

@ -321,7 +321,7 @@ class ChangesetsControllerTest < ActionDispatch::IntegrationTest
## ##
# check the result of a feed # check the result of a feed
def check_feed_result(changesets) def check_feed_result(changesets)
assert changesets.size <= 20 assert_operator changesets.size, :<=, 20
assert_select "feed", :count => [changesets.size, 1].min do assert_select "feed", :count => [changesets.size, 1].min do
assert_select "> title", :count => 1, :text => /^Changesets/ assert_select "> title", :count => 1, :text => /^Changesets/

View file

@ -356,7 +356,7 @@ class UserBlocksControllerTest < ActionDispatch::IntegrationTest
assert_response :success assert_response :success
assert_template "revoke" assert_template "revoke"
b = UserBlock.find(active_block.id) b = UserBlock.find(active_block.id)
assert b.ends_at - Time.now.utc > 100 assert_operator b.ends_at - Time.now.utc, :>, 100
# Check that revoking a block works using POST # Check that revoking a block works using POST
post revoke_user_block_path(:id => active_block, :confirm => true) post revoke_user_block_path(:id => active_block, :confirm => true)

View file

@ -80,7 +80,7 @@ class LocaleTest < ActiveSupport::TestCase
end end
def test_available def test_available
assert Locale.available.count <= I18n.available_locales.count assert_operator Locale.available.count, :<=, I18n.available_locales.count
end end
def test_preferred def test_preferred

View file

@ -61,6 +61,6 @@ class PasswordHashTest < ActiveSupport::TestCase
format = Argon2::HashFormat.new(hash) format = Argon2::HashFormat.new(hash)
assert_equal "argon2id", format.variant assert_equal "argon2id", format.variant
assert format.version <= 19 assert_operator format.version, :<=, 19
end end
end end

View file

@ -20,7 +20,7 @@ class ShortLinkTest < ActiveSupport::TestCase
# smaller range. # smaller range.
distance = Math.sqrt(((lat - lat2)**2) + ((lon - lon2)**2)) distance = Math.sqrt(((lat - lat2)**2) + ((lon - lon2)**2))
max_distance = 360.0 / (1 << (zoom + 8)) * 0.5 * Math.sqrt(5) max_distance = 360.0 / (1 << (zoom + 8)) * 0.5 * Math.sqrt(5)
assert max_distance > distance, "Maximum expected error exceeded: #{max_distance} <= #{distance} for (#{lat}, #{lon}, #{zoom})." assert_operator max_distance, :>, distance, "Maximum expected error exceeded: #{max_distance} <= #{distance} for (#{lat}, #{lon}, #{zoom})."
end end
end end

View file

@ -9,9 +9,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
test "the status is deleted and the personal data removed" do test "the status is deleted and the personal data removed" do
visit edit_account_path visit edit_account_path
click_on "Delete Account..." click_link "Delete Account..."
accept_confirm do accept_confirm do
click_on "Delete Account" click_link "Delete Account"
end end
assert_current_path root_path assert_current_path root_path
@ -23,9 +23,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
test "the user is signed out after deletion" do test "the user is signed out after deletion" do
visit edit_account_path visit edit_account_path
click_on "Delete Account..." click_link "Delete Account..."
accept_confirm do accept_confirm do
click_on "Delete Account" click_link "Delete Account"
end end
assert_content "Log In" assert_content "Log In"
@ -34,9 +34,9 @@ class AccountDeletionTest < ApplicationSystemTestCase
test "the user is shown a confirmation flash message" do test "the user is shown a confirmation flash message" do
visit edit_account_path visit edit_account_path
click_on "Delete Account..." click_link "Delete Account..."
accept_confirm do accept_confirm do
click_on "Delete Account" click_link "Delete Account"
end end
assert_content "Account Deleted" assert_content "Account Deleted"

View file

@ -10,7 +10,7 @@ class DiaryEntrySystemTest < ApplicationSystemTestCase
sign_in_as(create(:user)) sign_in_as(create(:user))
visit diary_entries_path visit diary_entries_path
click_on "Send a message to the author" click_link "Send a message to the author"
assert_content "Send a new message" assert_content "Send a new message"
assert_equal "Re: #{@diary_entry.title}", page.find_field("Subject").value 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 # No issues against the user
visit issues_path visit issues_path
fill_in "search_by_user", :with => good_user.display_name fill_in "search_by_user", :with => good_user.display_name
click_on "Search" click_button "Search"
assert_no_content I18n.t("issues.index.user_not_found") assert_no_content I18n.t("issues.index.user_not_found")
assert_content I18n.t("issues.index.issues_not_found") assert_content I18n.t("issues.index.issues_not_found")
# User doesn't exist # User doesn't exist
visit issues_path visit issues_path
fill_in "search_by_user", :with => "Nonexistent User" fill_in "search_by_user", :with => "Nonexistent User"
click_on "Search" click_button "Search"
assert_content I18n.t("issues.index.user_not_found") assert_content I18n.t("issues.index.user_not_found")
assert_content I18n.t("issues.index.issues_not_found") assert_content I18n.t("issues.index.issues_not_found")
# Find Issue against bad_user # Find Issue against bad_user
visit issues_path visit issues_path
fill_in "search_by_user", :with => bad_user.display_name fill_in "search_by_user", :with => bad_user.display_name
click_on "Search" click_button "Search"
assert_no_content I18n.t("issues.index.user_not_found") assert_no_content I18n.t("issues.index.user_not_found")
assert_no_content I18n.t("issues.index.issues_not_found") assert_no_content I18n.t("issues.index.issues_not_found")
end end
@ -106,7 +106,7 @@ class IssuesTest < ApplicationSystemTestCase
visit issue_path(issue) visit issue_path(issue)
fill_in :issue_comment_body, :with => "test comment" fill_in :issue_comment_body, :with => "test comment"
click_on "Add Comment" click_button "Add Comment"
assert_content I18n.t("issue_comments.create.comment_created") assert_content I18n.t("issue_comments.create.comment_created")
assert_content "test comment" assert_content "test comment"
@ -123,7 +123,7 @@ class IssuesTest < ApplicationSystemTestCase
fill_in :issue_comment_body, :with => "reassigning to moderators" fill_in :issue_comment_body, :with => "reassigning to moderators"
check :reassign check :reassign
click_on "Add Comment" click_button "Add Comment"
assert_content "and the issue was reassigned" assert_content "and the issue was reassigned"
assert_current_path issues_path(:status => "open") assert_current_path issues_path(:status => "open")
@ -140,7 +140,7 @@ class IssuesTest < ApplicationSystemTestCase
fill_in :issue_comment_body, :with => "reassigning to moderators" fill_in :issue_comment_body, :with => "reassigning to moderators"
check :reassign check :reassign
click_on "Add Comment" click_button "Add Comment"
assert_content "and the issue was reassigned" assert_content "and the issue was reassigned"
assert_current_path issue_path(issue) assert_current_path issue_path(issue)

View file

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

View file

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

View file

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

View file

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

View file

@ -6,8 +6,8 @@ class UserLogoutTest < ApplicationSystemTestCase
sign_in_as(user) sign_in_as(user)
assert_no_content "Log In" assert_no_content "Log In"
click_on user.display_name click_button user.display_name
click_on "Log Out" click_link "Log Out"
assert_content "Log In" assert_content "Log In"
end end
@ -17,8 +17,8 @@ class UserLogoutTest < ApplicationSystemTestCase
visit traces_path visit traces_path
assert_no_content "Log In" assert_no_content "Log In"
click_on user.display_name click_button user.display_name
click_on "Log Out" click_link "Log Out"
assert_content "Log In" assert_content "Log In"
assert_content "Public GPS Traces" assert_content "Public GPS Traces"
end end

View file

@ -4,7 +4,7 @@ class UserSignupTest < ApplicationSystemTestCase
test "Sign up from login page" do test "Sign up from login page" do
visit login_path visit login_path
click_on "Register now" click_link "Register now"
assert_content "Confirm Password" assert_content "Confirm Password"
end end
@ -13,7 +13,7 @@ class UserSignupTest < ApplicationSystemTestCase
user = build(:user) user = build(:user)
visit root_path visit root_path
click_on "Sign Up" click_link "Sign Up"
fill_in "Email", :with => user.email fill_in "Email", :with => user.email
fill_in "Email Confirmation", :with => user.email fill_in "Email Confirmation", :with => user.email
fill_in "Display Name", :with => user.display_name fill_in "Display Name", :with => user.display_name
@ -22,7 +22,7 @@ class UserSignupTest < ApplicationSystemTestCase
click_button "Sign Up" click_button "Sign Up"
assert_content "Contributor terms" assert_content "Contributor terms"
click_on "Cancel" click_button "Cancel"
assert_current_path "https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined" assert_current_path "https://wiki.openstreetmap.org/wiki/Contributor_Terms_Declined"
end end

View file

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

View file

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

View file

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