user_en_de = create(:user, :languages => %w[en de])
user_de = create(:user, :languages => %w[de])
[user_en_de, user_de].each do |user|
- amf_content "getpresets", "/1", ["#{user.email}:test", ""]
- post :amf_read
+ post :amf_read, :body => amf_content("getpresets", "/1", ["#{user.email}:test", ""])
assert_response :success
amf_parse_response
presets = amf_result("/1")
node = way.nodes.first
user = way.changeset.user
- amf_content "getway", "/1", [way.id]
- post :amf_read
+ post :amf_read, :body => amf_content("getway", "/1", [way.id])
assert_response :success
amf_parse_response
result = amf_result("/1")
# check an invisible way
id = create(:way, :deleted).id
- amf_content "getway", "/1", [id]
- post :amf_read
+ post :amf_read, :body => amf_content("getway", "/1", [id])
assert_response :success
amf_parse_response
result = amf_result("/1")
node = way.nodes.first
user = way.changeset.user
- amf_content "getway", "/1", [way.id]
- post :amf_read
+ post :amf_read, :body => amf_content("getway", "/1", [way.id])
assert_response :success
amf_parse_response
result = amf_result("/1")
create(:way_node, :way => way, :node => node, :sequence_id => 2)
user = way.changeset.user
- amf_content "getway", "/1", [way.id]
- post :amf_read
+ post :amf_read, :body => amf_content("getway", "/1", [way.id])
assert_response :success
amf_parse_response
result = amf_result("/1")
c = way.nodes[2].id
user = way.changeset.user
- amf_content "getway", "/1", [way.id]
- post :amf_read
+ post :amf_read, :body => amf_content("getway", "/1", [way.id])
assert_response :success
amf_parse_response
result = amf_result("/1")
def test_getway_nonexistent
# check chat a non-existent way is not returned
- amf_content "getway", "/1", [0]
- post :amf_read
+ post :amf_read, :body => amf_content("getway", "/1", [0])
assert_response :success
amf_parse_response
way = amf_result("/1")
minlat = node.lat - 0.1
maxlon = node.lon + 0.1
maxlat = node.lat + 0.1
- amf_content "whichways", "/1", [minlon, minlat, maxlon, maxlat]
- post :amf_read
+ post :amf_read, :body => amf_content("whichways", "/1", [minlon, minlat, maxlon, maxlat])
assert_response :success
amf_parse_response
minlat = node.lat - 0.1
maxlon = node.lon + 0.1
maxlat = node.lat + 0.1
- amf_content "whichways_deleted", "/1", [minlon, minlat, maxlon, maxlat]
- post :amf_read
+ post :amf_read, :body => amf_content("whichways_deleted", "/1", [minlon, minlat, maxlon, maxlat])
assert_response :success
amf_parse_response
def test_whichways_deleted_toobig
bbox = [-0.1, -0.1, 1.1, 1.1]
- amf_content "whichways_deleted", "/1", bbox
- post :amf_read
+ post :amf_read, :body => amf_content("whichways_deleted", "/1", bbox)
assert_response :success
amf_parse_response
def test_getrelation
id = create(:relation).id
- amf_content "getrelation", "/1", [id]
- post :amf_read
+ post :amf_read, :body => amf_content("getrelation", "/1", [id])
assert_response :success
amf_parse_response
rel = amf_result("/1")
def test_getrelation_invisible
id = create(:relation, :deleted).id
- amf_content "getrelation", "/1", [id]
- post :amf_read
+ post :amf_read, :body => amf_content("getrelation", "/1", [id])
assert_response :success
amf_parse_response
rel = amf_result("/1")
def test_getrelation_nonexistent
id = 0
- amf_content "getrelation", "/1", [id]
- post :amf_read
+ post :amf_read, :body => amf_content("getrelation", "/1", [id])
assert_response :success
amf_parse_response
rel = amf_result("/1")
# try to get version 1
{ latest.id => "",
v1.way_id => (v1.timestamp + 1).strftime("%d %b %Y, %H:%M:%S") }.each do |id, t|
- amf_content "getway_old", "/1", [id, t]
- post :amf_read
+ post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
assert_response :success
amf_parse_response
returned_way = amf_result("/1")
way_id => "2009-03-25 00:00:00", # <- wrong format
way_id => "0 Jan 2009 00:00:00", # <- invalid date
-1 => "1 Jan 2009 00:00:00" }.each do |id, t| # <- invalid
- amf_content "getway_old", "/1", [id, t]
- post :amf_read
+ post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
assert_response :success
amf_parse_response
returned_way = amf_result("/1")
[[0, ""],
[0, "1 Jan 1970, 00:00:00"],
[v1.way_id, (v1.timestamp - 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
- amf_content "getway_old", "/1", [id, t]
- post :amf_read
+ post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
assert_response :success
amf_parse_response
returned_way = amf_result("/1")
v1 = way.old_ways.find_by(:version => 1)
# try to get deleted version
[[v1.way_id, (v1.timestamp + 10).strftime("%d %b %Y, %H:%M:%S")]].each do |id, t|
- amf_content "getway_old", "/1", [id, t]
- post :amf_read
+ post :amf_read, :body => amf_content("getway_old", "/1", [id, t])
assert_response :success
amf_parse_response
returned_way = amf_result("/1")
oldest = create(:old_way, :current_way => latest, :version => 1, :timestamp => latest.timestamp - 2.minutes)
create(:old_way, :current_way => latest, :version => 2, :timestamp => latest.timestamp)
- amf_content "getway_history", "/1", [latest.id]
- post :amf_read
+ post :amf_read, :body => amf_content("getway_history", "/1", [latest.id])
assert_response :success
amf_parse_response
history = amf_result("/1")
end
def test_getway_history_nonexistent
- amf_content "getway_history", "/1", [0]
- post :amf_read
+ post :amf_read, :body => amf_content("getway_history", "/1", [0])
assert_response :success
amf_parse_response
history = amf_result("/1")
_node_v2 = create(:old_node, :current_node => node, :version => 2, :timestamp => 2.days.ago)
node_v3 = create(:old_node, :current_node => node, :version => 3, :timestamp => 1.day.ago)
- amf_content "getnode_history", "/1", [node.id]
- post :amf_read
+ post :amf_read, :body => amf_content("getnode_history", "/1", [node.id])
assert_response :success
amf_parse_response
history = amf_result("/1")
end
def test_getnode_history_nonexistent
- amf_content "getnode_history", "/1", [0]
- post :amf_read
+ post :amf_read, :body => amf_content("getnode_history", "/1", [0])
assert_response :success
amf_parse_response
history = amf_result("/1")
end
def test_findgpx_bad_user
- amf_content "findgpx", "/1", [1, "test@example.com:wrong"]
- post :amf_read
+ post :amf_read, :body => amf_content("findgpx", "/1", [1, "test@example.com:wrong"])
assert_response :success
amf_parse_response
result = amf_result("/1")
blocked_user = create(:user)
create(:user_block, :user => blocked_user)
- amf_content "findgpx", "/1", [1, "#{blocked_user.email}:test"]
- post :amf_read
+ post :amf_read, :body => amf_content("findgpx", "/1", [1, "#{blocked_user.email}:test"])
assert_response :success
amf_parse_response
result = amf_result("/1")
user = create(:user)
trace = create(:trace, :visibility => "private", :user => user)
- amf_content "findgpx", "/1", [trace.id, "#{user.email}:test"]
- post :amf_read
+ post :amf_read, :body => amf_content("findgpx", "/1", [trace.id, "#{user.email}:test"])
assert_response :success
amf_parse_response
result = amf_result("/1")
def test_findgpx_by_name
user = create(:user)
- amf_content "findgpx", "/1", ["Trace", "#{user.email}:test"]
- post :amf_read
+ post :amf_read, :body => amf_content("findgpx", "/1", ["Trace", "#{user.email}:test"])
assert_response :success
amf_parse_response
result = amf_result("/1")
def test_findrelations_by_id
relation = create(:relation, :version => 4)
- amf_content "findrelations", "/1", [relation.id]
- post :amf_read
+ post :amf_read, :body => amf_content("findrelations", "/1", [relation.id])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal relation.members, result[0][2]
assert_equal relation.version, result[0][3]
- amf_content "findrelations", "/1", [999999]
- post :amf_read
+ post :amf_read, :body => amf_content("findrelations", "/1", [999999])
assert_response :success
amf_parse_response
result = amf_result("/1")
create(:relation_tag, :relation => used_relation, :k => "test", :v => "yes")
create(:relation_tag, :relation => used_relation, :k => "name", :v => "Test Relation")
- amf_content "findrelations", "/1", ["yes"]
- post :amf_read
+ post :amf_read, :body => amf_content("findrelations", "/1", ["yes"])
assert_response :success
amf_parse_response
result = amf_result("/1").sort
assert_equal used_relation.members, result[1][2]
assert_equal used_relation.version, result[1][3]
- amf_content "findrelations", "/1", ["no"]
- post :amf_read
+ post :amf_read, :body => amf_content("findrelations", "/1", ["no"])
assert_response :success
amf_parse_response
result = amf_result("/1").sort
node = create(:node, :with_history, :version => 4)
create(:node_tag, :node => node)
- amf_content "getpoi", "/1", [node.id, ""]
- post :amf_read
+ post :amf_read, :body => amf_content("getpoi", "/1", [node.id, ""])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal node.tags, result[5]
assert_equal node.version, result[6]
- amf_content "getpoi", "/1", [999999, ""]
- post :amf_read
+ post :amf_read, :body => amf_content("getpoi", "/1", [999999, ""])
assert_response :success
amf_parse_response
result = amf_result("/1")
# previous whole second, causing <= comparison to fail
timestamp = (node.timestamp + 1.second).xmlschema
- amf_content "getpoi", "/1", [node.node_id, timestamp]
- post :amf_read
+ post :amf_read, :body => amf_content("getpoi", "/1", [node.node_id, timestamp])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal node.tags, result[5]
assert_equal current_node.version, result[6]
- amf_content "getpoi", "/1", [node.node_id, "2000-01-01T00:00:00Z"]
- post :amf_read
+ post :amf_read, :body => amf_content("getpoi", "/1", [node.node_id, "2000-01-01T00:00:00Z"])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal "node", result[1]
assert_equal node.node_id, result[2]
- amf_content "getpoi", "/1", [999999, Time.now.xmlschema]
- post :amf_read
+ post :amf_read, :body => amf_content("getpoi", "/1", [999999, Time.now.xmlschema])
assert_response :success
amf_parse_response
result = amf_result("/1")
nd = create(:node)
cs_id = nd.changeset.id
user = nd.changeset.user
- amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible])
assert_response :success
amf_parse_response
result = amf_result("/1")
# Now try to update again, with a different lat/lon, using the updated version number
lat = nd.lat + 0.1
lon = nd.lon - 0.1
- amf_content "putpoi", "/2", ["#{user.email}:test", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/2", ["#{user.email}:test", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible])
assert_response :success
amf_parse_response
result = amf_result("/2")
changeset = create(:changeset)
user = changeset.user
- amf_content "putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, {}, nil]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, {}, nil])
assert_response :success
amf_parse_response
result = amf_result("/1")
lat = rand(-50..49) + rand
lon = rand(-50..49) + rand
- amf_content "putpoi", "/2", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, { "key" => "value", "ping" => "pong" }, nil]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/2", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, { "key" => "value", "ping" => "pong" }, nil])
assert_response :success
amf_parse_response
result = amf_result("/2")
mostly_invalid = (0..31).to_a.map(&:chr).join
tags = { "something" => "foo#{mostly_invalid}bar" }
- amf_content "putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil])
assert_response :success
amf_parse_response
result = amf_result("/1")
invalid = "\xc0\xc0"
tags = { "something" => "foo#{invalid}bar" }
- amf_content "putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", changeset.id, nil, nil, lon, lat, tags, nil])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = nd.changeset.id
user = nd.changeset.user
- amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = nd.changeset.id
user = nd.changeset.user
- amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, false])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = changeset.id
user = changeset.user
- amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, 1, 999999, 0, 0, {}, false]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, 1, 999999, 0, 0, {}, false])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = nd.changeset.id
user = nd.changeset.user
- amf_content "putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, 200, 100, nd.tags, true]
- post :amf_write
+ post :amf_write, :body => amf_content("putpoi", "/1", ["#{user.email}:test", cs_id, nd.version, nd.id, 200, 100, nd.tags, true])
assert_response :success
amf_parse_response
result = amf_result("/1")
d = create(:node).id
e = create(:node).id
- amf_content "putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [a, b, c], { "test" => "new" }, [], {}]
- post :amf_write
+ post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [a, b, c], { "test" => "new" }, [], {}])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal [a, b, c], new_way.nds
assert_equal({ "test" => "new" }, new_way.tags)
- amf_content "putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, d, e, a], { "test" => "newer" }, [], {}]
- post :amf_write
+ post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, d, e, a], { "test" => "newer" }, [], {}])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal [b, d, e, a], new_way.nds
assert_equal({ "test" => "newer" }, new_way.tags)
- amf_content "putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, -1, d, e], { "test" => "newest" }, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, d, 1, { "test" => "ok" }]], { a => 1 }]
- post :amf_write
+ post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, 0, -1, [b, -1, d, e], { "test" => "newest" }, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, d, 1, { "test" => "ok" }]], { a => 1 }])
assert_response :success
amf_parse_response
result = amf_result("/1")
user = way.changeset.user
assert_not_equal({ "test" => "ok" }, way.tags)
- amf_content "putway", "/1", ["#{user.email}:test", cs_id, way.version, way.id, way.nds, { "test" => "ok" }, [], {}]
- post :amf_write
+ post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, way.version, way.id, way.nds, { "test" => "ok" }, [], {}])
assert_response :success
amf_parse_response
result = amf_result("/1")
d = create(:node).id
assert_not_equal [a, b, c, d], way.nds
- amf_content "putway", "/1", ["#{user.email}:test", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}]
- post :amf_write
+ post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, way.version + 1, way.id, [a, b, c, d], way.tags, [], {}])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal [a, b, c, d], new_way.nds
assert_equal way.tags, new_way.tags
- amf_content "putway", "/1", ["#{user.email}:test", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, b, 1, { "test" => "ok" }]], { d => 1 }]
- post :amf_write
+ post :amf_write, :body => amf_content("putway", "/1", ["#{user.email}:test", cs_id, way.version + 2, way.id, [a, -1, b, c], way.tags, [[4.56, 12.34, -1, 0, { "test" => "new" }], [12.34, 4.56, b, 1, { "test" => "ok" }]], { d => 1 }])
assert_response :success
amf_parse_response
result = amf_result("/1")
create(:way_node, :node => b)
c = way.nodes[2]
- amf_content "deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes]
- post :amf_write
+ post :amf_write, :body => amf_content("deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = way.changeset.id
user = way.changeset.user
- amf_content "deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes]
- post :amf_write
+ post :amf_write, :body => amf_content("deleteway", "/1", ["#{user.email}:test", cs_id, way.id, way.version, nodes])
assert_response :success
amf_parse_response
result = amf_result("/1")
way = create(:way_with_nodes, :nodes_count => 2)
relation = create(:relation)
- amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, 0, -1, { "test" => "new" }, [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], true]
- post :amf_write
+ post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, 0, -1, { "test" => "new" }, [["Node", node.id, "node"], ["Way", way.id, "way"], ["Relation", relation.id, "relation"]], true])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = relation.changeset.id
assert_not_equal({ "test" => "ok" }, relation.tags)
- amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, { "test" => "ok" }, relation.members, true]
- post :amf_write
+ post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, { "test" => "ok" }, relation.members, true])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = relation.changeset.id
user = relation.changeset.user
- amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false]
- post :amf_write
+ post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false])
assert_response :success
amf_parse_response
result = amf_result("/1")
cs_id = relation.changeset.id
user = relation.changeset.user
- amf_content "putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false]
- post :amf_write
+ post :amf_write, :body => amf_content("putrelation", "/1", ["#{user.email}:test", cs_id, relation.version, relation.id, relation.tags, relation.members, false])
assert_response :success
amf_parse_response
result = amf_result("/1")
def test_startchangeset_valid
user = create(:user)
- amf_content "startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1]
- post :amf_write
+ post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1])
assert_response :success
amf_parse_response
result = amf_result("/1")
old_cs_id = new_cs_id
- amf_content "startchangeset", "/1", ["#{user.email}:test", { "source" => "newer" }, old_cs_id, "newer", 1]
- post :amf_write
+ post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", { "source" => "newer" }, old_cs_id, "newer", 1])
assert_response :success
amf_parse_response
result = amf_result("/1")
old_cs_id = new_cs_id
- amf_content "startchangeset", "/1", ["#{user.email}:test", {}, old_cs_id, "", 0]
- post :amf_write
+ post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", {}, old_cs_id, "", 0])
assert_response :success
amf_parse_response
result = amf_result("/1")
user = create(:user)
user2 = create(:user)
- amf_content "startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1]
- post :amf_write
+ post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", { "source" => "new" }, nil, "new", 1])
assert_response :success
amf_parse_response
result = amf_result("/1")
assert_equal true, cs.is_open?
assert_equal({ "comment" => "new", "source" => "new" }, cs.tags)
- amf_content "startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0]
- post :amf_write
+ post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user2.email}:test", {}, cs_id, "delete", 0])
assert_response :success
amf_parse_response
result = amf_result("/1")
invalid = "\035\022"
comment = "foo#{invalid}bar"
- amf_content "startchangeset", "/1", ["#{user.email}:test", {}, nil, comment, 1]
- post :amf_write
+ post :amf_write, :body => amf_content("startchangeset", "/1", ["#{user.email}:test", {}, nil, comment, 1])
assert_response :success
amf_parse_response
result = amf_result("/1")
c.write [-1].pack("N")
c.write AMF.encodevalue(data)
- @request.env["RAW_POST_DATA"] = c.string
+ c.string
end
# Parses the @response object as an AMF messsage.
# caller's block for assertion testing.
def check_bboxes_are_bad(bboxes)
bboxes.each do |bbox|
- amf_content "whichways", "/1", bbox
- post :amf_read
+ post :amf_read, :body => amf_content("whichways", "/1", bbox)
assert_response :success
amf_parse_response
def test_create
basic_authorization create(:user, :data_public => false).email, "test"
# Create the first user's changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_require_public_data
basic_authorization create(:user).email, "test"
# Create the first user's changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success, "Creation of changeset did not return sucess status"
newid = @response.body.to_i
def test_create_invalid
basic_authorization create(:user, :data_public => false).email, "test"
- content "<osm><changeset></osm>"
- put :create
+ xml = "<osm><changeset></osm>"
+ put :create, :body => xml
assert_require_public_data
## Try the public user
basic_authorization create(:user).email, "test"
- content "<osm><changeset></osm>"
- put :create
+ xml = "<osm><changeset></osm>"
+ put :create, :body => xml
assert_response :bad_request, "creating a invalid changeset should fail"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :unauthorized,
"shouldn't be able to upload a simple valid diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :forbidden,
"can't upload a simple valid diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload a simple valid diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a simple valid creation to changeset: #{@response.body}"
end
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :success,
"can't upload a deletion diff to changeset: #{@response.body}"
diff = "<osmChange><delete><node id='#{node.id}' version='#{node.version}' changeset='#{changeset.id}'/></delete></osmChange>"
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a deletion diff to changeset: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
assert_difference "Changeset.count", 1 do
- put :create
+ put :create, :body => xml
end
assert_response :success
end
basic_authorization create(:user).email, "test"
# create a changeset
- content "<osm><changeset/></osm>"
- put :create
+ put :create, :body => "<osm><changeset/></osm>"
assert_response :success, "Should be able to create a changeset: #{@response.body}"
changeset_id = @response.body.to_i
# upload it, which used to cause an error like "PGError: ERROR:
# integer out of range" (bug #2152). but shouldn't any more.
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload a spatially-large diff to changeset: #{@response.body}"
end
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :precondition_failed,
"shouldn't be able to upload a invalid deletion diff: #{@response.body}"
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
end
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :success,
"can't do a conditional delete of in use objects: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shoudln't be able to upload too long a tag to changeset: #{@response.body}"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a complex diff to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :conflict,
"uploading a diff with multiple changesets should have failed"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload multiple versions of an element in a diff: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :conflict,
"shouldn't be able to upload the same element twice in a diff: #{@response.body}"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to upload an element without version: #{@response.body}"
end
</ping>
</osmChange>
CHANGESET
- content diff
- post :upload, :params => { :id => changeset.id }
+ 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"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a valid diff with whitespace variations to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :success,
"can't upload a valid diff with re-used placeholders to changeset: #{@response.body}"
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to re-use placeholder IDs"
end
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder node not found for reference -4 in way -1", @response.body
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder node not found for reference -4 in way #{way.id}", @response.body
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder Node not found for reference -4 in relation -1.", @response.body
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response :bad_request,
"shouldn't be able to use invalid placeholder IDs"
assert_equal "Placeholder Way not found for reference -1 in relation #{relation.id}.", @response.body
def test_upload_node_move
basic_authorization create(:user).email, "test"
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
diff.root << modify
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff.to_s
assert_response :success,
"diff should have uploaded OK"
def test_upload_way_extend
basic_authorization create(:user).email, "test"
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
diff.root << modify
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff.to_s
assert_response :success,
"diff should have uploaded OK"
"<osmChange><modify/></osmChange>",
"<osmChange><modify></modify></osmChange>"].each do |diff|
# upload it
- content diff
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff
assert_response(:success, "should be able to upload " \
"empty changeset: " + diff)
end
delete << node.to_xml_node
# upload it
- content diff
error_format "xml"
- post :upload, :params => { :id => changeset.id }
+ post :upload, :params => { :id => changeset.id }, :body => diff.to_s
assert_response :success,
"failed to return error in XML format"
basic_authorization create(:user, :data_public => false).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :forbidden
## Now try with a normal user
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload multiple versions of an element in a diff: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
OSMFILE
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload a diff from JOSM: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a temporary changeset
- content "<osm><changeset>" \
- "<tag k='created_by' v='osm test suite checking changesets'/>" \
- "</changeset></osm>"
- put :create
+ xml = "<osm><changeset>" \
+ "<tag k='created_by' v='osm test suite checking changesets'/>" \
+ "</changeset></osm>"
+ put :create, :body => xml
assert_response :success
changeset_id = @response.body.to_i
CHANGESET
# upload it
- content diff
- post :upload, :params => { :id => changeset_id }
+ post :upload, :params => { :id => changeset_id }, :body => diff
assert_response :success,
"can't upload multiple versions of an element in a diff: #{@response.body}"
basic_authorization create(:user).email, "test"
# create a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "Creating of changeset failed."
changeset_id = @response.body.to_i
# add a single node to it
with_controller(NodesController.new) do
- content "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
- put :create
+ xml = "<osm><node lon='1' lat='2' changeset='#{changeset_id}'/></osm>"
+ put :create, :body => xml
assert_response :success, "Couldn't create node."
end
# add another node to it
with_controller(NodesController.new) do
- content "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
- put :create
+ xml = "<osm><node lon='2' lat='1' changeset='#{changeset_id}'/></osm>"
+ put :create, :body => xml
assert_response :success, "Couldn't create second node."
end
# add (delete) a way to it, which contains a point at (3,3)
with_controller(WaysController.new) do
- content update_changeset(way.to_xml, changeset_id)
- put :delete, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml, changeset_id)
+ put :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :success, "Couldn't delete a way."
end
basic_authorization create(:user).display_name, "test"
# create a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ put :create, :body => "<osm><changeset/></osm>"
assert_response :success, "Creating of changeset failed."
changeset_id = @response.body.to_i
basic_authorization create(:user).display_name, "test"
# create a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "Creating of changeset failed."
changeset_id = @response.body.to_i
lat = -0.45
# Try and put
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- put :expand_bbox, :params => { :id => changeset_id }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ put :expand_bbox, :params => { :id => changeset_id }, :body => xml
assert_response :method_not_allowed, "shouldn't be able to put a bbox expand"
# Try to get the update
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- get :expand_bbox, :params => { :id => changeset_id }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ get :expand_bbox, :params => { :id => changeset_id }, :body => xml
assert_response :method_not_allowed, "shouldn't be able to get a bbox expand"
# Try to use a hopefully missing changeset
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- post :expand_bbox, :params => { :id => changeset_id + 13245 }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ post :expand_bbox, :params => { :id => changeset_id + 13245 }, :body => xml
assert_response :not_found, "shouldn't be able to do a bbox expand on a nonexistant changeset"
end
new_tag["k"] = "tagtesting"
new_tag["v"] = "valuetesting"
new_changeset.find("//osm/changeset").first << new_tag
- content new_changeset
# try without any authorization
- put :update, :params => { :id => private_changeset.id }
+ put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
assert_response :unauthorized
# try with the wrong authorization
basic_authorization create(:user).email, "test"
- put :update, :params => { :id => private_changeset.id }
+ put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
assert_response :conflict
# now this should get an unauthorized
basic_authorization private_user.email, "test"
- put :update, :params => { :id => private_changeset.id }
+ put :update, :params => { :id => private_changeset.id }, :body => new_changeset.to_s
assert_require_public_data "user with their data non-public, shouldn't be able to edit their changeset"
## Now try with the public user
new_tag["k"] = "tagtesting"
new_tag["v"] = "valuetesting"
new_changeset.find("//osm/changeset").first << new_tag
- content new_changeset
# try without any authorization
@request.env["HTTP_AUTHORIZATION"] = nil
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :unauthorized
# try with the wrong authorization
basic_authorization create(:user).email, "test"
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :conflict
# now this should work...
basic_authorization user.email, "test"
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :success
assert_select "osm>changeset[id='#{changeset.id}']", 1
new_tag["v"] = "testing"
new_changeset.find("//osm/changeset").first << new_tag
- content new_changeset
- put :update, :params => { :id => changeset.id }
+ put :update, :params => { :id => changeset.id }, :body => new_changeset.to_s
assert_response :conflict
end
basic_authorization create(:user).email, "test"
# open a new changeset
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "can't create a new changeset"
cs_id = @response.body.to_i
with_controller(NodesController.new) do
# create a new node
- content "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
- put :create
+ xml = "<osm><node changeset='#{cs_id}' lat='0.0' lon='0.0'/></osm>"
+ put :create, :body => xml
assert_response :success, "can't create a new node"
node_id = @response.body.to_i
node_xml["lon"] = rand.to_s
node_xml["version"] = (i + 1).to_s
- content node_doc
- put :update, :params => { :id => node_id }
+ put :update, :params => { :id => node_id }, :body => node_doc.to_s
assert_response :success, "attempt #{i} should have succeeded"
end
node_xml["lon"] = rand.to_s
node_xml["version"] = offset.to_s
- content node_doc
- put :update, :params => { :id => node_id }
+ put :update, :params => { :id => node_id }, :body => node_doc.to_s
assert_response :conflict, "final attempt should have failed"
end
##
# call the include method and assert properties of the bbox
def check_after_include(changeset_id, lon, lat, bbox)
- content "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
- post :expand_bbox, :params => { :id => changeset_id }
+ xml = "<osm><node lon='#{lon}' lat='#{lat}'/></osm>"
+ post :expand_bbox, :params => { :id => changeset_id }, :body => xml
assert_response :success, "Setting include of changeset failed: #{@response.body}"
# check exactly one changeset
## First try with no auth
# create a minimal xml file
- content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
+ xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
assert_difference("OldNode.count", 0) do
- put :create
+ put :create, :body => xml
end
# hope for unauthorized
assert_response :unauthorized, "node upload did not return unauthorized status"
basic_authorization private_user.email, "test"
# create a minimal xml file
- content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>")
+ xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>"
assert_difference("Node.count", 0) do
- put :create
+ put :create, :body => xml
end
# hope for success
assert_require_public_data "node create did not return forbidden status"
basic_authorization user.email, "test"
# create a minimal xml file
- content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
- put :create
+ xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
+ put :create, :body => xml
# hope for success
assert_response :success, "node upload did not return success status"
lon = 3.23
# test that the upload is rejected when xml is valid, but osm doc isn't
- content("<create/>")
- put :create
+ xml = "<create/>"
+ put :create, :body => xml
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
# test that the upload is rejected when no lat is supplied
# create a minimal xml file
- content("<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>")
- put :create
+ xml = "<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>"
+ put :create, :body => xml
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
# test that the upload is rejected when no lon is supplied
# create a minimal xml file
- content("<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>")
- put :create
+ xml = "<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>"
+ put :create, :body => xml
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
# test that the upload is rejected when lat is non-numeric
# create a minimal xml file
- content("<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>")
- put :create
+ xml = "<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
+ put :create, :body => xml
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
# test that the upload is rejected when lon is non-numeric
# create a minimal xml file
- content("<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>")
- put :create
+ xml = "<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>"
+ put :create, :body => xml
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
# test that the upload is rejected when we have a tag which is too long
- content("<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>")
- put :create
+ xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
+ put :create, :body => xml
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal ["NodeTag ", " v: is too long (maximum is 255 characters) (\"#{'x' * 256}\")"], @response.body.split(/[0-9]+,foo:/)
end
basic_authorization private_user.email, "test"
# try to delete with an invalid (closed) changeset
- content update_changeset(private_node.to_xml, private_user_closed_changeset.id)
- delete :delete, :params => { :id => private_node.id }
+ xml = update_changeset(private_node.to_xml, private_user_closed_changeset.id)
+ delete :delete, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data("non-public user shouldn't be able to delete node")
# try to delete with an invalid (non-existent) changeset
- content update_changeset(private_node.to_xml, 0)
- delete :delete, :params => { :id => private_node.id }
+ xml = update_changeset(private_node.to_xml, 0)
+ delete :delete, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data("shouldn't be able to delete node, when user's data is private")
# valid delete now takes a payload
- content(private_node.to_xml)
- delete :delete, :params => { :id => private_node.id }
+ xml = private_node.to_xml
+ delete :delete, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data("shouldn't be able to delete node when user's data isn't public'")
# this won't work since the node is already deleted
- content(private_deleted_node.to_xml)
- delete :delete, :params => { :id => private_deleted_node.id }
+ xml = private_deleted_node.to_xml
+ delete :delete, :params => { :id => private_deleted_node.id }, :body => xml.to_s
assert_require_public_data
# this won't work since the node never existed
private_used_node = create(:node, :changeset => private_user_changeset)
create(:way_node, :node => private_used_node)
- content(private_used_node.to_xml)
- delete :delete, :params => { :id => private_used_node.id }
+ xml = private_used_node.to_xml
+ delete :delete, :params => { :id => private_used_node.id }, :body => xml.to_s
assert_require_public_data "shouldn't be able to delete a node used in a way (#{@response.body})"
# in a relation...
private_used_node2 = create(:node, :changeset => private_user_changeset)
create(:relation_member, :member => private_used_node2)
- content(private_used_node2.to_xml)
- delete :delete, :params => { :id => private_used_node2.id }
+ xml = private_used_node2.to_xml
+ delete :delete, :params => { :id => private_used_node2.id }, :body => xml.to_s
assert_require_public_data "shouldn't be able to delete a node used in a relation (#{@response.body})"
## now setup for the public data user
basic_authorization user.email, "test"
# try to delete with an invalid (closed) changeset
- content update_changeset(node.to_xml, closed_changeset.id)
- delete :delete, :params => { :id => node.id }
+ xml = update_changeset(node.to_xml, closed_changeset.id)
+ delete :delete, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict
# try to delete with an invalid (non-existent) changeset
- content update_changeset(node.to_xml, 0)
- delete :delete, :params => { :id => node.id }
+ xml = update_changeset(node.to_xml, 0)
+ delete :delete, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict
# try to delete a node with a different ID
other_node = create(:node)
- content(other_node.to_xml)
- delete :delete, :params => { :id => node.id }
+ xml = other_node.to_xml
+ delete :delete, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request,
"should not be able to delete a node with a different ID from the XML"
# try to delete a node rubbish in the payloads
- content("<delete/>")
- delete :delete, :params => { :id => node.id }
+ xml = "<delete/>"
+ delete :delete, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request,
"should not be able to delete a node without a valid XML payload"
# valid delete now takes a payload
- content(node.to_xml)
- delete :delete, :params => { :id => node.id }
+ xml = node.to_xml
+ delete :delete, :params => { :id => node.id }, :body => xml.to_s
assert_response :success
# valid delete should return the new version number, which should
"delete request should return a new version number for node"
# deleting the same node twice doesn't work
- content(node.to_xml)
- delete :delete, :params => { :id => node.id }
+ xml = node.to_xml
+ delete :delete, :params => { :id => node.id }, :body => xml.to_s
assert_response :gone
# this won't work since the node never existed
way_node = create(:way_node, :node => used_node)
way_node2 = create(:way_node, :node => used_node)
- content(used_node.to_xml)
- delete :delete, :params => { :id => used_node.id }
+ xml = used_node.to_xml
+ delete :delete, :params => { :id => used_node.id }, :body => xml.to_s
assert_response :precondition_failed,
"shouldn't be able to delete a node used in a way (#{@response.body})"
assert_equal "Precondition failed: Node #{used_node.id} is still used by ways #{way_node.way.id},#{way_node2.way.id}.", @response.body
relation_member = create(:relation_member, :member => used_node2)
relation_member2 = create(:relation_member, :member => used_node2)
- content(used_node2.to_xml)
- delete :delete, :params => { :id => used_node2.id }
+ xml = used_node2.to_xml
+ delete :delete, :params => { :id => used_node2.id }, :body => xml.to_s
assert_response :precondition_failed,
"shouldn't be able to delete a node used in a relation (#{@response.body})"
assert_equal "Precondition failed: Node #{used_node2.id} is still used by relations #{relation_member.relation.id},#{relation_member2.relation.id}.", @response.body
user = create(:user)
node = create(:node, :changeset => create(:changeset, :user => user))
- content node.to_xml
- put :update, :params => { :id => node.id }
+ xml = node.to_xml
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :unauthorized
## Second test with the private user
## trying to break changesets
# try and update in someone else's changeset
- content update_changeset(private_node.to_xml,
- create(:changeset).id)
- put :update, :params => { :id => private_node.id }
+ xml = update_changeset(private_node.to_xml,
+ create(:changeset).id)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "update with other user's changeset should be forbidden when data isn't public"
# try and update in a closed changeset
- content update_changeset(private_node.to_xml,
- create(:changeset, :closed, :user => private_user).id)
- put :update, :params => { :id => private_node.id }
+ xml = update_changeset(private_node.to_xml,
+ create(:changeset, :closed, :user => private_user).id)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
# try and update in a non-existant changeset
- content update_changeset(private_node.to_xml, 0)
- put :update, :params => { :id => private_node.id }
+ xml = update_changeset(private_node.to_xml, 0)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "update with changeset=0 should be forbidden, when data isn't public"
## try and submit invalid updates
- content xml_attr_rewrite(private_node.to_xml, "lat", 91.0)
- put :update, :params => { :id => private_node.id }
+ xml = xml_attr_rewrite(private_node.to_xml, "lat", 91.0)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "node at lat=91 should be forbidden, when data isn't public"
- content xml_attr_rewrite(private_node.to_xml, "lat", -91.0)
- put :update, :params => { :id => private_node.id }
+ xml = xml_attr_rewrite(private_node.to_xml, "lat", -91.0)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "node at lat=-91 should be forbidden, when data isn't public"
- content xml_attr_rewrite(private_node.to_xml, "lon", 181.0)
- put :update, :params => { :id => private_node.id }
+ xml = xml_attr_rewrite(private_node.to_xml, "lon", 181.0)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "node at lon=181 should be forbidden, when data isn't public"
- content xml_attr_rewrite(private_node.to_xml, "lon", -181.0)
- put :update, :params => { :id => private_node.id }
+ xml = xml_attr_rewrite(private_node.to_xml, "lon", -181.0)
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "node at lon=-181 should be forbidden, when data isn't public"
## finally, produce a good request which still won't work
- content private_node.to_xml
- put :update, :params => { :id => private_node.id }
+ xml = private_node.to_xml
+ put :update, :params => { :id => private_node.id }, :body => xml.to_s
assert_require_public_data "should have failed with a forbidden when data isn't public"
## Finally test with the public user
# try and update a node without authorisation
# first try to update node without auth
- content node.to_xml
- put :update, :params => { :id => node.id }
+ xml = node.to_xml
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :forbidden
# setup auth
## trying to break changesets
# try and update in someone else's changeset
- content update_changeset(node.to_xml,
- create(:changeset).id)
- put :update, :params => { :id => node.id }
+ xml = update_changeset(node.to_xml,
+ create(:changeset).id)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict, "update with other user's changeset should be rejected"
# try and update in a closed changeset
- content update_changeset(node.to_xml,
- create(:changeset, :closed, :user => user).id)
- put :update, :params => { :id => node.id }
+ xml = update_changeset(node.to_xml,
+ create(:changeset, :closed, :user => user).id)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict, "update with closed changeset should be rejected"
# try and update in a non-existant changeset
- content update_changeset(node.to_xml, 0)
- put :update, :params => { :id => node.id }
+ xml = update_changeset(node.to_xml, 0)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict, "update with changeset=0 should be rejected"
## try and submit invalid updates
- content xml_attr_rewrite(node.to_xml, "lat", 91.0)
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml, "lat", 91.0)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request, "node at lat=91 should be rejected"
- content xml_attr_rewrite(node.to_xml, "lat", -91.0)
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml, "lat", -91.0)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request, "node at lat=-91 should be rejected"
- content xml_attr_rewrite(node.to_xml, "lon", 181.0)
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml, "lon", 181.0)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request, "node at lon=181 should be rejected"
- content xml_attr_rewrite(node.to_xml, "lon", -181.0)
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml, "lon", -181.0)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request, "node at lon=-181 should be rejected"
## next, attack the versioning
current_node_version = node.version
# try and submit a version behind
- content xml_attr_rewrite(node.to_xml,
- "version", current_node_version - 1)
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml,
+ "version", current_node_version - 1)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict, "should have failed on old version number"
# try and submit a version ahead
- content xml_attr_rewrite(node.to_xml,
- "version", current_node_version + 1)
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml,
+ "version", current_node_version + 1)
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict, "should have failed on skipped version number"
# try and submit total crap in the version field
- content xml_attr_rewrite(node.to_xml,
- "version", "p1r4t3s!")
- put :update, :params => { :id => node.id }
+ xml = xml_attr_rewrite(node.to_xml,
+ "version", "p1r4t3s!")
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :conflict,
"should not be able to put 'p1r4at3s!' in the version field"
## try an update with the wrong ID
- content create(:node).to_xml
- put :update, :params => { :id => node.id }
+ xml = create(:node).to_xml
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request,
"should not be able to update a node with a different ID from the XML"
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
- content "<update/>"
- put :update, :params => { :id => node.id }
+ xml = "<update/>"
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :bad_request,
"should not be able to update a node with non-OSM XML doc."
## finally, produce a good request which should work
- content node.to_xml
- put :update, :params => { :id => node.id }
+ xml = node.to_xml
+ put :update, :params => { :id => node.id }, :body => xml.to_s
assert_response :success, "a valid update request failed"
end
node_xml.find("//osm/node").first << tag_xml
# try and upload it
- content node_xml
- put :update, :params => { :id => existing_tag.node.id }
+ put :update, :params => { :id => existing_tag.node.id }, :body => node_xml.to_s
assert_response :bad_request,
"adding duplicate tags to a node should fail with 'bad request'"
assert_equal "Element node/#{existing_tag.node.id} has duplicate tags with key #{existing_tag.k}", @response.body
# try and put something into a string that the API might
# use unquoted and therefore allow code injection...
- content "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
- '<tag k="#{@user.inspect}" v="0"/>' \
- "</node></osm>"
- put :create
+ xml = "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
+ '<tag k="#{@user.inspect}" v="0"/>' \
+ "</node></osm>"
+ put :create, :body => xml
assert_require_public_data "Shouldn't be able to create with non-public user"
## Then try with the public data user
# try and put something into a string that the API might
# use unquoted and therefore allow code injection...
- content "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
- '<tag k="#{@user.inspect}" v="0"/>' \
- "</node></osm>"
- put :create
+ xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
+ '<tag k="#{@user.inspect}" v="0"/>' \
+ "</node></osm>"
+ put :create, :body => xml
assert_response :success
nodeid = @response.body
xml_node["lat"] = precision(rand * 180 - 90).to_s
xml_node["lon"] = precision(rand * 360 - 180).to_s
with_controller(NodesController.new) do
- content xml_doc
- put :update, :params => { :id => nodeid }
+ put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
assert_response :forbidden, "Should have rejected node update"
xml_node["version"] = @response.body.to_s
end
xml_tag["v"] = random_string
xml_node << xml_tag
with_controller(NodesController.new) do
- content xml_doc
- put :update, :params => { :id => nodeid }
+ put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
assert_response :forbidden,
"should have rejected node #{nodeid} (#{@response.body}) with forbidden"
xml_node["version"] = @response.body.to_s
xml_node["lat"] = precision(rand * 180 - 90).to_s
xml_node["lon"] = precision(rand * 360 - 180).to_s
with_controller(NodesController.new) do
- content xml_doc
- put :update, :params => { :id => nodeid }
+ put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
assert_response :success
xml_node["version"] = @response.body.to_s
end
xml_tag["v"] = random_string
xml_node << xml_tag
with_controller(NodesController.new) do
- content xml_doc
- put :update, :params => { :id => nodeid }
+ put :update, :params => { :id => nodeid }, :body => xml_doc.to_s
assert_response :success,
"couldn't update node #{nodeid} (#{@response.body})"
xml_node["version"] = @response.body.to_s
basic_authorization private_user.email, "test"
# create an relation without members
- content "<osm><relation changeset='#{private_changeset.id}'><tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{private_changeset.id}'><tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for forbidden, due to user
assert_response :forbidden,
"relation upload should have failed with forbidden"
###
# create an relation with a node as member
# This time try with a role attribute in the relation
- content "<osm><relation changeset='#{private_changeset.id}'>" \
- "<member ref='#{node.id}' type='node' role='some'/>" \
- "<tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{private_changeset.id}'>" \
+ "<member ref='#{node.id}' type='node' role='some'/>" \
+ "<tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for forbidden due to user
assert_response :forbidden,
"relation upload did not return forbidden status"
###
# create an relation with a node as member, this time test that we don't
# need a role attribute to be included
- content "<osm><relation changeset='#{private_changeset.id}'>" \
- "<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{private_changeset.id}'>" \
+ "<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for forbidden due to user
assert_response :forbidden,
"relation upload did not return forbidden status"
###
# create an relation with a way and a node as members
- content "<osm><relation changeset='#{private_changeset.id}'>" \
- "<member type='node' ref='#{node.id}' role='some'/>" \
- "<member type='way' ref='#{way.id}' role='other'/>" \
- "<tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{private_changeset.id}'>" \
+ "<member type='node' ref='#{node.id}' role='some'/>" \
+ "<member type='way' ref='#{way.id}' role='other'/>" \
+ "<tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for forbidden, due to user
assert_response :forbidden,
"relation upload did not return success status"
basic_authorization user.email, "test"
# create an relation without members
- content "<osm><relation changeset='#{changeset.id}'><tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{changeset.id}'><tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for success
assert_response :success,
"relation upload did not return success status"
###
# create an relation with a node as member
# This time try with a role attribute in the relation
- content "<osm><relation changeset='#{changeset.id}'>" \
- "<member ref='#{node.id}' type='node' role='some'/>" \
- "<tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{changeset.id}'>" \
+ "<member ref='#{node.id}' type='node' role='some'/>" \
+ "<tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for success
assert_response :success,
"relation upload did not return success status"
###
# create an relation with a node as member, this time test that we don't
# need a role attribute to be included
- content "<osm><relation changeset='#{changeset.id}'>" \
- "<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{changeset.id}'>" \
+ "<member ref='#{node.id}' type='node'/>" + "<tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for success
assert_response :success,
"relation upload did not return success status"
###
# create an relation with a way and a node as members
- content "<osm><relation changeset='#{changeset.id}'>" \
- "<member type='node' ref='#{node.id}' role='some'/>" \
- "<member type='way' ref='#{way.id}' role='other'/>" \
- "<tag k='test' v='yes' /></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{changeset.id}'>" \
+ "<member type='node' ref='#{node.id}' role='some'/>" \
+ "<member type='way' ref='#{way.id}' role='other'/>" \
+ "<tag k='test' v='yes' /></relation></osm>"
+ put :create, :body => xml
# hope for success
assert_response :success,
"relation upload did not return success status"
basic_authorization user.email, "test"
with_relation(relation.id) do |rel|
update_changeset(rel, changeset.id)
- content rel
- put :update, :params => { :id => other_relation.id }
+ put :update, :params => { :id => other_relation.id }, :body => rel.to_s
assert_response :bad_request
end
end
basic_authorization user.email, "test"
# create a relation with non-existing node as member
- content "<osm><relation changeset='#{changeset.id}'>" \
- "<member type='node' ref='0'/><tag k='test' v='yes' />" \
- "</relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{changeset.id}'>" \
+ "<member type='node' ref='0'/><tag k='test' v='yes' />" \
+ "</relation></osm>"
+ put :create, :body => xml
# expect failure
assert_response :precondition_failed,
"relation upload with invalid node did not return 'precondition failed'"
basic_authorization user.email, "test"
# create some xml that should return an error
- content "<osm><relation changeset='#{changeset.id}'>" \
- "<member type='type' ref='#{node.id}' role=''/>" \
- "<tag k='tester' v='yep'/></relation></osm>"
- put :create
+ xml = "<osm><relation changeset='#{changeset.id}'>" \
+ "<member type='type' ref='#{node.id}' role=''/>" \
+ "<tag k='tester' v='yep'/></relation></osm>"
+ put :create, :body => xml
# expect failure
assert_response :bad_request
assert_match(/Cannot parse valid relation from xml string/, @response.body)
assert_response :forbidden
# try to delete without specifying a changeset
- content "<osm><relation id='#{relation.id}'/></osm>"
- delete :delete, :params => { :id => relation.id }
+ xml = "<osm><relation id='#{relation.id}'/></osm>"
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :forbidden
# try to delete with an invalid (closed) changeset
- content update_changeset(relation.to_xml,
- private_user_closed_changeset.id)
- delete :delete, :params => { :id => relation.id }
+ xml = update_changeset(relation.to_xml,
+ private_user_closed_changeset.id)
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :forbidden
# try to delete with an invalid (non-existent) changeset
- content update_changeset(relation.to_xml, 0)
- delete :delete, :params => { :id => relation.id }
+ xml = update_changeset(relation.to_xml, 0)
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :forbidden
# this won't work because the relation is in-use by another relation
- content(used_relation.to_xml)
- delete :delete, :params => { :id => used_relation.id }
+ xml = used_relation.to_xml
+ delete :delete, :params => { :id => used_relation.id }, :body => xml.to_s
assert_response :forbidden
# this should work when we provide the appropriate payload...
- content(relation.to_xml)
- delete :delete, :params => { :id => relation.id }
+ xml = relation.to_xml
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :forbidden
# this won't work since the relation is already deleted
- content(deleted_relation.to_xml)
- delete :delete, :params => { :id => deleted_relation.id }
+ xml = deleted_relation.to_xml
+ delete :delete, :params => { :id => deleted_relation.id }, :body => xml.to_s
assert_response :forbidden
# this won't work since the relation never existed
assert_response :bad_request
# try to delete without specifying a changeset
- content "<osm><relation id='#{relation.id}' version='#{relation.version}' /></osm>"
- delete :delete, :params => { :id => relation.id }
+ xml = "<osm><relation id='#{relation.id}' version='#{relation.version}' /></osm>"
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :bad_request
assert_match(/Changeset id is missing/, @response.body)
# try to delete with an invalid (closed) changeset
- content update_changeset(relation.to_xml,
- closed_changeset.id)
- delete :delete, :params => { :id => relation.id }
+ xml = update_changeset(relation.to_xml,
+ closed_changeset.id)
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :conflict
# try to delete with an invalid (non-existent) changeset
- content update_changeset(relation.to_xml, 0)
- delete :delete, :params => { :id => relation.id }
+ xml = update_changeset(relation.to_xml, 0)
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :conflict
# this won't work because the relation is in a changeset owned by someone else
- content update_changeset(relation.to_xml, create(:changeset).id)
- delete :delete, :params => { :id => relation.id }
+ xml = update_changeset(relation.to_xml, create(:changeset).id)
+ delete :delete, :params => { :id => relation.id }, :body => xml.to_s
assert_response :conflict,
"shouldn't be able to delete a relation in a changeset owned by someone else (#{@response.body})"
# this won't work because the relation in the payload is different to that passed
- content update_changeset(relation.to_xml, changeset.id)
- delete :delete, :params => { :id => create(:relation).id }
+ xml = update_changeset(relation.to_xml, changeset.id)
+ delete :delete, :params => { :id => create(:relation).id }, :body => xml.to_s
assert_response :bad_request, "shouldn't be able to delete a relation when payload is different to the url"
# this won't work because the relation is in-use by another relation
- content update_changeset(used_relation.to_xml, changeset.id)
- delete :delete, :params => { :id => used_relation.id }
+ xml = update_changeset(used_relation.to_xml, changeset.id)
+ delete :delete, :params => { :id => used_relation.id }, :body => xml.to_s
assert_response :precondition_failed,
"shouldn't be able to delete a relation used in a relation (#{@response.body})"
assert_equal "Precondition failed: The relation #{used_relation.id} is used in relation #{super_relation.id}.", @response.body
# this should work when we provide the appropriate payload...
- content update_changeset(multi_tag_relation.to_xml, changeset.id)
- delete :delete, :params => { :id => multi_tag_relation.id }
+ xml = update_changeset(multi_tag_relation.to_xml, changeset.id)
+ delete :delete, :params => { :id => multi_tag_relation.id }, :body => xml.to_s
assert_response :success
# valid delete should return the new version number, which should
"delete request should return a new version number for relation"
# this won't work since the relation is already deleted
- content update_changeset(deleted_relation.to_xml, changeset.id)
- delete :delete, :params => { :id => deleted_relation.id }
+ xml = update_changeset(deleted_relation.to_xml, changeset.id)
+ delete :delete, :params => { :id => deleted_relation.id }, :body => xml.to_s
assert_response :gone
# Public visible relation needs to be deleted
- content update_changeset(super_relation.to_xml, changeset.id)
- delete :delete, :params => { :id => super_relation.id }
+ xml = update_changeset(super_relation.to_xml, changeset.id)
+ delete :delete, :params => { :id => super_relation.id }, :body => xml.to_s
assert_response :success
# this works now because the relation which was using this one
# has been deleted.
- content update_changeset(used_relation.to_xml, changeset.id)
- delete :delete, :params => { :id => used_relation.id }
+ xml = update_changeset(used_relation.to_xml, changeset.id)
+ delete :delete, :params => { :id => used_relation.id }, :body => xml.to_s
assert_response :success,
"should be able to delete a relation used in an old relation (#{@response.body})"
update_changeset(relation_xml, changeset_id)
# upload the change
- content relation_xml
- put :update, :params => { :id => relation.id }
+ put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
assert_response :success, "can't update relation for tag/bbox test"
end
end
update_changeset(relation_xml, changeset_id)
# upload the change
- content relation_xml
- put :update, :params => { :id => relation.id }
+ put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
# get it back and check the ordering
update_changeset(relation_xml, changeset_id)
# upload the change
- content relation_xml
- put :update, :params => { :id => relation.id }
+ put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
assert_response :success, "can't update relation for remove node/bbox test"
end
end
OSM
doc = XML::Parser.string(doc_str).parse
- content doc
- put :create
+ put :create, :body => doc.to_s
assert_response :success, "can't create a relation: #{@response.body}"
relation_id = @response.body.to_i
doc.find("//osm/relation").first["version"] = 1.to_s
# upload the next version of the relation
- content doc
- put :update, :params => { :id => relation_id }
+ put :update, :params => { :id => relation_id }, :body => doc.to_s
assert_response :success, "can't update relation: #{@response.body}"
assert_equal 2, @response.body.to_i
## First try with the private user
basic_authorization private_user.email, "test"
- content doc
- put :create
+ put :create, :body => doc.to_s
assert_response :forbidden
## Now try with the public user
basic_authorization user.email, "test"
- content doc
- put :create
+ put :create, :body => doc.to_s
assert_response :success, "can't create a relation: #{@response.body}"
relation_id = @response.body.to_i
doc = XML::Parser.string(doc_str).parse
basic_authorization user.email, "test"
- content doc
- put :create
+ put :create, :body => doc.to_s
assert_response :success, "can't create a relation: #{@response.body}"
relation_id = @response.body.to_i
update_changeset(relation_xml, changeset_id)
# upload the change
- content relation_xml
- put :update, :params => { :id => relation.id }
+ put :update, :params => { :id => relation.id }, :body => relation_xml.to_s
assert_response :success, "can't update relation for remove all members test"
checkrelation = Relation.find(relation.id)
assert_not_nil(checkrelation,
# create a new changeset for this operation, so we are assured
# that the bounding box will be newly-generated.
changeset_id = with_controller(ChangesetsController.new) do
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :forbidden, "shouldn't be able to create changeset for modify test, as should get forbidden"
end
# create a new changeset for this operation, so we are assured
# that the bounding box will be newly-generated.
changeset_id = with_controller(ChangesetsController.new) do
- content "<osm><changeset/></osm>"
- put :create
+ xml = "<osm><changeset/></osm>"
+ put :create, :body => xml
assert_response :success, "couldn't create changeset for modify test"
@response.body.to_i
end
# the parsed XML doc is retured.
def with_update(rel)
rel_id = rel.find("//osm/relation").first["id"].to_i
- content rel
- put :update, :params => { :id => rel_id }
+ put :update, :params => { :id => rel_id }, :body => rel.to_s
assert_response :success, "can't update relation: #{@response.body}"
version = @response.body.to_i
change << modify
modify << doc.import(rel.find("//osm/relation").first)
- content doc.to_s
- post :upload, :params => { :id => cs_id }
+ post :upload, :params => { :id => cs_id }, :body => doc.to_s
assert_response :success, "can't upload diff relation: #{@response.body}"
version = xml_parse(@response.body).find("//diffResult/relation").first["new_version"].to_i
end
anon_trace_file = create(:trace, :visibility => "private")
# First with no auth
- content public_trace_file.to_xml
- put :api_update, :params => { :id => public_trace_file.id }
+ put :api_update, :params => { :id => public_trace_file.id }, :body => public_trace_file.to_xml.to_s
assert_response :unauthorized
# Now with some other user, which should fail
basic_authorization create(:user).display_name, "test"
- content public_trace_file.to_xml
- put :api_update, :params => { :id => public_trace_file.id }
+ put :api_update, :params => { :id => public_trace_file.id }, :body => public_trace_file.to_xml.to_s
assert_response :forbidden
# Now with a trace which doesn't exist
basic_authorization create(:user).display_name, "test"
- content public_trace_file.to_xml
- put :api_update, :params => { :id => 0 }
+ put :api_update, :params => { :id => 0 }, :body => public_trace_file.to_xml.to_s
assert_response :not_found
# Now with a trace which did exist but has been deleted
basic_authorization deleted_trace_file.user.display_name, "test"
- content deleted_trace_file.to_xml
- put :api_update, :params => { :id => deleted_trace_file.id }
+ put :api_update, :params => { :id => deleted_trace_file.id }, :body => deleted_trace_file.to_xml.to_s
assert_response :not_found
# Now try an update with the wrong ID
basic_authorization public_trace_file.user.display_name, "test"
- content anon_trace_file.to_xml
- put :api_update, :params => { :id => public_trace_file.id }
+ put :api_update, :params => { :id => public_trace_file.id }, :body => anon_trace_file.to_xml.to_s
assert_response :bad_request,
"should not be able to update a trace with a different ID from the XML"
t = public_trace_file
t.description = "Changed description"
t.visibility = "private"
- content t.to_xml
- put :api_update, :params => { :id => t.id }
+ put :api_update, :params => { :id => t.id }, :body => t.to_xml.to_s
assert_response :success
nt = Trace.find(t.id)
assert_equal nt.description, t.description
trace = tracetag.trace
basic_authorization trace.user.display_name, "test"
- content trace.to_xml
- put :api_update, :params => { :id => trace.id }
+ put :api_update, :params => { :id => trace.id }, :body => trace.to_xml.to_s
assert_response :success
updated = Trace.find(trace.id)
# try a put without auth
assert_no_difference "UserPreference.count" do
- content "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
- put :update
+ put :update, :body => "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
end
assert_response :unauthorized, "should be authenticated"
assert_equal "value", UserPreference.find([user.id, "key"]).v
# try the put again
assert_no_difference "UserPreference.count" do
- content "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
- put :update
+ put :update, :body => "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
end
assert_response :success
assert_equal "text/plain", @response.content_type
# try a put with duplicate keys
assert_no_difference "UserPreference.count" do
- content "<osm><preferences><preference k='key' v='value'/><preference k='key' v='newer_value'/></preferences></osm>"
- put :update
+ put :update, :body => "<osm><preferences><preference k='key' v='value'/><preference k='key' v='newer_value'/></preferences></osm>"
end
assert_response :bad_request
assert_equal "text/plain", @response.content_type
# try a put with invalid content
assert_no_difference "UserPreference.count" do
- content "nonsense"
- put :update
+ put :update, :body => "nonsense"
end
assert_response :bad_request
end
# try a put without auth
assert_no_difference "UserPreference.count" do
- content "new_value"
- put :update_one, :params => { :preference_key => "new_key" }
+ put :update_one, :params => { :preference_key => "new_key" }, :body => "new_value"
end
assert_response :unauthorized, "should be authenticated"
assert_raises ActiveRecord::RecordNotFound do
# try adding a new preference
assert_difference "UserPreference.count", 1 do
- content "new_value"
- put :update_one, :params => { :preference_key => "new_key" }
+ put :update_one, :params => { :preference_key => "new_key" }, :body => "new_value"
end
assert_response :success
assert_equal "text/plain", @response.content_type
# try changing the value of a preference
assert_no_difference "UserPreference.count" do
- content "newer_value"
- put :update_one, :params => { :preference_key => "new_key" }
+ put :update_one, :params => { :preference_key => "new_key" }, :body => "newer_value"
end
assert_response :success
assert_equal "text/plain", @response.content_type
changeset_id = private_changeset.id
# create a way with pre-existing nodes
- content "<osm><way changeset='#{changeset_id}'>" \
- "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
- "<tag k='test' v='yes' /></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{changeset_id}'>" \
+ "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
+ "<tag k='test' v='yes' /></way></osm>"
+ put :create, :body => xml
# hope for failure
assert_response :forbidden,
"way upload did not return forbidden status"
changeset_id = changeset.id
# create a way with pre-existing nodes
- content "<osm><way changeset='#{changeset_id}'>" \
- "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
- "<tag k='test' v='yes' /></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{changeset_id}'>" \
+ "<nd ref='#{node1.id}'/><nd ref='#{node2.id}'/>" \
+ "<tag k='test' v='yes' /></way></osm>"
+ put :create, :body => xml
# hope for success
assert_response :success,
"way upload did not return success status"
# use the first user's open changeset
# create a way with non-existing node
- content "<osm><way changeset='#{private_open_changeset.id}'>" \
- "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
+ "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :forbidden,
"way upload with invalid node using a private user did not return 'forbidden'"
# create a way with no nodes
- content "<osm><way changeset='#{private_open_changeset.id}'>" \
- "<tag k='test' v='yes' /></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{private_open_changeset.id}'>" \
+ "<tag k='test' v='yes' /></way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :forbidden,
"way upload with no node using a private userdid not return 'forbidden'"
# create a way inside a closed changeset
- content "<osm><way changeset='#{private_closed_changeset.id}'>" \
- "<nd ref='#{node.id}'/></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{private_closed_changeset.id}'>" \
+ "<nd ref='#{node.id}'/></way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :forbidden,
"way upload to closed changeset with a private user did not return 'forbidden'"
# use the first user's open changeset
# create a way with non-existing node
- content "<osm><way changeset='#{open_changeset.id}'>" \
- "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{open_changeset.id}'>" \
+ "<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :precondition_failed,
"way upload with invalid node did not return 'precondition failed'"
assert_equal "Precondition failed: Way requires the nodes with id in (0), which either do not exist, or are not visible.", @response.body
# create a way with no nodes
- content "<osm><way changeset='#{open_changeset.id}'>" \
- "<tag k='test' v='yes' /></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{open_changeset.id}'>" \
+ "<tag k='test' v='yes' /></way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :precondition_failed,
"way upload with no node did not return 'precondition failed'"
assert_equal "Precondition failed: Cannot create way: data is invalid.", @response.body
# create a way inside a closed changeset
- content "<osm><way changeset='#{closed_changeset.id}'>" \
- "<nd ref='#{node.id}'/></way></osm>"
- put :create
+ xml = "<osm><way changeset='#{closed_changeset.id}'>" \
+ "<nd ref='#{node.id}'/></way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :conflict,
"way upload to closed changeset did not return 'conflict'"
# create a way with a tag which is too long
- content "<osm><way changeset='#{open_changeset.id}'>" \
- "<nd ref='#{node.id}'/>" \
- "<tag k='foo' v='#{'x' * 256}'/>" \
- "</way></osm>"
- put :create
+ xml = "<osm><way changeset='#{open_changeset.id}'>" \
+ "<nd ref='#{node.id}'/>" \
+ "<tag k='foo' v='#{'x' * 256}'/>" \
+ "</way></osm>"
+ put :create, :body => xml
# expect failure
assert_response :bad_request,
"way upload to with too long tag did not return 'bad_request'"
assert_response :forbidden
# Now try without having a changeset
- content "<osm><way id='#{private_way.id}'/></osm>"
- delete :delete, :params => { :id => private_way.id }
+ xml = "<osm><way id='#{private_way.id}'/></osm>"
+ delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
assert_response :forbidden
# try to delete with an invalid (closed) changeset
- content update_changeset(private_way.to_xml, private_closed_changeset.id)
- delete :delete, :params => { :id => private_way.id }
+ xml = update_changeset(private_way.to_xml, private_closed_changeset.id)
+ delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
assert_response :forbidden
# try to delete with an invalid (non-existent) changeset
- content update_changeset(private_way.to_xml, 0)
- delete :delete, :params => { :id => private_way.id }
+ xml = update_changeset(private_way.to_xml, 0)
+ delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
assert_response :forbidden
# Now try with a valid changeset
- content private_way.to_xml
- delete :delete, :params => { :id => private_way.id }
+ xml = private_way.to_xml
+ delete :delete, :params => { :id => private_way.id }, :body => xml.to_s
assert_response :forbidden
# check the returned value - should be the new version number
# "delete request should return a new version number for way"
# this won't work since the way is already deleted
- content private_deleted_way.to_xml
- delete :delete, :params => { :id => private_deleted_way.id }
+ xml = private_deleted_way.to_xml
+ delete :delete, :params => { :id => private_deleted_way.id }, :body => xml.to_s
assert_response :forbidden
# this shouldn't work as the way is used in a relation
- content private_used_way.to_xml
- delete :delete, :params => { :id => private_used_way.id }
+ xml = private_used_way.to_xml
+ delete :delete, :params => { :id => private_used_way.id }, :body => xml.to_s
assert_response :forbidden,
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
assert_response :bad_request
# Now try without having a changeset
- content "<osm><way id='#{way.id}'/></osm>"
- delete :delete, :params => { :id => way.id }
+ xml = "<osm><way id='#{way.id}'/></osm>"
+ delete :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :bad_request
# try to delete with an invalid (closed) changeset
- content update_changeset(way.to_xml, closed_changeset.id)
- delete :delete, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml, closed_changeset.id)
+ delete :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict
# try to delete with an invalid (non-existent) changeset
- content update_changeset(way.to_xml, 0)
- delete :delete, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml, 0)
+ delete :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict
# Now try with a valid changeset
- content way.to_xml
- delete :delete, :params => { :id => way.id }
+ xml = way.to_xml
+ delete :delete, :params => { :id => way.id }, :body => xml.to_s
assert_response :success
# check the returned value - should be the new version number
"delete request should return a new version number for way"
# this won't work since the way is already deleted
- content deleted_way.to_xml
- delete :delete, :params => { :id => deleted_way.id }
+ xml = deleted_way.to_xml
+ delete :delete, :params => { :id => deleted_way.id }, :body => xml.to_s
assert_response :gone
# this shouldn't work as the way is used in a relation
- content used_way.to_xml
- delete :delete, :params => { :id => used_way.id }
+ xml = used_way.to_xml
+ delete :delete, :params => { :id => used_way.id }, :body => xml.to_s
assert_response :precondition_failed,
"shouldn't be able to delete a way used in a relation (#{@response.body})"
assert_equal "Precondition failed: Way #{used_way.id} is still used by relations #{relation.id}.", @response.body
## First test with no user credentials
# try and update a way without authorisation
- content way.to_xml
- put :update, :params => { :id => way.id }
+ xml = way.to_xml
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :unauthorized
## Second test with the private user
## trying to break changesets
# try and update in someone else's changeset
- content update_changeset(private_way.to_xml,
- create(:changeset).id)
- put :update, :params => { :id => private_way.id }
+ xml = update_changeset(private_way.to_xml,
+ create(:changeset).id)
+ put :update, :params => { :id => private_way.id }, :body => xml.to_s
assert_require_public_data "update with other user's changeset should be forbidden when date isn't public"
# try and update in a closed changeset
- content update_changeset(private_way.to_xml,
- create(:changeset, :closed, :user => private_user).id)
- put :update, :params => { :id => private_way.id }
+ xml = update_changeset(private_way.to_xml,
+ create(:changeset, :closed, :user => private_user).id)
+ put :update, :params => { :id => private_way.id }, :body => xml.to_s
assert_require_public_data "update with closed changeset should be forbidden, when data isn't public"
# try and update in a non-existant changeset
- content update_changeset(private_way.to_xml, 0)
- put :update, :params => { :id => private_way.id }
+ xml = update_changeset(private_way.to_xml, 0)
+ put :update, :params => { :id => private_way.id }, :body => xml.to_s
assert_require_public_data("update with changeset=0 should be forbidden, when data isn't public")
## try and submit invalid updates
- content xml_replace_node(private_way.to_xml, node.id, 9999)
- put :update, :params => { :id => private_way.id }
+ xml = xml_replace_node(private_way.to_xml, node.id, 9999)
+ put :update, :params => { :id => private_way.id }, :body => xml.to_s
assert_require_public_data "way with non-existent node should be forbidden, when data isn't public"
- content xml_replace_node(private_way.to_xml, node.id, create(:node, :deleted).id)
- put :update, :params => { :id => private_way.id }
+ xml = xml_replace_node(private_way.to_xml, node.id, create(:node, :deleted).id)
+ put :update, :params => { :id => private_way.id }, :body => xml.to_s
assert_require_public_data "way with deleted node should be forbidden, when data isn't public"
## finally, produce a good request which will still not work
- content private_way.to_xml
- put :update, :params => { :id => private_way.id }
+ xml = private_way.to_xml
+ put :update, :params => { :id => private_way.id }, :body => xml.to_s
assert_require_public_data "should have failed with a forbidden when data isn't public"
## Finally test with the public user
## trying to break changesets
# try and update in someone else's changeset
- content update_changeset(way.to_xml,
- create(:changeset).id)
- put :update, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml,
+ create(:changeset).id)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict, "update with other user's changeset should be rejected"
# try and update in a closed changeset
- content update_changeset(way.to_xml,
- create(:changeset, :closed, :user => user).id)
- put :update, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml,
+ create(:changeset, :closed, :user => user).id)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict, "update with closed changeset should be rejected"
# try and update in a non-existant changeset
- content update_changeset(way.to_xml, 0)
- put :update, :params => { :id => way.id }
+ xml = update_changeset(way.to_xml, 0)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict, "update with changeset=0 should be rejected"
## try and submit invalid updates
- content xml_replace_node(way.to_xml, node.id, 9999)
- put :update, :params => { :id => way.id }
+ xml = xml_replace_node(way.to_xml, node.id, 9999)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :precondition_failed, "way with non-existent node should be rejected"
- content xml_replace_node(way.to_xml, node.id, create(:node, :deleted).id)
- put :update, :params => { :id => way.id }
+ xml = xml_replace_node(way.to_xml, node.id, create(:node, :deleted).id)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :precondition_failed, "way with deleted node should be rejected"
## next, attack the versioning
current_way_version = way.version
# try and submit a version behind
- content xml_attr_rewrite(way.to_xml,
- "version", current_way_version - 1)
- put :update, :params => { :id => way.id }
+ xml = xml_attr_rewrite(way.to_xml,
+ "version", current_way_version - 1)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict, "should have failed on old version number"
# try and submit a version ahead
- content xml_attr_rewrite(way.to_xml,
- "version", current_way_version + 1)
- put :update, :params => { :id => way.id }
+ xml = xml_attr_rewrite(way.to_xml,
+ "version", current_way_version + 1)
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict, "should have failed on skipped version number"
# try and submit total crap in the version field
- content xml_attr_rewrite(way.to_xml,
- "version", "p1r4t3s!")
- put :update, :params => { :id => way.id }
+ xml = xml_attr_rewrite(way.to_xml,
+ "version", "p1r4t3s!")
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :conflict,
"should not be able to put 'p1r4at3s!' in the version field"
## try an update with the wrong ID
- content create(:way).to_xml
- put :update, :params => { :id => way.id }
+ xml = create(:way).to_xml
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :bad_request,
"should not be able to update a way with a different ID from the XML"
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
- content "<update/>"
- put :update, :params => { :id => way.id }
+ xml = "<update/>"
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :bad_request,
"should not be able to update a way with non-OSM XML doc."
## finally, produce a good request which should work
- content way.to_xml
- put :update, :params => { :id => way.id }
+ xml = way.to_xml
+ put :update, :params => { :id => way.id }, :body => xml.to_s
assert_response :success, "a valid update request failed"
end
way_xml.find("//osm/way").first << tag_xml
# try and upload it
- content way_xml
- put :update, :params => { :id => private_way.id }
+ put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
assert_response :forbidden,
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
way_xml.find("//osm/way").first << tag_xml
# try and upload it
- content way_xml
- put :update, :params => { :id => way.id }
+ put :update, :params => { :id => way.id }, :body => way_xml.to_s
assert_response :success,
"adding a new tag to a way should succeed"
assert_equal way.version + 1, @response.body.to_i
way_xml.find("//osm/way").first << tag_xml
# try and upload it
- content way_xml
- put :update, :params => { :id => private_way.id }
+ put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
assert_response :forbidden,
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
way_xml.find("//osm/way").first << tag_xml
# try and upload it
- content way_xml
- put :update, :params => { :id => way.id }
+ put :update, :params => { :id => way.id }, :body => way_xml.to_s
assert_response :bad_request,
"adding a duplicate tag to a way should fail with 'bad request'"
assert_equal "Element way/#{way.id} has duplicate tags with key #{existing_tag.k}", @response.body
way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
# try and upload it
- content way_xml
- put :update, :params => { :id => private_way.id }
+ put :update, :params => { :id => private_way.id }, :body => way_xml.to_s
assert_response :forbidden,
"adding new duplicate tags to a way using a non-public user should fail with 'forbidden'"
way_xml.find("//osm/way").first << tag_xml.copy(true) << tag_xml
# try and upload it
- content way_xml
- put :update, :params => { :id => way.id }
+ put :update, :params => { :id => way.id }, :body => way_xml.to_s
assert_response :bad_request,
"adding new duplicate tags to a way should fail with 'bad request'"
assert_equal "Element way/#{way.id} has duplicate tags with key i_am_a_duplicate", @response.body
way_str << "</way></osm>"
# try and upload it
- content way_str
- put :create
+ put :create, :body => way_str
assert_response :forbidden,
"adding new duplicate tags to a way with a non-public user should fail with 'forbidden'"
way_str << "</way></osm>"
# try and upload it
- content way_str
- put :create
+ put :create, :body => way_str
assert_response :bad_request,
"adding new duplicate tags to a way should fail with 'bad request'"
assert_equal "Element way/ has duplicate tags with key addr:housenumber", @response.body
@request.env["HTTP_X_ERROR_FORMAT"] = format
end
- ##
- # set the raw body to be sent with a POST request
- def content(c)
- @request.env["RAW_POST_DATA"] = c.to_s
- end
-
##
# Used to check that the error header and the forbidden responses are given
# when the owner of the changset has their data not marked as public