Fix rubocop lint issues
This commit is contained in:
parent
ef7f3d800c
commit
baf10cd392
40 changed files with 105 additions and 150 deletions
|
@ -446,7 +446,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# Using similar method for the node controller test
|
||||
def test_putpoi_create_valid
|
||||
# This node has no tags
|
||||
nd = Node.new
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100) - 50 + rand
|
||||
lon = rand(100) - 50 + rand
|
||||
|
@ -485,7 +485,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
|
||||
####
|
||||
# This node has some tags
|
||||
tnd = Node.new
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100) - 50 + rand
|
||||
lon = rand(100) - 50 + rand
|
||||
|
@ -528,7 +528,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# try creating a POI with rubbish in the tags
|
||||
def test_putpoi_create_with_control_chars
|
||||
# This node has no tags
|
||||
nd = Node.new
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100) - 50 + rand
|
||||
lon = rand(100) - 50 + rand
|
||||
|
@ -563,7 +563,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# try creating a POI with rubbish in the tags
|
||||
def test_putpoi_create_with_invalid_utf8
|
||||
# This node has no tags
|
||||
nd = Node.new
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100) - 50 + rand
|
||||
lon = rand(100) - 50 + rand
|
||||
|
@ -649,21 +649,21 @@ class AmfControllerTest < ActionController::TestCase
|
|||
req.read(2) # version
|
||||
|
||||
# parse through any headers
|
||||
headers = AMF.getint(req) # Read number of headers
|
||||
headers.times do # Read each header
|
||||
name = AMF.getstring(req) # |
|
||||
req.getc # | skip boolean
|
||||
value = AMF.getvalue(req) # |
|
||||
headers = AMF.getint(req) # Read number of headers
|
||||
headers.times do # Read each header
|
||||
AMF.getstring(req) # |
|
||||
req.getc # | skip boolean
|
||||
AMF.getvalue(req) # |
|
||||
end
|
||||
|
||||
# parse through responses
|
||||
results = {}
|
||||
bodies = AMF.getint(req) # Read number of bodies
|
||||
bodies.times do # Read each body
|
||||
message = AMF.getstring(req) # | get message name
|
||||
index = AMF.getstring(req) # | get index in response sequence
|
||||
bytes = AMF.getlong(req) # | get total size in bytes
|
||||
args = AMF.getvalue(req) # | get response (probably an array)
|
||||
bodies = AMF.getint(req) # Read number of bodies
|
||||
bodies.times do # Read each body
|
||||
message = AMF.getstring(req) # | get message name
|
||||
AMF.getstring(req) # | get index in response sequence
|
||||
AMF.getlong(req) # | get total size in bytes
|
||||
args = AMF.getvalue(req) # | get response (probably an array)
|
||||
results[message] = args
|
||||
end
|
||||
@amf_result = results
|
||||
|
|
|
@ -521,7 +521,6 @@ EOF
|
|||
put :create
|
||||
end
|
||||
assert_response :success
|
||||
changeset_id = @response.body.to_i
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -778,6 +777,7 @@ EOF
|
|||
# check that objects are unmodified
|
||||
assert_nodes_are_equal(node, Node.find(1))
|
||||
assert_ways_are_equal(way, Way.find(1))
|
||||
assert_relations_are_equal(rel, Relation.find(1))
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -194,14 +194,12 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# in a way...
|
||||
content(nodes(:used_node_1).to_xml)
|
||||
delete :delete, :id => current_nodes(:used_node_1).id
|
||||
assert_require_public_data
|
||||
"shouldn't be able to delete a node used in a way (#{@response.body})"
|
||||
assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
|
||||
|
||||
# in a relation...
|
||||
content(nodes(:node_used_by_relationship).to_xml)
|
||||
delete :delete, :id => current_nodes(:node_used_by_relationship).id
|
||||
assert_require_public_data
|
||||
"shouldn't be able to delete a node used in a relation (#{@response.body})"
|
||||
assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
|
||||
|
||||
## now set auth for the public data user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
|
|
@ -35,7 +35,6 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
def test_version
|
||||
## First try this with a non-public user
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
changeset_id = changesets(:normal_user_first_change).id
|
||||
|
||||
# setup a simple XML node
|
||||
xml_doc = current_nodes(:visible_node).to_xml
|
||||
|
@ -85,7 +84,6 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
|
||||
## Now do it with the public user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
changeset_id = changesets(:public_user_first_change).id
|
||||
|
||||
# setup a simple XML node
|
||||
xml_doc = current_nodes(:node_with_versions).to_xml
|
||||
|
|
|
@ -681,7 +681,7 @@ OSM
|
|||
content doc
|
||||
put :update, :id => relation_id
|
||||
assert_response :success, "can't update relation: #{@response.body}"
|
||||
new_version = @response.body.to_i
|
||||
assert_equal 2, @response.body.to_i
|
||||
|
||||
# get it back again and check the ordering again
|
||||
get :read, :id => relation_id
|
||||
|
|
|
@ -124,11 +124,9 @@ class WayControllerTest < ActionController::TestCase
|
|||
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
||||
"<tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
# hope for failure
|
||||
assert_response :forbidden,
|
||||
"way upload did not return success status"
|
||||
# read id of created way and search for it
|
||||
wayid = @response.body
|
||||
"way upload did not return forbidden status"
|
||||
|
||||
## Now use a public user
|
||||
nid1 = current_nodes(:used_node_1).id
|
||||
|
|
|
@ -7,10 +7,6 @@ class ApplicationHelperTest < ActionView::TestCase
|
|||
I18n.locale = "en"
|
||||
end
|
||||
|
||||
def setup
|
||||
I18n.locale = "en"
|
||||
end
|
||||
|
||||
def test_linkify
|
||||
%w(http://example.com/test ftp://example.com/test https://example.com/test).each do |link|
|
||||
text = "Test #{link} is made into a link"
|
||||
|
|
|
@ -171,7 +171,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
|||
def test_user_create_openid_failure
|
||||
new_email = "newtester-openid2@osm.org"
|
||||
display_name = "new_tester-openid2"
|
||||
password = "testtest2"
|
||||
assert_difference('User.count', 0) do
|
||||
assert_difference('ActionMailer::Base.deliveries.size', 0) do
|
||||
post "/user/new",
|
||||
|
@ -190,7 +189,6 @@ class UserCreationTest < ActionDispatch::IntegrationTest
|
|||
def test_user_create_openid_redirect
|
||||
new_email = "redirect_tester_openid@osm.org"
|
||||
display_name = "redirect_tester_openid"
|
||||
password = ""
|
||||
# nothing special about this page, just need a protected page to redirect back to.
|
||||
referer = "/traces/mine"
|
||||
assert_difference('User.count') do
|
||||
|
|
|
@ -292,8 +292,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
|||
post '/login', 'openid_url' => "http://localhost:1123/john.doe?openid.success=true", :referer => "/history"
|
||||
assert_response :redirect
|
||||
|
||||
res = openid_request(@response.redirect_url)
|
||||
res2 = post '/login', res
|
||||
post '/login', openid_request(@response.redirect_url)
|
||||
|
||||
assert_response :redirect
|
||||
follow_redirect!
|
||||
|
@ -311,8 +310,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
|||
post '/login', 'openid_url' => "http://localhost:1123/john.doe", :referer => "/diary"
|
||||
assert_response :redirect
|
||||
|
||||
res = openid_request(@response.redirect_url)
|
||||
post '/login', res
|
||||
post '/login', openid_request(@response.redirect_url)
|
||||
|
||||
assert_response :redirect
|
||||
follow_redirect!
|
||||
|
@ -361,7 +359,7 @@ class UserLoginTest < ActionDispatch::IntegrationTest
|
|||
assert_response :redirect
|
||||
|
||||
res = openid_request(@response.redirect_url)
|
||||
res2 = post '/login', res
|
||||
post '/login', res
|
||||
|
||||
assert_response :redirect
|
||||
follow_redirect!
|
||||
|
|
|
@ -144,7 +144,6 @@ class BoundingBoxTest < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
def test_expand_max_lat_with_margin
|
||||
bbox = @bbox_expand
|
||||
@expand_max_lat_array.each_with_index do |array_string, index|
|
||||
check_expand(@bbox_expand_minus_two, array_string, 1, @expand_max_lat_margin_response[index])
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'test_helper'
|
|||
class I18nTest < ActiveSupport::TestCase
|
||||
I18n.available_locales.each do |locale|
|
||||
define_method("test_#{locale.to_s.underscore}".to_sym) do
|
||||
plural_keys = plural_keys(locale)
|
||||
# plural_keys = plural_keys(locale)
|
||||
|
||||
translation_keys.each do |key|
|
||||
variables = []
|
||||
|
@ -32,7 +32,7 @@ class I18nTest < ActiveSupport::TestCase
|
|||
|
||||
if value.is_a?(Hash)
|
||||
value.each do |subkey, subvalue|
|
||||
# assert plural_keys.include?(subkey), "#{key}.#{subkey} is not a valid plural key"
|
||||
# assert plural_keys.include?(subkey), "#{key}.#{subkey} is not a valid plural key"
|
||||
|
||||
unless subvalue.nil?
|
||||
subvalue.scan(/%\{(\w+)\}/) do
|
||||
|
|
|
@ -40,7 +40,7 @@ class ChangesetTest < ActiveSupport::TestCase
|
|||
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||
Changeset.from_xml(nokv, false)
|
||||
end
|
||||
assert_match /tag is missing key/, message_create.message
|
||||
assert_match /tag is missing key/, message_update.message
|
||||
end
|
||||
|
||||
def test_from_xml_no_v
|
||||
|
|
|
@ -25,7 +25,7 @@ class MessageTest < ActiveSupport::TestCase
|
|||
def test_validating_msgs
|
||||
message = messages(:unread_message)
|
||||
assert message.valid?
|
||||
massage = messages(:read_message)
|
||||
message = messages(:read_message)
|
||||
assert message.valid?
|
||||
end
|
||||
|
||||
|
@ -79,8 +79,6 @@ class MessageTest < ActiveSupport::TestCase
|
|||
rescue ArgumentError => ex
|
||||
assert_equal ex.to_s, "invalid byte sequence in UTF-8"
|
||||
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
# because we only test invalid sequences it is OK to barf on them
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ class NoteTest < ActiveSupport::TestCase
|
|||
assert_not_nil note.closed_at
|
||||
end
|
||||
|
||||
def test_close
|
||||
def test_reopen
|
||||
note = notes(:closed_note_with_comment)
|
||||
assert_equal "closed", note.status
|
||||
assert_not_nil note.closed_at
|
||||
|
|
|
@ -71,6 +71,20 @@ class ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
# for some reason assert_equal a, b fails when the relations are
|
||||
# actually equal, so this method manually checks the fields...
|
||||
def assert_relations_are_equal(a, b)
|
||||
assert_not_nil a, "first relation is not allowed to be nil"
|
||||
assert_not_nil b, "second relation #{a.id} is not allowed to be nil"
|
||||
assert_equal a.id, b.id, "relation IDs"
|
||||
assert_equal a.changeset_id, b.changeset_id, "changeset ID on relation #{a.id}"
|
||||
assert_equal a.visible, b.visible, "visible on relation #{a.id}, #{a.visible.inspect} != #{b.visible.inspect}"
|
||||
assert_equal a.version, b.version, "version on relation #{a.id}"
|
||||
assert_equal a.tags, b.tags, "tags on relation #{a.id}"
|
||||
assert_equal a.members, b.members, "member references on relation #{a.id}"
|
||||
end
|
||||
|
||||
##
|
||||
# for some reason assert_equal a, b fails when the ways are actually
|
||||
# equal, so this method manually checks the fields...
|
||||
|
@ -130,20 +144,21 @@ class ActiveSupport::TestCase
|
|||
|
||||
# Set things up for OpenID testing
|
||||
def openid_setup
|
||||
rots_response = Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
||||
Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
||||
rescue
|
||||
# It isn't, so start a new instance.
|
||||
rots = IO.popen("#{Rails.root}/vendor/gems/rots-0.2.1/bin/rots --silent")
|
||||
|
||||
# Wait for up to 30 seconds for the server to start and respond before continuing
|
||||
for i in (1..30)
|
||||
1.upto(30).each do
|
||||
begin
|
||||
sleep 1
|
||||
rots_response = Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
||||
Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
|
||||
# If the rescue block doesn't fire, ROTS is up and running and we can continue
|
||||
break
|
||||
rescue
|
||||
rescue
|
||||
# If the connection failed, do nothing and repeat the loop
|
||||
next
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue