Fix some new rubocop warnings

This commit is contained in:
Tom Hughes 2020-08-06 21:56:18 +01:00
parent c03ba5f6b8
commit ea59d95f4a
23 changed files with 99 additions and 81 deletions

View file

@ -291,7 +291,7 @@ module Api
assert_response :success
amf_parse_response
rel = amf_result("/1")
assert_equal rel[0], 0
assert_equal(0, rel[0])
assert_equal rel[2], id
end
@ -301,8 +301,8 @@ module Api
assert_response :success
amf_parse_response
rel = amf_result("/1")
assert_equal rel[0], -4
assert_equal rel[1], "relation"
assert_equal(-4, rel[0])
assert_equal("relation", rel[1])
assert_equal rel[2], id
assert(rel[3].nil?) && rel[4].nil?
end
@ -313,8 +313,8 @@ module Api
assert_response :success
amf_parse_response
rel = amf_result("/1")
assert_equal rel[0], -4
assert_equal rel[1], "relation"
assert_equal(-4, rel[0])
assert_equal("relation", rel[1])
assert_equal rel[2], id
assert(rel[3].nil?) && rel[4].nil?
end
@ -426,8 +426,8 @@ module Api
history = amf_result("/1")
# ['way',wayid,history]
assert_equal history[0], "way"
assert_equal history[1], 0
assert_equal("way", history[0])
assert_equal(0, history[1])
assert_empty history[2]
end
@ -445,8 +445,7 @@ module Api
# ['node',nodeid,history]
# note that (as per getway_history) we actually round up
# to the next second
assert_equal history[0], "node",
'first element should be "node"'
assert_equal("node", history[0], 'first element should be "node"')
assert_equal history[1], node.id,
"second element should be the input node ID"
assert_equal history[2].first[0],
@ -464,8 +463,8 @@ module Api
history = amf_result("/1")
# ['node',nodeid,history]
assert_equal history[0], "node"
assert_equal history[1], 0
assert_equal("node", history[0])
assert_equal(0, history[1])
assert_empty history[2]
end
@ -979,15 +978,15 @@ module Api
new_node = Node.find(new_node_id)
assert_equal 1, new_node.version
assert new_node.visible
assert_equal 4.56, new_node.lon
assert_equal 12.34, new_node.lat
assert_in_delta(4.56, new_node.lon)
assert_in_delta(12.34, new_node.lat)
assert_equal({ "test" => "new" }, new_node.tags)
changed_node = Node.find(d)
assert_equal 2, changed_node.version
assert changed_node.visible
assert_equal 12.34, changed_node.lon
assert_equal 4.56, changed_node.lat
assert_in_delta(12.34, changed_node.lon)
assert_in_delta(4.56, changed_node.lat)
assert_equal({ "test" => "ok" }, changed_node.tags)
# node is not deleted because our other ways are using it
@ -1074,15 +1073,15 @@ module Api
new_node = Node.find(new_node_id)
assert_equal 1, new_node.version
assert new_node.visible
assert_equal 4.56, new_node.lon
assert_equal 12.34, new_node.lat
assert_in_delta(4.56, new_node.lon)
assert_in_delta(12.34, new_node.lat)
assert_equal({ "test" => "new" }, new_node.tags)
changed_node = Node.find(b)
assert_equal 2, changed_node.version
assert changed_node.visible
assert_equal 12.34, changed_node.lon
assert_equal 4.56, changed_node.lat
assert_in_delta(12.34, changed_node.lon)
assert_in_delta(4.56, changed_node.lat)
assert_equal({ "test" => "ok" }, changed_node.tags)
deleted_node = Node.find(d)

View file

@ -60,7 +60,7 @@ module Api
zoom_to_test.each do |zoom|
get changes_path(:zoom => zoom)
assert_response :bad_request
assert_equal @response.body, "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours"
assert_equal("Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", @response.body)
end
end
@ -81,7 +81,7 @@ module Api
invalid.each do |hour|
get changes_path(:hours => hour)
assert_response :bad_request, "Problem with the hour: #{hour}"
assert_equal @response.body, "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", "Problem with the hour: #{hour}."
assert_equal("Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", @response.body, "Problem with the hour: #{hour}.")
end
end
@ -95,7 +95,7 @@ module Api
def test_changes_start_end_invalid
get changes_path(:start => "2010-04-03 10:55:00", :end => "2010-04-03 09:55:00")
assert_response :bad_request
assert_equal @response.body, "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours"
assert_equal("Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", @response.body)
end
def test_changes_start_end_valid

View file

@ -908,7 +908,7 @@ module Api
CHANGESET
post changeset_upload_path(changeset), :params => diff, :headers => auth_header
assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
assert_equal @response.body, "Unknown action ping, choices are create, modify, delete"
assert_equal("Unknown action ping, choices are create, modify, delete", @response.body)
end
##

