]> git.openstreetmap.org Git - rails.git/commitdiff
Prefer keyword arguments when method has optional boolean arguments
authorTom Hughes <tom@compton.nu>
Fri, 13 Nov 2020 10:14:10 +0000 (10:14 +0000)
committerTom Hughes <tom@compton.nu>
Fri, 13 Nov 2020 10:22:55 +0000 (10:22 +0000)
17 files changed:
.rubocop_todo.yml
app/controllers/api/changesets_controller.rb
app/controllers/api/nodes_controller.rb
app/controllers/api/relations_controller.rb
app/controllers/api/tracepoints_controller.rb
app/controllers/api/ways_controller.rb
app/models/changeset.rb
app/models/node.rb
app/models/relation.rb
app/models/trace.rb
app/models/tracepoint.rb
app/models/way.rb
lib/diff_reader.rb
test/models/changeset_test.rb
test/models/node_test.rb
test/models/relation_test.rb
test/models/way_test.rb

index 67ef880c53df49370c59b1298929f162ce58a027..4e0bad7f9650eff28c271ffcd6a51f7ee9b8a0f2 100644 (file)
@@ -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:
index a5a37b485868f8e986053cd723b17e0b671f5710..a236083db2813f09bab39b03bd7b7eb0ba629172 100644 (file)
@@ -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
index 9204d96c0250c1901e0c031de81b6df25c6b9971..62eb76505b6228f4c6530476024e7c8afbdae397 100644 (file)
@@ -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
index 28e4a026bc47a820a5eb40faa7aa1c221e6364f6..9bb3eb87c4ebf4e2f2c4404a30981957b859a70d 100644 (file)
@@ -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
index 5fbece05b7a1eb08638cb6b8c64acad0897113ad..f7b812f7c6be5d6d86d842e6dfaf50c8e96a7fd9 100644 (file)
@@ -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\""
index a0feabff3a82a504b9a31f5dfd397601e99d8e27..f88f3a1d011d7609c0c0eb8a3704ee2c31746fe1 100644 (file)
@@ -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
index 9db213e777c9574c488e3490123057d1c6c4601a..aa674ea7fc5391ec781119e20f07d5bcef478332 100644 (file)
@@ -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
index 52c4b6d67a0256abbe97a9e1efffbee173123cec..a5346e87f39b71f297b9b6b4948d01f271d2618e 100644 (file)
@@ -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?
index 2fe60e5f77049def901d3da23df912231aaf43e0..5ed838e107ea270671c7551d440ad0e014be6aae 100644 (file)
@@ -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?
index 3a0793972a4b78c0f9224c3eb15b2c7829e607bd..0860d2b31954e1a3d255594650b071443399f702 100644 (file)
@@ -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"]
index 6352824fd7f08c3c50f781c95c80837c10302aab..000f257b4eba0f683db3c0af4c974fe80aa9015d 100644 (file)
@@ -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
index ca6829df434cc699974896944d5586c1566ebc3a..0150a2ee398d5dc793c335906fa5d1e0371176c8 100644 (file)
@@ -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?
index 5d98ef874406adc14e1cacc0b1ce584641c33e9b..501a918d0b4f0d9f1037050699e5811aabe75222 100644 (file)
@@ -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
index bc8c84fb1f0a0a017d183c144e8dc80fc98a8a6e..3be9a52e636fc8ba9d58d64c5022226a673f480f 100644 (file)
@@ -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 = "<osm></osm>"
     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 = "<osm><changeset><tag /></changeset></osm>"
     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 = "<osm><changeset><tag k='key' /></changeset></osm>"
     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 = "<osm><changeset><tag k='dup' v='test' /><tag k='dup' v='value' /></changeset></osm>"
     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 = "<osm><changeset><tag k=\"comment\" v=\"Just adding some streetnames and a restaurant\"/></changeset></osm>"
     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
index b5435412ba44eac47c42113486a6d164042e188d..214ff595d9549ccfd56d8faf66faa5a58f85aea5 100644 (file)
@@ -168,11 +168,11 @@ class NodeTest < ActiveSupport::TestCase
     noid = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset}' version='#{version}' /></osm>"
     # 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 = "<osm><node id='1' lon='23.3' changeset='2' version='23' /></osm>"
     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 = "<osm><node id='1' lat='23.1' changeset='2' version='23' /></osm>"
     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 = "<osm><node id='123' lon='23.23' lat='23.1' version='23' /></osm>"
     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 = "<osm><node id='123' lat='23' lon='23' changeset='23' /></osm>"
     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 = "<osm><node id='123' lon='23.23' lat='23.1' lat='12' changeset='23' version='23' /></osm>"
     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 = "<osm><node id='#{id}' lat='12.3' lon='12.3' changeset='33' version='23' /></osm>"
       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 = "<osm></osm>"
     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 = "<osm><node id='23' lat='12.3' lon='23.4' changeset='12' version='23'><tag /></node></osm>"
     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 = "<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
-      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 = "<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
-      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
index 6b76d82a49fe623fe4516bd23e5ce9616d4ffa45..e3ad13dc71ee4975cce25cbfb9beb7c1fb64ac58 100644 (file)
@@ -4,10 +4,10 @@ class RelationTest < ActiveSupport::TestCase
   def test_from_xml_no_id
     noid = "<osm><relation version='12' changeset='23' /></osm>"
     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 = "<osm><relation id='123' version='12' /></osm>"
     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 = "<osm><relation id='123' changeset='23' /></osm>"
     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 = "<osm><relation id='#{id}' changeset='332' version='23' /></osm>"
       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 = "<osm><relation id='23' changeset='23' version='23'><tag /></relation></osm>"
     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 = "<osm><relation id='23' changeset='23' version='23'><tag k='key' /></relation></osm>"
     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 = "<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
-      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
index 3c44f2f26bd6ddb5975920b2e6948038defb5e4f..6b166ec7eee0b602c230ca07ccbc65d0eadefa24 100644 (file)
@@ -43,10 +43,10 @@ class WayTest < ActiveSupport::TestCase
   def test_from_xml_no_id
     noid = "<osm><way version='12' changeset='23' /></osm>"
     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 = "<osm><way id='123' version='23' /></osm>"
     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 = "<osm><way id='123' changeset='23' /></osm>"
     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 = "<osm><way id='#{id}' changeset='33' version='23' /></osm>"
       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 = "<osm><way id='23' changeset='23' version='23'><tag /></way></osm>"
     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 = "<osm><way id='23' changeset='23' version='23'><tag k='key' /></way></osm>"
     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 = "<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
-      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