diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 67ef880c5..4e0bad7f9 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -173,16 +173,6 @@ Style/FrozenStringLiteralComment:
Style/NumericLiterals:
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
# Cop supports --auto-correct.
Style/StringConcatenation:
diff --git a/app/controllers/api/changesets_controller.rb b/app/controllers/api/changesets_controller.rb
index a5a37b485..a236083db 100644
--- a/app/controllers/api/changesets_controller.rb
+++ b/app/controllers/api/changesets_controller.rb
@@ -21,7 +21,7 @@ module Api
def create
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
cs.user = current_user
diff --git a/app/controllers/api/nodes_controller.rb b/app/controllers/api/nodes_controller.rb
index 9204d96c0..62eb76505 100644
--- a/app/controllers/api/nodes_controller.rb
+++ b/app/controllers/api/nodes_controller.rb
@@ -19,7 +19,7 @@ module Api
def create
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
node.create_with_history current_user
diff --git a/app/controllers/api/relations_controller.rb b/app/controllers/api/relations_controller.rb
index 28e4a026b..9bb3eb87c 100644
--- a/app/controllers/api/relations_controller.rb
+++ b/app/controllers/api/relations_controller.rb
@@ -16,7 +16,7 @@ module Api
def create
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
relation.create_with_history current_user
diff --git a/app/controllers/api/tracepoints_controller.rb b/app/controllers/api/tracepoints_controller.rb
index 5fbece05b..f7b812f7c 100644
--- a/app/controllers/api/tracepoints_controller.rb
+++ b/app/controllers/api/tracepoints_controller.rb
@@ -98,7 +98,7 @@ module Api
end
end
- trkseg << point.to_xml_node(timestamps)
+ trkseg << point.to_xml_node(:print_timestamp => timestamps)
end
response.headers["Content-Disposition"] = "attachment; filename=\"tracks.gpx\""
diff --git a/app/controllers/api/ways_controller.rb b/app/controllers/api/ways_controller.rb
index a0feabff3..f88f3a1d0 100644
--- a/app/controllers/api/ways_controller.rb
+++ b/app/controllers/api/ways_controller.rb
@@ -16,7 +16,7 @@ module Api
def create
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
way.create_with_history current_user
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 9db213e77..aa674ea7f 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -80,13 +80,13 @@ class Changeset < ApplicationRecord
self.closed_at = Time.now.getutc if is_open?
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)
doc = p.parse
pt = doc.find_first("//osm/changeset")
if pt
- Changeset.from_xml_node(pt, create)
+ Changeset.from_xml_node(pt, :create => create)
else
raise OSM::APIBadXMLError.new("changeset", xml, "XML doesn't contain an osm/changeset element.")
end
@@ -94,7 +94,7 @@ class Changeset < ApplicationRecord
raise OSM::APIBadXMLError.new("changeset", xml, e.message)
end
- def self.from_xml_node(pt, create = false)
+ def self.from_xml_node(pt, create: false)
cs = Changeset.new
if create
cs.created_at = Time.now.getutc
diff --git a/app/models/node.rb b/app/models/node.rb
index 52c4b6d67..a5346e87f 100644
--- a/app/models/node.rb
+++ b/app/models/node.rb
@@ -71,13 +71,13 @@ class Node < ApplicationRecord
end
# 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)
doc = p.parse
pt = doc.find_first("//osm/node")
if pt
- Node.from_xml_node(pt, create)
+ Node.from_xml_node(pt, :create => create)
else
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/node element.")
end
@@ -85,7 +85,7 @@ class Node < ApplicationRecord
raise OSM::APIBadXMLError.new("node", xml, e.message)
end
- def self.from_xml_node(pt, create = false)
+ def self.from_xml_node(pt, create: false)
node = Node.new
raise OSM::APIBadXMLError.new("node", pt, "lat missing") if pt["lat"].nil?
diff --git a/app/models/relation.rb b/app/models/relation.rb
index 2fe60e5f7..5ed838e10 100644
--- a/app/models/relation.rb
+++ b/app/models/relation.rb
@@ -54,13 +54,13 @@ class Relation < ApplicationRecord
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)
doc = p.parse
pt = doc.find_first("//osm/relation")
if pt
- Relation.from_xml_node(pt, create)
+ Relation.from_xml_node(pt, :create => create)
else
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/relation element.")
end
@@ -68,7 +68,7 @@ class Relation < ApplicationRecord
raise OSM::APIBadXMLError.new("relation", xml, e.message)
end
- def self.from_xml_node(pt, create = false)
+ def self.from_xml_node(pt, create: false)
relation = Relation.new
raise OSM::APIBadXMLError.new("relation", pt, "Version is required when updating") unless create || !pt["version"].nil?
diff --git a/app/models/trace.rb b/app/models/trace.rb
index 3a0793972..0860d2b31 100644
--- a/app/models/trace.rb
+++ b/app/models/trace.rb
@@ -162,13 +162,13 @@ class Trace < ApplicationRecord
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)
doc = p.parse
pt = doc.find_first("//osm/gpx_file")
if pt
- update_from_xml_node(pt, create)
+ update_from_xml_node(pt, :create => create)
else
raise OSM::APIBadXMLError.new("trace", xml, "XML doesn't contain an osm/gpx_file element.")
end
@@ -176,7 +176,7 @@ class Trace < ApplicationRecord
raise OSM::APIBadXMLError.new("trace", xml, e.message)
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?
self.visibility = pt["visibility"]
diff --git a/app/models/tracepoint.rb b/app/models/tracepoint.rb
index 6352824fd..000f257b4 100644
--- a/app/models/tracepoint.rb
+++ b/app/models/tracepoint.rb
@@ -32,7 +32,7 @@ class Tracepoint < ApplicationRecord
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["lat"] = lat.to_s
el1["lon"] = lon.to_s
diff --git a/app/models/way.rb b/app/models/way.rb
index ca6829df4..0150a2ee3 100644
--- a/app/models/way.rb
+++ b/app/models/way.rb
@@ -52,13 +52,13 @@ class Way < ApplicationRecord
scope :invisible, -> { where(:visible => false) }
# 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)
doc = p.parse
pt = doc.find_first("//osm/way")
if pt
- Way.from_xml_node(pt, create)
+ Way.from_xml_node(pt, :create => create)
else
raise OSM::APIBadXMLError.new("node", xml, "XML doesn't contain an osm/way element.")
end
@@ -66,7 +66,7 @@ class Way < ApplicationRecord
raise OSM::APIBadXMLError.new("way", xml, e.message)
end
- def self.from_xml_node(pt, create = false)
+ def self.from_xml_node(pt, create: false)
way = Way.new
raise OSM::APIBadXMLError.new("way", pt, "Version is required when updating") unless create || !pt["version"].nil?
diff --git a/lib/diff_reader.rb b/lib/diff_reader.rb
index 5d98ef874..501a918d0 100644
--- a/lib/diff_reader.rb
+++ b/lib/diff_reader.rb
@@ -138,7 +138,7 @@ class DiffReader
# create a new element. this code is agnostic of the element type
# because all the elements support the methods that we're using.
with_model do |model, xml|
- new = model.from_xml_node(xml, true)
+ new = model.from_xml_node(xml, :create => true)
check(model, xml, new)
# 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_model do |model, xml|
# 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)
# if the ID is a placeholder then map it to the real ID
diff --git a/test/models/changeset_test.rb b/test/models/changeset_test.rb
index bc8c84fb1..3be9a52e6 100644
--- a/test/models/changeset_test.rb
+++ b/test/models/changeset_test.rb
@@ -4,11 +4,11 @@ class ChangesetTest < ActiveSupport::TestCase
def test_from_xml_no_text
no_text = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(no_text, true)
+ Changeset.from_xml(no_text, :create => true)
end
assert_match(/Must specify a string with one or more characters/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(no_text, false)
+ Changeset.from_xml(no_text, :create => false)
end
assert_match(/Must specify a string with one or more characters/, message_update.message)
end
@@ -16,11 +16,11 @@ class ChangesetTest < ActiveSupport::TestCase
def test_from_xml_no_changeset
nocs = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(nocs, true)
+ Changeset.from_xml(nocs, :create => true)
end
assert_match %r{XML doesn't contain an osm/changeset element}, message_create.message
message_update = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(nocs, false)
+ Changeset.from_xml(nocs, :create => false)
end
assert_match %r{XML doesn't contain an osm/changeset element}, message_update.message
end
@@ -28,11 +28,11 @@ class ChangesetTest < ActiveSupport::TestCase
def test_from_xml_no_k_v
nokv = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(nokv, true)
+ Changeset.from_xml(nokv, :create => true)
end
assert_match(/tag is missing key/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(nokv, false)
+ Changeset.from_xml(nokv, :create => false)
end
assert_match(/tag is missing key/, message_update.message)
end
@@ -40,11 +40,11 @@ class ChangesetTest < ActiveSupport::TestCase
def test_from_xml_no_v
no_v = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(no_v, true)
+ Changeset.from_xml(no_v, :create => true)
end
assert_match(/tag is missing value/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Changeset.from_xml(no_v, false)
+ Changeset.from_xml(no_v, :create => false)
end
assert_match(/tag is missing value/, message_update.message)
end
@@ -52,11 +52,11 @@ class ChangesetTest < ActiveSupport::TestCase
def test_from_xml_duplicate_k
dupk = ""
message_create = assert_raise(OSM::APIDuplicateTagsError) do
- Changeset.from_xml(dupk, true)
+ Changeset.from_xml(dupk, :create => true)
end
assert_equal "Element changeset/ has duplicate tags with key dup", message_create.message
message_update = assert_raise(OSM::APIDuplicateTagsError) do
- Changeset.from_xml(dupk, false)
+ Changeset.from_xml(dupk, :create => false)
end
assert_equal "Element changeset/ has duplicate tags with key dup", message_update.message
end
@@ -65,10 +65,10 @@ class ChangesetTest < ActiveSupport::TestCase
# Example taken from the Update section on the API_v0.6 docs on the wiki
xml = ""
assert_nothing_raised do
- Changeset.from_xml(xml, false)
+ Changeset.from_xml(xml, :create => false)
end
assert_nothing_raised do
- Changeset.from_xml(xml, true)
+ Changeset.from_xml(xml, :create => true)
end
end
end
diff --git a/test/models/node_test.rb b/test/models/node_test.rb
index b5435412b..214ff595d 100644
--- a/test/models/node_test.rb
+++ b/test/models/node_test.rb
@@ -168,11 +168,11 @@ class NodeTest < ActiveSupport::TestCase
noid = ""
# First try a create which doesn't need the id
assert_nothing_raised do
- Node.from_xml(noid, true)
+ Node.from_xml(noid, :create => true)
end
# Now try an update with no id, and make sure that it gives the appropriate exception
message = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(noid, false)
+ Node.from_xml(noid, :create => false)
end
assert_match(/ID is required when updating./, message.message)
end
@@ -180,11 +180,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_lat
nolat = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nolat, true)
+ Node.from_xml(nolat, :create => true)
end
assert_match(/lat missing/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nolat, false)
+ Node.from_xml(nolat, :create => false)
end
assert_match(/lat missing/, message_update.message)
end
@@ -192,11 +192,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_lon
nolon = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nolon, true)
+ Node.from_xml(nolon, :create => true)
end
assert_match(/lon missing/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nolon, false)
+ Node.from_xml(nolon, :create => false)
end
assert_match(/lon missing/, message_update.message)
end
@@ -204,11 +204,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_changeset_id
nocs = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nocs, true)
+ Node.from_xml(nocs, :create => true)
end
assert_match(/Changeset id is missing/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nocs, false)
+ Node.from_xml(nocs, :create => false)
end
assert_match(/Changeset id is missing/, message_update.message)
end
@@ -216,10 +216,10 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_version
no_version = ""
assert_nothing_raised do
- Node.from_xml(no_version, true)
+ Node.from_xml(no_version, :create => true)
end
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_version, false)
+ Node.from_xml(no_version, :create => false)
end
assert_match(/Version is required when updating/, message_update.message)
end
@@ -227,11 +227,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_double_lat
nocs = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nocs, true)
+ Node.from_xml(nocs, :create => true)
end
assert_match(/Fatal error: Attribute lat redefined at/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nocs, false)
+ Node.from_xml(nocs, :create => false)
end
assert_match(/Fatal error: Attribute lat redefined at/, message_update.message)
end
@@ -241,10 +241,10 @@ class NodeTest < ActiveSupport::TestCase
id_list.each do |id|
zero_id = ""
assert_nothing_raised do
- Node.from_xml(zero_id, true)
+ Node.from_xml(zero_id, :create => true)
end
message_update = assert_raise(OSM::APIBadUserInput) do
- Node.from_xml(zero_id, false)
+ Node.from_xml(zero_id, :create => false)
end
assert_match(/ID of node cannot be zero when updating/, message_update.message)
end
@@ -253,11 +253,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_text
no_text = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_text, true)
+ Node.from_xml(no_text, :create => true)
end
assert_match(/Must specify a string with one or more characters/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_text, false)
+ Node.from_xml(no_text, :create => false)
end
assert_match(/Must specify a string with one or more characters/, message_update.message)
end
@@ -265,11 +265,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_node
no_node = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_node, true)
+ Node.from_xml(no_node, :create => true)
end
assert_match %r{XML doesn't contain an osm/node element}, message_create.message
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_node, false)
+ Node.from_xml(no_node, :create => false)
end
assert_match %r{XML doesn't contain an osm/node element}, message_update.message
end
@@ -277,11 +277,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_k_v
nokv = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nokv, true)
+ Node.from_xml(nokv, :create => true)
end
assert_match(/tag is missing key/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(nokv, false)
+ Node.from_xml(nokv, :create => false)
end
assert_match(/tag is missing key/, message_update.message)
end
@@ -289,11 +289,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_no_v
no_v = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_v, true)
+ Node.from_xml(no_v, :create => true)
end
assert_match(/tag is missing value/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Node.from_xml(no_v, false)
+ Node.from_xml(no_v, :create => false)
end
assert_match(/tag is missing value/, message_update.message)
end
@@ -301,11 +301,11 @@ class NodeTest < ActiveSupport::TestCase
def test_from_xml_duplicate_k
dupk = ""
message_create = assert_raise(OSM::APIDuplicateTagsError) do
- Node.from_xml(dupk, true)
+ Node.from_xml(dupk, :create => true)
end
assert_equal "Element node/ has duplicate tags with key dup", message_create.message
message_update = assert_raise(OSM::APIDuplicateTagsError) do
- Node.from_xml(dupk, false)
+ Node.from_xml(dupk, :create => false)
end
assert_equal "Element node/23 has duplicate tags with key dup", message_update.message
end
diff --git a/test/models/relation_test.rb b/test/models/relation_test.rb
index 6b76d82a4..e3ad13dc7 100644
--- a/test/models/relation_test.rb
+++ b/test/models/relation_test.rb
@@ -4,10 +4,10 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_no_id
noid = ""
assert_nothing_raised do
- Relation.from_xml(noid, true)
+ Relation.from_xml(noid, :create => true)
end
message = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(noid, false)
+ Relation.from_xml(noid, :create => false)
end
assert_match(/ID is required when updating/, message.message)
end
@@ -15,11 +15,11 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_no_changeset_id
nocs = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(nocs, true)
+ Relation.from_xml(nocs, :create => true)
end
assert_match(/Changeset id is missing/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(nocs, false)
+ Relation.from_xml(nocs, :create => false)
end
assert_match(/Changeset id is missing/, message_update.message)
end
@@ -27,10 +27,10 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_no_version
no_version = ""
assert_nothing_raised do
- Relation.from_xml(no_version, true)
+ Relation.from_xml(no_version, :create => true)
end
message_update = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(no_version, false)
+ Relation.from_xml(no_version, :create => false)
end
assert_match(/Version is required when updating/, message_update.message)
end
@@ -40,10 +40,10 @@ class RelationTest < ActiveSupport::TestCase
id_list.each do |id|
zero_id = ""
assert_nothing_raised do
- Relation.from_xml(zero_id, true)
+ Relation.from_xml(zero_id, :create => true)
end
message_update = assert_raise(OSM::APIBadUserInput) do
- Relation.from_xml(zero_id, false)
+ Relation.from_xml(zero_id, :create => false)
end
assert_match(/ID of relation cannot be zero when updating/, message_update.message)
end
@@ -52,11 +52,11 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_no_text
no_text = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(no_text, true)
+ Relation.from_xml(no_text, :create => true)
end
assert_match(/Must specify a string with one or more characters/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(no_text, false)
+ Relation.from_xml(no_text, :create => false)
end
assert_match(/Must specify a string with one or more characters/, message_update.message)
end
@@ -64,11 +64,11 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_no_k_v
nokv = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(nokv, true)
+ Relation.from_xml(nokv, :create => true)
end
assert_match(/tag is missing key/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(nokv, false)
+ Relation.from_xml(nokv, :create => false)
end
assert_match(/tag is missing key/, message_update.message)
end
@@ -76,11 +76,11 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_no_v
no_v = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(no_v, true)
+ Relation.from_xml(no_v, :create => true)
end
assert_match(/tag is missing value/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Relation.from_xml(no_v, false)
+ Relation.from_xml(no_v, :create => false)
end
assert_match(/tag is missing value/, message_update.message)
end
@@ -88,11 +88,11 @@ class RelationTest < ActiveSupport::TestCase
def test_from_xml_duplicate_k
dupk = ""
message_create = assert_raise(OSM::APIDuplicateTagsError) do
- Relation.from_xml(dupk, true)
+ Relation.from_xml(dupk, :create => true)
end
assert_equal "Element relation/ has duplicate tags with key dup", message_create.message
message_update = assert_raise(OSM::APIDuplicateTagsError) do
- Relation.from_xml(dupk, false)
+ Relation.from_xml(dupk, :create => false)
end
assert_equal "Element relation/23 has duplicate tags with key dup", message_update.message
end
diff --git a/test/models/way_test.rb b/test/models/way_test.rb
index 3c44f2f26..6b166ec7e 100644
--- a/test/models/way_test.rb
+++ b/test/models/way_test.rb
@@ -43,10 +43,10 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_no_id
noid = ""
assert_nothing_raised do
- Way.from_xml(noid, true)
+ Way.from_xml(noid, :create => true)
end
message = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(noid, false)
+ Way.from_xml(noid, :create => false)
end
assert_match(/ID is required when updating/, message.message)
end
@@ -54,11 +54,11 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_no_changeset_id
nocs = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(nocs, true)
+ Way.from_xml(nocs, :create => true)
end
assert_match(/Changeset id is missing/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(nocs, false)
+ Way.from_xml(nocs, :create => false)
end
assert_match(/Changeset id is missing/, message_update.message)
end
@@ -66,10 +66,10 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_no_version
no_version = ""
assert_nothing_raised do
- Way.from_xml(no_version, true)
+ Way.from_xml(no_version, :create => true)
end
message_update = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(no_version, false)
+ Way.from_xml(no_version, :create => false)
end
assert_match(/Version is required when updating/, message_update.message)
end
@@ -79,10 +79,10 @@ class WayTest < ActiveSupport::TestCase
id_list.each do |id|
zero_id = ""
assert_nothing_raised do
- Way.from_xml(zero_id, true)
+ Way.from_xml(zero_id, :create => true)
end
message_update = assert_raise(OSM::APIBadUserInput) do
- Way.from_xml(zero_id, false)
+ Way.from_xml(zero_id, :create => false)
end
assert_match(/ID of way cannot be zero when updating/, message_update.message)
end
@@ -91,11 +91,11 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_no_text
no_text = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(no_text, true)
+ Way.from_xml(no_text, :create => true)
end
assert_match(/Must specify a string with one or more characters/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(no_text, false)
+ Way.from_xml(no_text, :create => false)
end
assert_match(/Must specify a string with one or more characters/, message_update.message)
end
@@ -103,11 +103,11 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_no_k_v
nokv = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(nokv, true)
+ Way.from_xml(nokv, :create => true)
end
assert_match(/tag is missing key/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(nokv, false)
+ Way.from_xml(nokv, :create => false)
end
assert_match(/tag is missing key/, message_update.message)
end
@@ -115,11 +115,11 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_no_v
no_v = ""
message_create = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(no_v, true)
+ Way.from_xml(no_v, :create => true)
end
assert_match(/tag is missing value/, message_create.message)
message_update = assert_raise(OSM::APIBadXMLError) do
- Way.from_xml(no_v, false)
+ Way.from_xml(no_v, :create => false)
end
assert_match(/tag is missing value/, message_update.message)
end
@@ -127,11 +127,11 @@ class WayTest < ActiveSupport::TestCase
def test_from_xml_duplicate_k
dupk = ""
message_create = assert_raise(OSM::APIDuplicateTagsError) do
- Way.from_xml(dupk, true)
+ Way.from_xml(dupk, :create => true)
end
assert_equal "Element way/ has duplicate tags with key dup", message_create.message
message_update = assert_raise(OSM::APIDuplicateTagsError) do
- Way.from_xml(dupk, false)
+ Way.from_xml(dupk, :create => false)
end
assert_equal "Element way/23 has duplicate tags with key dup", message_update.message
end