second_relation = create(:relation_member, :member => node).relation
_super_relation = create(:relation_member, :member => second_relation).relation
# should combine multiple relation_member references into just one relation entry
- create(:relation_member, :member => node, :relation => relation_with_node, :sequence_id => 2)
+ create(:relation_member, :member => node, :relation => relation_with_node)
# should not include deleted relations
deleted_relation = create(:relation, :deleted)
create(:relation_member, :member => node, :relation => deleted_relation)
second_relation = create(:relation_member, :member => way).relation
_super_relation = create(:relation_member, :member => second_relation).relation
# should combine multiple relation_member references into just one relation entry
- create(:relation_member, :member => way, :relation => relation_with_way, :sequence_id => 2)
+ create(:relation_member, :member => way, :relation => relation_with_way)
# should not include deleted relations
deleted_relation = create(:relation, :deleted)
create(:relation_member, :member => way, :relation => deleted_relation)
second_relation = create(:relation_member, :member => relation).relation
_super_relation = create(:relation_member, :member => second_relation).relation
# should combine multiple relation_member references into just one relation entry
- create(:relation_member, :member => relation, :relation => relation_with_relation, :sequence_id => 2)
+ create(:relation_member, :member => relation, :relation => relation_with_relation)
# should not include deleted relations
deleted_relation = create(:relation, :deleted)
create(:relation_member, :member => relation, :relation => deleted_relation)
[relation_with_relation, second_relation])
end
- def check_relations_for_element(path, type, id, expected_relations)
- # check the "relations for relation" mode
- get path
- assert_response :success
-
- # count one osm element
- assert_select "osm[version='#{Settings.api_version}'][generator='OpenStreetMap server']", 1
-
- # we should have only the expected number of relations
- assert_select "osm>relation", expected_relations.size
-
- # and each of them should contain the element we originally searched for
- expected_relations.each do |relation|
- # The relation should appear once, but the element could appear multiple times
- assert_select "osm>relation[id='#{relation.id}']", 1
- assert_select "osm>relation[id='#{relation.id}']>member[type='#{type}'][ref='#{id}']"
- end
- end
-
def test_full
# check the "full" mode
get relation_full_path(:id => 999999)
# create an relation with a node as member, this time test that we don't
# need a role attribute to be included
xml = "<osm><relation changeset='#{private_changeset.id}'>" \
- "<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
+ "<member ref='#{node.id}' type='node'/><tag k='test' v='yes' /></relation></osm>"
put relation_create_path, :params => xml, :headers => auth_header
# hope for forbidden due to user
assert_response :forbidden,
# create an relation with a node as member, this time test that we don't
# need a role attribute to be included
xml = "<osm><relation changeset='#{changeset.id}'>" \
- "<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
+ "<member ref='#{node.id}' type='node'/><tag k='test' v='yes' /></relation></osm>"
put relation_create_path, :params => xml, :headers => auth_header
# hope for success
assert_response :success,
# valid delete should return the new version number, which should
# be greater than the old version number
- assert @response.body.to_i > multi_tag_relation.version,
- "delete request should return a new version number for relation"
+ assert_operator @response.body.to_i, :>, multi_tag_relation.version, "delete request should return a new version number for relation"
# this won't work since the relation is already deleted
xml = update_changeset(xml_for_relation(deleted_relation), changeset.id)
end
end
- # ============================================================
- # utility functions
- # ============================================================
+ private
+
+ def check_relations_for_element(path, type, id, expected_relations)
+ # check the "relations for relation" mode
+ get path
+ assert_response :success
+
+ # count one osm element
+ assert_select "osm[version='#{Settings.api_version}'][generator='#{Settings.generator}']", 1
+
+ # we should have only the expected number of relations
+ assert_select "osm>relation", expected_relations.size
+
+ # and each of them should contain the element we originally searched for
+ expected_relations.each do |relation|
+ # The relation should appear once, but the element could appear multiple times
+ assert_select "osm>relation[id='#{relation.id}']", 1
+ assert_select "osm>relation[id='#{relation.id}']>member[type='#{type}'][ref='#{id}']"
+ end
+ end
##
# checks that the XML document and the string arguments have
##
# updates the relation (XML) +rel+ and
# yields the new version of that relation into the block.
- # the parsed XML doc is retured.
+ # the parsed XML doc is returned.
def with_update(rel, headers)
rel_id = rel.find("//osm/relation").first["id"].to_i
put api_relation_path(:id => rel_id), :params => rel.to_s, :headers => headers
##
# updates the relation (XML) +rel+ via the diff-upload API and
# yields the new version of that relation into the block.
- # the parsed XML doc is retured.
+ # the parsed XML doc is returned.
def with_update_diff(rel, headers)
rel_id = rel.find("//osm/relation").first["id"].to_i
cs_id = rel.find("//osm/relation").first["changeset"].to_i
version = nil
with_controller(Api::ChangesetsController.new) do
- doc = OSM::API.new.get_xml_doc
+ doc = OSM::API.new.xml_doc
change = XML::Node.new "osmChange"
doc.root = change
modify = XML::Node.new "modify"