Prefer keyword arguments when method has optional boolean arguments
This commit is contained in:
parent
63221710a4
commit
582402ba8f
17 changed files with 91 additions and 101 deletions
|
@ -173,16 +173,6 @@ Style/FrozenStringLiteralComment:
|
||||||
Style/NumericLiterals:
|
Style/NumericLiterals:
|
||||||
MinDigits: 11
|
MinDigits: 11
|
||||||
|
|
||||||
# Offense count: 20
|
|
||||||
Style/OptionalBooleanParameter:
|
|
||||||
Exclude:
|
|
||||||
- 'app/models/changeset.rb'
|
|
||||||
- 'app/models/node.rb'
|
|
||||||
- 'app/models/relation.rb'
|
|
||||||
- 'app/models/trace.rb'
|
|
||||||
- 'app/models/tracepoint.rb'
|
|
||||||
- 'app/models/way.rb'
|
|
||||||
|
|
||||||
# Offense count: 28
|
# Offense count: 28
|
||||||
# Cop supports --auto-correct.
|
# Cop supports --auto-correct.
|
||||||
Style/StringConcatenation:
|
Style/StringConcatenation:
|
||||||
|
|
|
@ -21,7 +21,7 @@ module Api
|
||||||
def create
|
def create
|
||||||
assert_method :put
|
assert_method :put
|
||||||
|
|
||||||
cs = Changeset.from_xml(request.raw_post, true)
|
cs = Changeset.from_xml(request.raw_post, :create => true)
|
||||||
|
|
||||||
# Assume that Changeset.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Changeset.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
cs.user = current_user
|
cs.user = current_user
|
||||||
|
|
|
@ -19,7 +19,7 @@ module Api
|
||||||
def create
|
def create
|
||||||
assert_method :put
|
assert_method :put
|
||||||
|
|
||||||
node = Node.from_xml(request.raw_post, true)
|
node = Node.from_xml(request.raw_post, :create => true)
|
||||||
|
|
||||||
# Assume that Node.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Node.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
node.create_with_history current_user
|
node.create_with_history current_user
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Api
|
||||||
def create
|
def create
|
||||||
assert_method :put
|
assert_method :put
|
||||||
|
|
||||||
relation = Relation.from_xml(request.raw_post, true)
|
relation = Relation.from_xml(request.raw_post, :create => true)
|
||||||
|
|
||||||
# Assume that Relation.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Relation.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
relation.create_with_history current_user
|
relation.create_with_history current_user
|
||||||
|
|
|
@ -98,7 +98,7 @@ module Api
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
trkseg << point.to_xml_node(timestamps)
|
trkseg << point.to_xml_node(:print_timestamp => timestamps)
|
||||||
end
|
end
|
||||||
|
|
||||||
response.headers["Content-Disposition"] = "attachment; filename=\"tracks.gpx\""
|
response.headers["Content-Disposition"] = "attachment; filename=\"tracks.gpx\""
|
||||||
|
|
|
@ -16,7 +16,7 @@ module Api
|
||||||
def create
|
def create
|
||||||
assert_method :put
|
assert_method :put
|
||||||
|
|
||||||
way = Way.from_xml(request.raw_post, true)
|
way = Way.from_xml(request.raw_post, :create => true)
|
||||||
|
|
||||||
# Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
|
# Assume that Way.from_xml has thrown an exception if there is an error parsing the xml
|
||||||
way.create_with_history current_user
|
way.create_with_history current_user
|
||||||
|
|
|
@ -80,13 +80,13 @@ class Changeset < ApplicationRecord
|
||||||
self.closed_at = Time.now.getutc if is_open?
|
self.closed_at = Time.now.getutc if is_open?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_xml(xml, create = false)
|
def self.from_xml(xml, create: false)
|
||||||
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
||||||
doc = p.parse
|
doc = p.parse
|
||||||
pt = doc.find_first("//osm/changeset")
|
pt = doc.find_first("//osm/changeset")
|
||||||
|
|
||||||
if pt
|
if pt
|
||||||
Changeset.from_xml_node(pt, create)
|
Changeset.from_xml_node(pt, :create => create)
|
||||||
else
|
else
|
||||||
raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.")
|
raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.")
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ class Changeset < ApplicationRecord
|
||||||
raise OSM::APIBadXMLError.new("changeset", xml, e.message)
|
raise OSM::APIBadXMLError.new("changeset", xml, e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_xml_node(pt, create = false)
|
def self.from_xml_node(pt, create: false)
|
||||||
cs = Changeset.new
|
cs = Changeset.new
|
||||||
if create
|
if create
|
||||||
cs.created_at = Time.now.getutc
|
cs.created_at = Time.now.getutc
|
||||||
|
|
|
@ -71,13 +71,13 @@ class Node < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# Read in xml as text and return it's Node object representation
|
# Read in xml as text and return it's Node object representation
|
||||||
def self.from_xml(xml, create = false)
|
def self.from_xml(xml, create: false)
|
||||||
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
||||||
doc = p.parse
|
doc = p.parse
|
||||||
pt = doc.find_first("//osm/node")
|
pt = doc.find_first("//osm/node")
|
||||||
|
|
||||||
if pt
|
if pt
|
||||||
Node.from_xml_node(pt, create)
|
Node.from_xml_node(pt, :create => create)
|
||||||
else
|
else
|
||||||
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/node element.")
|
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/node element.")
|
||||||
end
|
end
|
||||||
|
@ -85,7 +85,7 @@ class Node < ApplicationRecord
|
||||||
raise OSM::APIBadXMLError.new("node", xml, e.message)
|
raise OSM::APIBadXMLError.new("node", xml, e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_xml_node(pt, create = false)
|
def self.from_xml_node(pt, create: false)
|
||||||
node = Node.new
|
node = Node.new
|
||||||
|
|
||||||
raise OSM::APIBadXMLError.new("node", pt, "lat missing") if pt["lat"].nil?
|
raise OSM::APIBadXMLError.new("node", pt, "lat missing") if pt["lat"].nil?
|
||||||
|
|
|
@ -54,13 +54,13 @@ class Relation < ApplicationRecord
|
||||||
|
|
||||||
TYPES = %w[node way relation].freeze
|
TYPES = %w[node way relation].freeze
|
||||||
|
|
||||||
def self.from_xml(xml, create = false)
|
def self.from_xml(xml, create: false)
|
||||||
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
||||||
doc = p.parse
|
doc = p.parse
|
||||||
pt = doc.find_first("//osm/relation")
|
pt = doc.find_first("//osm/relation")
|
||||||
|
|
||||||
if pt
|
if pt
|
||||||
Relation.from_xml_node(pt, create)
|
Relation.from_xml_node(pt, :create => create)
|
||||||
else
|
else
|
||||||
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/relation element.")
|
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/relation element.")
|
||||||
end
|
end
|
||||||
|
@ -68,7 +68,7 @@ class Relation < ApplicationRecord
|
||||||
raise OSM::APIBadXMLError.new("relation", xml, e.message)
|
raise OSM::APIBadXMLError.new("relation", xml, e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_xml_node(pt, create = false)
|
def self.from_xml_node(pt, create: false)
|
||||||
relation = Relation.new
|
relation = Relation.new
|
||||||
|
|
||||||
raise OSM::APIBadXMLError.new("relation", pt, "Version is required when updating") unless create || !pt["version"].nil?
|
raise OSM::APIBadXMLError.new("relation", pt, "Version is required when updating") unless create || !pt["version"].nil?
|
||||||
|
|
|
@ -162,13 +162,13 @@ class Trace < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_from_xml(xml, create = false)
|
def update_from_xml(xml, create: false)
|
||||||
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
||||||
doc = p.parse
|
doc = p.parse
|
||||||
pt = doc.find_first("//osm/gpx_file")
|
pt = doc.find_first("//osm/gpx_file")
|
||||||
|
|
||||||
if pt
|
if pt
|
||||||
update_from_xml_node(pt, create)
|
update_from_xml_node(pt, :create => create)
|
||||||
else
|
else
|
||||||
raise OSM::APIBadXMLError.new("trace", xml, "XML doesn't contain an osm/gpx_file element.")
|
raise OSM::APIBadXMLError.new("trace", xml, "XML doesn't contain an osm/gpx_file element.")
|
||||||
end
|
end
|
||||||
|
@ -176,7 +176,7 @@ class Trace < ApplicationRecord
|
||||||
raise OSM::APIBadXMLError.new("trace", xml, e.message)
|
raise OSM::APIBadXMLError.new("trace", xml, e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_from_xml_node(pt, create = false)
|
def update_from_xml_node(pt, create: false)
|
||||||
raise OSM::APIBadXMLError.new("trace", pt, "visibility missing") if pt["visibility"].nil?
|
raise OSM::APIBadXMLError.new("trace", pt, "visibility missing") if pt["visibility"].nil?
|
||||||
|
|
||||||
self.visibility = pt["visibility"]
|
self.visibility = pt["visibility"]
|
||||||
|
|
|
@ -32,7 +32,7 @@ class Tracepoint < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :trace, :foreign_key => "gpx_id"
|
belongs_to :trace, :foreign_key => "gpx_id"
|
||||||
|
|
||||||
def to_xml_node(print_timestamp = false)
|
def to_xml_node(print_timestamp: false)
|
||||||
el1 = XML::Node.new "trkpt"
|
el1 = XML::Node.new "trkpt"
|
||||||
el1["lat"] = lat.to_s
|
el1["lat"] = lat.to_s
|
||||||
el1["lon"] = lon.to_s
|
el1["lon"] = lon.to_s
|
||||||
|
|
|
@ -52,13 +52,13 @@ class Way < ApplicationRecord
|
||||||
scope :invisible, -> { where(:visible => false) }
|
scope :invisible, -> { where(:visible => false) }
|
||||||
|
|
||||||
# Read in xml as text and return it's Way object representation
|
# Read in xml as text and return it's Way object representation
|
||||||
def self.from_xml(xml, create = false)
|
def self.from_xml(xml, create: false)
|
||||||
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
|
||||||
doc = p.parse
|
doc = p.parse
|
||||||
pt = doc.find_first("//osm/way")
|
pt = doc.find_first("//osm/way")
|
||||||
|
|
||||||
if pt
|
if pt
|
||||||
Way.from_xml_node(pt, create)
|
Way.from_xml_node(pt, :create => create)
|
||||||
else
|
else
|
||||||
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/way element.")
|
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/way element.")
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,7 @@ class Way < ApplicationRecord
|
||||||
raise OSM::APIBadXMLError.new("way", xml, e.message)
|
raise OSM::APIBadXMLError.new("way", xml, e.message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_xml_node(pt, create = false)
|
def self.from_xml_node(pt, create: false)
|
||||||
way = Way.new
|
way = Way.new
|
||||||
|
|
||||||
raise OSM::APIBadXMLError.new("way", pt, "Version is required when updating") unless create || !pt["version"].nil?
|
raise OSM::APIBadXMLError.new("way", pt, "Version is required when updating") unless create || !pt["version"].nil?
|
||||||
|
|
|
@ -138,7 +138,7 @@ class DiffReader
|
||||||
# create a new element. this code is agnostic of the element type
|
# create a new element. this code is agnostic of the element type
|
||||||
# because all the elements support the methods that we're using.
|
# because all the elements support the methods that we're using.
|
||||||
with_model do |model, xml|
|
with_model do |model, xml|
|
||||||
new = model.from_xml_node(xml, true)
|
new = model.from_xml_node(xml, :create => true)
|
||||||
check(model, xml, new)
|
check(model, xml, new)
|
||||||
|
|
||||||
# when this element is saved it will get a new ID, so we save it
|
# when this element is saved it will get a new ID, so we save it
|
||||||
|
@ -174,7 +174,7 @@ class DiffReader
|
||||||
# with types, but uses duck typing to handle them transparently.
|
# with types, but uses duck typing to handle them transparently.
|
||||||
with_model do |model, xml|
|
with_model do |model, xml|
|
||||||
# get the new element from the XML payload
|
# get the new element from the XML payload
|
||||||
new = model.from_xml_node(xml, false)
|
new = model.from_xml_node(xml, :create => false)
|
||||||
check(model, xml, new)
|
check(model, xml, new)
|
||||||
|
|
||||||
# if the ID is a placeholder then map it to the real ID
|
# if the ID is a placeholder then map it to the real ID
|
||||||
|
|
|
@ -4,11 +4,11 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_text
|
def test_from_xml_no_text
|
||||||
no_text = ""
|
no_text = ""
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(no_text, true)
|
Changeset.from_xml(no_text, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(no_text, false)
|
Changeset.from_xml(no_text, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -16,11 +16,11 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_changeset
|
def test_from_xml_no_changeset
|
||||||
nocs = "<osm></osm>"
|
nocs = "<osm></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(nocs, true)
|
Changeset.from_xml(nocs, :create => true)
|
||||||
end
|
end
|
||||||
assert_match %r{XML doesn't contain an osm/changeset element}, message_create.message
|
assert_match %r{XML doesn't contain an osm/changeset element}, message_create.message
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(nocs, false)
|
Changeset.from_xml(nocs, :create => false)
|
||||||
end
|
end
|
||||||
assert_match %r{XML doesn't contain an osm/changeset element}, message_update.message
|
assert_match %r{XML doesn't contain an osm/changeset element}, message_update.message
|
||||||
end
|
end
|
||||||
|
@ -28,11 +28,11 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_k_v
|
def test_from_xml_no_k_v
|
||||||
nokv = "<osm><changeset><tag /></changeset></osm>"
|
nokv = "<osm><changeset><tag /></changeset></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(nokv, true)
|
Changeset.from_xml(nokv, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_create.message)
|
assert_match(/tag is missing key/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(nokv, false)
|
Changeset.from_xml(nokv, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_update.message)
|
assert_match(/tag is missing key/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -40,11 +40,11 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_v
|
def test_from_xml_no_v
|
||||||
no_v = "<osm><changeset><tag k='key' /></changeset></osm>"
|
no_v = "<osm><changeset><tag k='key' /></changeset></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(no_v, true)
|
Changeset.from_xml(no_v, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_create.message)
|
assert_match(/tag is missing value/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Changeset.from_xml(no_v, false)
|
Changeset.from_xml(no_v, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_update.message)
|
assert_match(/tag is missing value/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -52,11 +52,11 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_duplicate_k
|
def test_from_xml_duplicate_k
|
||||||
dupk = "<osm><changeset><tag k='dup' v='test' /><tag k='dup' v='value' /></changeset></osm>"
|
dupk = "<osm><changeset><tag k='dup' v='test' /><tag k='dup' v='value' /></changeset></osm>"
|
||||||
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Changeset.from_xml(dupk, true)
|
Changeset.from_xml(dupk, :create => true)
|
||||||
end
|
end
|
||||||
assert_equal "Element changeset/ has duplicate tags with key dup", message_create.message
|
assert_equal "Element changeset/ has duplicate tags with key dup", message_create.message
|
||||||
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Changeset.from_xml(dupk, false)
|
Changeset.from_xml(dupk, :create => false)
|
||||||
end
|
end
|
||||||
assert_equal "Element changeset/ has duplicate tags with key dup", message_update.message
|
assert_equal "Element changeset/ has duplicate tags with key dup", message_update.message
|
||||||
end
|
end
|
||||||
|
@ -65,10 +65,10 @@ class ChangesetTest < ActiveSupport::TestCase
|
||||||
# Example taken from the Update section on the API_v0.6 docs on the wiki
|
# Example taken from the Update section on the API_v0.6 docs on the wiki
|
||||||
xml = "<osm><changeset><tag k=\"comment\" v=\"Just adding some streetnames and a restaurant\"/></changeset></osm>"
|
xml = "<osm><changeset><tag k=\"comment\" v=\"Just adding some streetnames and a restaurant\"/></changeset></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Changeset.from_xml(xml, false)
|
Changeset.from_xml(xml, :create => false)
|
||||||
end
|
end
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Changeset.from_xml(xml, true)
|
Changeset.from_xml(xml, :create => true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -168,11 +168,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
noid = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset}' version='#{version}' /></osm>"
|
noid = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset}' version='#{version}' /></osm>"
|
||||||
# First try a create which doesn't need the id
|
# First try a create which doesn't need the id
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Node.from_xml(noid, true)
|
Node.from_xml(noid, :create => true)
|
||||||
end
|
end
|
||||||
# Now try an update with no id, and make sure that it gives the appropriate exception
|
# Now try an update with no id, and make sure that it gives the appropriate exception
|
||||||
message = assert_raise(OSM::APIBadXMLError) do
|
message = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(noid, false)
|
Node.from_xml(noid, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/ID is required when updating./, message.message)
|
assert_match(/ID is required when updating./, message.message)
|
||||||
end
|
end
|
||||||
|
@ -180,11 +180,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_lat
|
def test_from_xml_no_lat
|
||||||
nolat = "<osm><node id='1' lon='23.3' changeset='2' version='23' /></osm>"
|
nolat = "<osm><node id='1' lon='23.3' changeset='2' version='23' /></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nolat, true)
|
Node.from_xml(nolat, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/lat missing/, message_create.message)
|
assert_match(/lat missing/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nolat, false)
|
Node.from_xml(nolat, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/lat missing/, message_update.message)
|
assert_match(/lat missing/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -192,11 +192,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_lon
|
def test_from_xml_no_lon
|
||||||
nolon = "<osm><node id='1' lat='23.1' changeset='2' version='23' /></osm>"
|
nolon = "<osm><node id='1' lat='23.1' changeset='2' version='23' /></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nolon, true)
|
Node.from_xml(nolon, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/lon missing/, message_create.message)
|
assert_match(/lon missing/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nolon, false)
|
Node.from_xml(nolon, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/lon missing/, message_update.message)
|
assert_match(/lon missing/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -204,11 +204,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_changeset_id
|
def test_from_xml_no_changeset_id
|
||||||
nocs = "<osm><node id='123' lon='23.23' lat='23.1' version='23' /></osm>"
|
nocs = "<osm><node id='123' lon='23.23' lat='23.1' version='23' /></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nocs, true)
|
Node.from_xml(nocs, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Changeset id is missing/, message_create.message)
|
assert_match(/Changeset id is missing/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nocs, false)
|
Node.from_xml(nocs, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Changeset id is missing/, message_update.message)
|
assert_match(/Changeset id is missing/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -216,10 +216,10 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_version
|
def test_from_xml_no_version
|
||||||
no_version = "<osm><node id='123' lat='23' lon='23' changeset='23' /></osm>"
|
no_version = "<osm><node id='123' lat='23' lon='23' changeset='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Node.from_xml(no_version, true)
|
Node.from_xml(no_version, :create => true)
|
||||||
end
|
end
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_version, false)
|
Node.from_xml(no_version, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Version is required when updating/, message_update.message)
|
assert_match(/Version is required when updating/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -227,11 +227,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_double_lat
|
def test_from_xml_double_lat
|
||||||
nocs = "<osm><node id='123' lon='23.23' lat='23.1' lat='12' changeset='23' version='23' /></osm>"
|
nocs = "<osm><node id='123' lon='23.23' lat='23.1' lat='12' changeset='23' version='23' /></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nocs, true)
|
Node.from_xml(nocs, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Fatal error: Attribute lat redefined at/, message_create.message)
|
assert_match(/Fatal error: Attribute lat redefined at/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nocs, false)
|
Node.from_xml(nocs, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Fatal error: Attribute lat redefined at/, message_update.message)
|
assert_match(/Fatal error: Attribute lat redefined at/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -241,10 +241,10 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
id_list.each do |id|
|
id_list.each do |id|
|
||||||
zero_id = "<osm><node id='#{id}' lat='12.3' lon='12.3' changeset='33' version='23' /></osm>"
|
zero_id = "<osm><node id='#{id}' lat='12.3' lon='12.3' changeset='33' version='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Node.from_xml(zero_id, true)
|
Node.from_xml(zero_id, :create => true)
|
||||||
end
|
end
|
||||||
message_update = assert_raise(OSM::APIBadUserInput) do
|
message_update = assert_raise(OSM::APIBadUserInput) do
|
||||||
Node.from_xml(zero_id, false)
|
Node.from_xml(zero_id, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/ID of node cannot be zero when updating/, message_update.message)
|
assert_match(/ID of node cannot be zero when updating/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -253,11 +253,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_text
|
def test_from_xml_no_text
|
||||||
no_text = ""
|
no_text = ""
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_text, true)
|
Node.from_xml(no_text, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_text, false)
|
Node.from_xml(no_text, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -265,11 +265,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_node
|
def test_from_xml_no_node
|
||||||
no_node = "<osm></osm>"
|
no_node = "<osm></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_node, true)
|
Node.from_xml(no_node, :create => true)
|
||||||
end
|
end
|
||||||
assert_match %r{XML doesn't contain an osm/node element}, message_create.message
|
assert_match %r{XML doesn't contain an osm/node element}, message_create.message
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_node, false)
|
Node.from_xml(no_node, :create => false)
|
||||||
end
|
end
|
||||||
assert_match %r{XML doesn't contain an osm/node element}, message_update.message
|
assert_match %r{XML doesn't contain an osm/node element}, message_update.message
|
||||||
end
|
end
|
||||||
|
@ -277,11 +277,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_k_v
|
def test_from_xml_no_k_v
|
||||||
nokv = "<osm><node id='23' lat='12.3' lon='23.4' changeset='12' version='23'><tag /></node></osm>"
|
nokv = "<osm><node id='23' lat='12.3' lon='23.4' changeset='12' version='23'><tag /></node></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nokv, true)
|
Node.from_xml(nokv, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_create.message)
|
assert_match(/tag is missing key/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(nokv, false)
|
Node.from_xml(nokv, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_update.message)
|
assert_match(/tag is missing key/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -289,11 +289,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_v
|
def test_from_xml_no_v
|
||||||
no_v = "<osm><node id='23' lat='23.43' lon='23.32' changeset='23' version='32'><tag k='key' /></node></osm>"
|
no_v = "<osm><node id='23' lat='23.43' lon='23.32' changeset='23' version='32'><tag k='key' /></node></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_v, true)
|
Node.from_xml(no_v, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_create.message)
|
assert_match(/tag is missing value/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Node.from_xml(no_v, false)
|
Node.from_xml(no_v, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_update.message)
|
assert_match(/tag is missing value/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -301,11 +301,11 @@ class NodeTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_duplicate_k
|
def test_from_xml_duplicate_k
|
||||||
dupk = "<osm><node id='23' lat='23.2' lon='23' changeset='34' version='23'><tag k='dup' v='test' /><tag k='dup' v='tester' /></node></osm>"
|
dupk = "<osm><node id='23' lat='23.2' lon='23' changeset='34' version='23'><tag k='dup' v='test' /><tag k='dup' v='tester' /></node></osm>"
|
||||||
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Node.from_xml(dupk, true)
|
Node.from_xml(dupk, :create => true)
|
||||||
end
|
end
|
||||||
assert_equal "Element node/ has duplicate tags with key dup", message_create.message
|
assert_equal "Element node/ has duplicate tags with key dup", message_create.message
|
||||||
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Node.from_xml(dupk, false)
|
Node.from_xml(dupk, :create => false)
|
||||||
end
|
end
|
||||||
assert_equal "Element node/23 has duplicate tags with key dup", message_update.message
|
assert_equal "Element node/23 has duplicate tags with key dup", message_update.message
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,10 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_id
|
def test_from_xml_no_id
|
||||||
noid = "<osm><relation version='12' changeset='23' /></osm>"
|
noid = "<osm><relation version='12' changeset='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Relation.from_xml(noid, true)
|
Relation.from_xml(noid, :create => true)
|
||||||
end
|
end
|
||||||
message = assert_raise(OSM::APIBadXMLError) do
|
message = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(noid, false)
|
Relation.from_xml(noid, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/ID is required when updating/, message.message)
|
assert_match(/ID is required when updating/, message.message)
|
||||||
end
|
end
|
||||||
|
@ -15,11 +15,11 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_changeset_id
|
def test_from_xml_no_changeset_id
|
||||||
nocs = "<osm><relation id='123' version='12' /></osm>"
|
nocs = "<osm><relation id='123' version='12' /></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(nocs, true)
|
Relation.from_xml(nocs, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Changeset id is missing/, message_create.message)
|
assert_match(/Changeset id is missing/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(nocs, false)
|
Relation.from_xml(nocs, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Changeset id is missing/, message_update.message)
|
assert_match(/Changeset id is missing/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -27,10 +27,10 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_version
|
def test_from_xml_no_version
|
||||||
no_version = "<osm><relation id='123' changeset='23' /></osm>"
|
no_version = "<osm><relation id='123' changeset='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Relation.from_xml(no_version, true)
|
Relation.from_xml(no_version, :create => true)
|
||||||
end
|
end
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(no_version, false)
|
Relation.from_xml(no_version, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Version is required when updating/, message_update.message)
|
assert_match(/Version is required when updating/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -40,10 +40,10 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
id_list.each do |id|
|
id_list.each do |id|
|
||||||
zero_id = "<osm><relation id='#{id}' changeset='332' version='23' /></osm>"
|
zero_id = "<osm><relation id='#{id}' changeset='332' version='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Relation.from_xml(zero_id, true)
|
Relation.from_xml(zero_id, :create => true)
|
||||||
end
|
end
|
||||||
message_update = assert_raise(OSM::APIBadUserInput) do
|
message_update = assert_raise(OSM::APIBadUserInput) do
|
||||||
Relation.from_xml(zero_id, false)
|
Relation.from_xml(zero_id, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/ID of relation cannot be zero when updating/, message_update.message)
|
assert_match(/ID of relation cannot be zero when updating/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -52,11 +52,11 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_text
|
def test_from_xml_no_text
|
||||||
no_text = ""
|
no_text = ""
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(no_text, true)
|
Relation.from_xml(no_text, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(no_text, false)
|
Relation.from_xml(no_text, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -64,11 +64,11 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_k_v
|
def test_from_xml_no_k_v
|
||||||
nokv = "<osm><relation id='23' changeset='23' version='23'><tag /></relation></osm>"
|
nokv = "<osm><relation id='23' changeset='23' version='23'><tag /></relation></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(nokv, true)
|
Relation.from_xml(nokv, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_create.message)
|
assert_match(/tag is missing key/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(nokv, false)
|
Relation.from_xml(nokv, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_update.message)
|
assert_match(/tag is missing key/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -76,11 +76,11 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_v
|
def test_from_xml_no_v
|
||||||
no_v = "<osm><relation id='23' changeset='23' version='23'><tag k='key' /></relation></osm>"
|
no_v = "<osm><relation id='23' changeset='23' version='23'><tag k='key' /></relation></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(no_v, true)
|
Relation.from_xml(no_v, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_create.message)
|
assert_match(/tag is missing value/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Relation.from_xml(no_v, false)
|
Relation.from_xml(no_v, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_update.message)
|
assert_match(/tag is missing value/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -88,11 +88,11 @@ class RelationTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_duplicate_k
|
def test_from_xml_duplicate_k
|
||||||
dupk = "<osm><relation id='23' changeset='23' version='23'><tag k='dup' v='test'/><tag k='dup' v='tester'/></relation></osm>"
|
dupk = "<osm><relation id='23' changeset='23' version='23'><tag k='dup' v='test'/><tag k='dup' v='tester'/></relation></osm>"
|
||||||
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Relation.from_xml(dupk, true)
|
Relation.from_xml(dupk, :create => true)
|
||||||
end
|
end
|
||||||
assert_equal "Element relation/ has duplicate tags with key dup", message_create.message
|
assert_equal "Element relation/ has duplicate tags with key dup", message_create.message
|
||||||
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Relation.from_xml(dupk, false)
|
Relation.from_xml(dupk, :create => false)
|
||||||
end
|
end
|
||||||
assert_equal "Element relation/23 has duplicate tags with key dup", message_update.message
|
assert_equal "Element relation/23 has duplicate tags with key dup", message_update.message
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,10 +43,10 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_id
|
def test_from_xml_no_id
|
||||||
noid = "<osm><way version='12' changeset='23' /></osm>"
|
noid = "<osm><way version='12' changeset='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Way.from_xml(noid, true)
|
Way.from_xml(noid, :create => true)
|
||||||
end
|
end
|
||||||
message = assert_raise(OSM::APIBadXMLError) do
|
message = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(noid, false)
|
Way.from_xml(noid, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/ID is required when updating/, message.message)
|
assert_match(/ID is required when updating/, message.message)
|
||||||
end
|
end
|
||||||
|
@ -54,11 +54,11 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_changeset_id
|
def test_from_xml_no_changeset_id
|
||||||
nocs = "<osm><way id='123' version='23' /></osm>"
|
nocs = "<osm><way id='123' version='23' /></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(nocs, true)
|
Way.from_xml(nocs, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Changeset id is missing/, message_create.message)
|
assert_match(/Changeset id is missing/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(nocs, false)
|
Way.from_xml(nocs, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Changeset id is missing/, message_update.message)
|
assert_match(/Changeset id is missing/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -66,10 +66,10 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_version
|
def test_from_xml_no_version
|
||||||
no_version = "<osm><way id='123' changeset='23' /></osm>"
|
no_version = "<osm><way id='123' changeset='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Way.from_xml(no_version, true)
|
Way.from_xml(no_version, :create => true)
|
||||||
end
|
end
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(no_version, false)
|
Way.from_xml(no_version, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Version is required when updating/, message_update.message)
|
assert_match(/Version is required when updating/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -79,10 +79,10 @@ class WayTest < ActiveSupport::TestCase
|
||||||
id_list.each do |id|
|
id_list.each do |id|
|
||||||
zero_id = "<osm><way id='#{id}' changeset='33' version='23' /></osm>"
|
zero_id = "<osm><way id='#{id}' changeset='33' version='23' /></osm>"
|
||||||
assert_nothing_raised do
|
assert_nothing_raised do
|
||||||
Way.from_xml(zero_id, true)
|
Way.from_xml(zero_id, :create => true)
|
||||||
end
|
end
|
||||||
message_update = assert_raise(OSM::APIBadUserInput) do
|
message_update = assert_raise(OSM::APIBadUserInput) do
|
||||||
Way.from_xml(zero_id, false)
|
Way.from_xml(zero_id, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/ID of way cannot be zero when updating/, message_update.message)
|
assert_match(/ID of way cannot be zero when updating/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -91,11 +91,11 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_text
|
def test_from_xml_no_text
|
||||||
no_text = ""
|
no_text = ""
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(no_text, true)
|
Way.from_xml(no_text, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
assert_match(/Must specify a string with one or more characters/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(no_text, false)
|
Way.from_xml(no_text, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
assert_match(/Must specify a string with one or more characters/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -103,11 +103,11 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_k_v
|
def test_from_xml_no_k_v
|
||||||
nokv = "<osm><way id='23' changeset='23' version='23'><tag /></way></osm>"
|
nokv = "<osm><way id='23' changeset='23' version='23'><tag /></way></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(nokv, true)
|
Way.from_xml(nokv, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_create.message)
|
assert_match(/tag is missing key/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(nokv, false)
|
Way.from_xml(nokv, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing key/, message_update.message)
|
assert_match(/tag is missing key/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -115,11 +115,11 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_no_v
|
def test_from_xml_no_v
|
||||||
no_v = "<osm><way id='23' changeset='23' version='23'><tag k='key' /></way></osm>"
|
no_v = "<osm><way id='23' changeset='23' version='23'><tag k='key' /></way></osm>"
|
||||||
message_create = assert_raise(OSM::APIBadXMLError) do
|
message_create = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(no_v, true)
|
Way.from_xml(no_v, :create => true)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_create.message)
|
assert_match(/tag is missing value/, message_create.message)
|
||||||
message_update = assert_raise(OSM::APIBadXMLError) do
|
message_update = assert_raise(OSM::APIBadXMLError) do
|
||||||
Way.from_xml(no_v, false)
|
Way.from_xml(no_v, :create => false)
|
||||||
end
|
end
|
||||||
assert_match(/tag is missing value/, message_update.message)
|
assert_match(/tag is missing value/, message_update.message)
|
||||||
end
|
end
|
||||||
|
@ -127,11 +127,11 @@ class WayTest < ActiveSupport::TestCase
|
||||||
def test_from_xml_duplicate_k
|
def test_from_xml_duplicate_k
|
||||||
dupk = "<osm><way id='23' changeset='23' version='23'><tag k='dup' v='test' /><tag k='dup' v='tester' /></way></osm>"
|
dupk = "<osm><way id='23' changeset='23' version='23'><tag k='dup' v='test' /><tag k='dup' v='tester' /></way></osm>"
|
||||||
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
message_create = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Way.from_xml(dupk, true)
|
Way.from_xml(dupk, :create => true)
|
||||||
end
|
end
|
||||||
assert_equal "Element way/ has duplicate tags with key dup", message_create.message
|
assert_equal "Element way/ has duplicate tags with key dup", message_create.message
|
||||||
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
message_update = assert_raise(OSM::APIDuplicateTagsError) do
|
||||||
Way.from_xml(dupk, false)
|
Way.from_xml(dupk, :create => false)
|
||||||
end
|
end
|
||||||
assert_equal "Element way/23 has duplicate tags with key dup", message_update.message
|
assert_equal "Element way/23 has duplicate tags with key dup", message_update.message
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue