# simple diff to change a node, way and relation by removing
# their tags
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</relation>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset_id }, :body => diff
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</relation>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset_id }, :body => diff
# simple diff to change a node, way and relation by removing
# their tags
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</relation>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset_id }, :body => diff
basic_authorization user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
</relation>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
diff.root = XML::Node.new "osmChange"
delete = XML::Node.new "delete"
diff.root << delete
- delete << super_relation.to_xml_node
- delete << used_relation.to_xml_node
- delete << used_way.to_xml_node
- delete << used_node.to_xml_node
+ delete << xml_node_for_relation(super_relation)
+ delete << xml_node_for_relation(used_relation)
+ delete << xml_node_for_way(used_way)
+ delete << xml_node_for_node(used_node)
# update the changeset to one that this user owns
%w[node way relation].each do |type|
assert_select "diffResult>relation", 2
# check that everything was deleted
- assert_equal false, Node.find(used_node.id).visible
- assert_equal false, Way.find(used_way.id).visible
- assert_equal false, Relation.find(super_relation.id).visible
- assert_equal false, Relation.find(used_relation.id).visible
+ assert_not Node.find(used_node.id).visible
+ assert_not Way.find(used_way.id).visible
+ assert_not Relation.find(super_relation.id).visible
+ assert_not Relation.find(used_relation.id).visible
end
##
assert_select "diffResult>node", 1
# check that everything was deleted
- assert_equal false, Node.find(node.id).visible
+ assert_not Node.find(node.id).visible
end
def test_repeated_changeset_create
changeset_id = @response.body.to_i
# upload some widely-spaced nodes, spiralling positive and negative
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id='-1' lon='-20' lat='-10' changeset='#{changeset_id}'/>
<node id='-18' lon='179.9' lat='89.9' changeset='#{changeset_id}'/>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it, which used to cause an error like "PGError: ERROR:
# integer out of range" (bug #2152). but shouldn't any more.
diff.root = XML::Node.new "osmChange"
delete = XML::Node.new "delete"
diff.root << delete
- delete << other_relation.to_xml_node
- delete << used_way.to_xml_node
- delete << used_node.to_xml_node
+ delete << xml_node_for_relation(other_relation)
+ delete << xml_node_for_way(used_way)
+ delete << xml_node_for_node(used_node)
# update the changeset to one that this user owns
%w[node way relation].each do |type|
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
# check that nothing was, in fact, deleted
- assert_equal true, Node.find(used_node.id).visible
- assert_equal true, Way.find(used_way.id).visible
- assert_equal true, Relation.find(relation.id).visible
- assert_equal true, Relation.find(other_relation.id).visible
+ assert Node.find(used_node.id).visible
+ assert Way.find(used_way.id).visible
+ assert Relation.find(relation.id).visible
+ assert Relation.find(other_relation.id).visible
end
##
delete = XML::Node.new "delete"
diff.root << delete
delete["if-unused"] = ""
- delete << used_relation.to_xml_node
- delete << used_way.to_xml_node
- delete << used_node.to_xml_node
+ delete << xml_node_for_relation(used_relation)
+ delete << xml_node_for_way(used_way)
+ delete << xml_node_for_node(used_node)
# update the changeset to one that this user owns
%w[node way relation].each do |type|
assert_equal used_relation.version, doc.find("//diffResult/relation").first["new_version"].to_i
# check that nothing was, in fact, deleted
- assert_equal true, Node.find(used_node.id).visible
- assert_equal true, Way.find(used_way.id).visible
- assert_equal true, Relation.find(used_relation.id).visible
+ assert Node.find(used_node.id).visible
+ assert Way.find(used_way.id).visible
+ assert Relation.find(used_relation.id).visible
end
##
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
</node>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
</relation>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
# simple diff to create a node way and relation using placeholders
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
</node>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
# change the location of a node multiple times, each time referencing
# the last version. doesn't this depend on version numbers being
# sequential?
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
<node id='#{node.id}' lon='9' lat='9' changeset='#{changeset.id}' version='8'/>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
<node id='#{node.id}' lon='1' lat='1' changeset='#{changeset.id}' version='1'/>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='1' lon='1' lat='1' changeset='#{changeset.id}'/>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<ping>
<node id='1' lon='1' lat='1' changeset='#{changeset.id}' />
</ping>
</osmChange>
-CHANGESET
+ CHANGESET
post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request, "Shouldn't be able to upload a diff with the action ping"
assert_equal @response.body, "Unknown action ping, choices are create, modify, delete"
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify><node id='#{node.id}' lon='0' lat='0' changeset='#{changeset.id}'
version='1'></node>
<member type='relation' role='some' ref='#{other_relation.id}'/>
</relation>
</modify></osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}'>
<node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
</delete>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id='-1' lon='0' lat='0' changeset='#{changeset.id}' version='1'/>
<node id='-1' lon='2' lat='2' changeset='#{changeset.id}' version='2'/>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</way>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
# the same again, but this time use an existing way
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</way>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
basic_authorization changeset.user.email, "test"
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</relation>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
# the same again, but this time use an existing relation
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<create>
<node id="-1" lon="0" lat="0" changeset="#{changeset.id}" version="1"/>
</relation>
</create>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset.id }, :body => diff
diff = XML::Document.new
diff.root = XML::Node.new "osmChange"
modify = XML::Node.new "modify"
- xml_old_node = old_node.to_xml_node
+ xml_old_node = xml_node_for_node(old_node)
xml_old_node["lat"] = 2.0.to_s
xml_old_node["lon"] = 2.0.to_s
xml_old_node["changeset"] = changeset_id.to_s
diff = XML::Document.new
diff.root = XML::Node.new "osmChange"
modify = XML::Node.new "modify"
- xml_old_way = old_way.to_xml_node
+ xml_old_way = xml_node_for_way(old_way)
nd_ref = XML::Node.new "nd"
nd_ref["ref"] = create(:node, :lat => 3, :lon => 3).id.to_s
xml_old_way << nd_ref
diff.root = XML::Node.new "osmChange"
delete = XML::Node.new "delete"
diff.root << delete
- delete << node.to_xml_node
+ delete << xml_node_for_node(node)
# upload it
error_format "xml"
changeset_id = @response.body.to_i
# add a diff to it
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<modify>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
<node id='#{node.id}' lon='9' lat='9' changeset='#{changeset_id}' version='8'/>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success
changeset_id = @response.body.to_i
- diff = <<OSMFILE.strip_heredoc
+ diff = <<~OSMFILE
<osmChange version="0.6" generator="JOSM">
<create version="0.6" generator="JOSM">
<node id='-1' visible='true' changeset='#{changeset_id}' lat='51.49619982187321' lon='-0.18722061869438314' />
</way>
</create>
</osmChange>
-OSMFILE
+ OSMFILE
# upload it
post :upload, :params => { :id => changeset_id }, :body => diff
changeset_id = @response.body.to_i
# add a diff to it
- diff = <<CHANGESET.strip_heredoc
+ diff = <<~CHANGESET
<osmChange>
<delete>
<node id='#{node.id}' lon='0' lat='0' changeset='#{changeset_id}' version='1'/>
</way>
</modify>
</osmChange>
-CHANGESET
+ CHANGESET
# upload it
post :upload, :params => { :id => changeset_id }, :body => diff
# add (delete) a way to it, which contains a point at (3,3)
with_controller(WaysController.new) do
- xml = update_changeset(way.to_xml, changeset_id)
+ xml = update_changeset(xml_for_way(way), changeset_id)
put :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :success, "Couldn't delete a way."
end