View file

@ -181,7 +181,7 @@ module Api
.select { |a| a["version"] == node.version }
.select { |a| a["changeset"] == node.changeset_id }
.select { |a| a["timestamp"] == node.timestamp.xmlschema }
assert_equal result_nodes.count, 1
assert_equal(1, result_nodes.count)
result_node = result_nodes.first
assert_equal result_node["tags"], tag.k => tag.v

View file

@ -296,10 +296,8 @@ module Api
assert_not_nil checkrelation,
"uploaded relation not found in data base after upload"
# compare values
assert_equal checkrelation.members.length, 0,
"saved relation contains members but should not"
assert_equal checkrelation.tags.length, 1,
"saved relation does not contain exactly one tag"
assert_equal(0, checkrelation.members.length, "saved relation contains members but should not")
assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
assert_equal changeset.id, checkrelation.changeset.id,
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
@ -326,10 +324,8 @@ module Api
assert_not_nil checkrelation,
"uploaded relation not found in data base after upload"
# compare values
assert_equal checkrelation.members.length, 1,
"saved relation does not contain exactly one member"
assert_equal checkrelation.tags.length, 1,
"saved relation does not contain exactly one tag"
assert_equal(1, checkrelation.members.length, "saved relation does not contain exactly one member")
assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
assert_equal changeset.id, checkrelation.changeset.id,
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
@ -356,10 +352,8 @@ module Api
assert_not_nil checkrelation,
"uploaded relation not found in data base after upload"
# compare values
assert_equal checkrelation.members.length, 1,
"saved relation does not contain exactly one member"
assert_equal checkrelation.tags.length, 1,
"saved relation does not contain exactly one tag"
assert_equal(1, checkrelation.members.length, "saved relation does not contain exactly one member")
assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
assert_equal changeset.id, checkrelation.changeset.id,
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,
@ -387,10 +381,8 @@ module Api
assert_not_nil checkrelation,
"uploaded relation not found in data base after upload"
# compare values
assert_equal checkrelation.members.length, 2,
"saved relation does not have exactly two members"
assert_equal checkrelation.tags.length, 1,
"saved relation does not contain exactly one tag"
assert_equal(2, checkrelation.members.length, "saved relation does not have exactly two members")
assert_equal(1, checkrelation.tags.length, "saved relation does not contain exactly one tag")
assert_equal changeset.id, checkrelation.changeset.id,
"saved relation does not belong in the changeset it was assigned to"
assert_equal user.id, checkrelation.changeset.user_id,

View file

@ -307,7 +307,7 @@ module Api
updated = Trace.find(trace.id)
# Ensure there's only one tag in the database after updating
assert_equal Tracetag.count, 1
assert_equal(1, Tracetag.count)
# The new tag object might have a different id, so check the string representation
assert_equal trace.tagstring, updated.tagstring
end

View file

@ -180,8 +180,7 @@ module Api
assert_not_nil checkway,
"uploaded way not found in data base after upload"
# compare values
assert_equal checkway.nds.length, 2,
"saved way does not contain exactly one node"
assert_equal(2, checkway.nds.length, "saved way does not contain exactly one node")
assert_equal checkway.nds[0], node1.id,
"saved way does not contain the right node on pos 0"
assert_equal checkway.nds[1], node2.id,

View file

@ -275,8 +275,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest
assert_response :success
assert_template "edit"
assert_equal 1.0, assigns(:lat)
assert_equal 1.0, assigns(:lon)
assert_in_delta(1.0, assigns(:lat))
assert_in_delta(1.0, assigns(:lon))
assert_equal 18, assigns(:zoom)
end
@ -312,8 +312,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest
get edit_path(:way => way.id)
assert_response :success
assert_template "edit"
assert_equal 3.0, assigns(:lat)
assert_equal 3.0, assigns(:lon)
assert_in_delta(3.0, assigns(:lat))
assert_in_delta(3.0, assigns(:lon))
assert_equal 17, assigns(:zoom)
end
@ -349,8 +349,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest
get edit_path(:note => note.id)
assert_response :success
assert_template "edit"
assert_equal 1.0, assigns(:lat)
assert_equal 1.0, assigns(:lon)
assert_in_delta(1.0, assigns(:lat))
assert_in_delta(1.0, assigns(:lon))
assert_equal 17, assigns(:zoom)
end
@ -386,8 +386,8 @@ class SiteControllerTest < ActionDispatch::IntegrationTest
get edit_path(:gpx => gpx.id)
assert_response :success
assert_template "edit"
assert_equal 1.0, assigns(:lat)
assert_equal 1.0, assigns(:lon)
assert_in_delta(1.0, assigns(:lat))
assert_in_delta(1.0, assigns(:lon))
assert_equal 16, assigns(:zoom)
end