From: Tom Hughes Date: Thu, 15 Nov 2018 00:46:53 +0000 (+0000) Subject: Fix tests for rails 5.2.1 compatibility X-Git-Tag: live~3374 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/6f2f9221ef230142bc8c28b3942e306a13ce206b?ds=inline Fix tests for rails 5.2.1 compatibility Rails 5.2.1 has changed how the request body is handled internally for a test which means we can no longer cheat by stashing it in the request environment and must instead pass it properly to the request method. --- diff --git a/test/controllers/amf_controller_test.rb b/test/controllers/amf_controller_test.rb index 650bf1f8e..135b27edf 100644 --- a/test/controllers/amf_controller_test.rb +++ b/test/controllers/amf_controller_test.rb @@ -21,8 +21,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -50,8 +49,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -68,8 +66,7 @@ class AmfControllerTest < ActionController::TestCase # 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") @@ -86,8 +83,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -108,8 +104,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -131,8 +126,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -149,8 +143,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -172,8 +165,7 @@ class AmfControllerTest < ActionController::TestCase 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 @@ -266,8 +258,7 @@ class AmfControllerTest < ActionController::TestCase 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 @@ -286,8 +277,7 @@ class AmfControllerTest < ActionController::TestCase 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 @@ -297,8 +287,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -308,8 +297,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -321,8 +309,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -343,8 +330,7 @@ class AmfControllerTest < ActionController::TestCase # 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") @@ -365,8 +351,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -386,8 +371,7 @@ class AmfControllerTest < ActionController::TestCase [[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") @@ -403,8 +387,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -420,8 +403,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -438,8 +420,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -456,8 +437,7 @@ class AmfControllerTest < ActionController::TestCase _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") @@ -478,8 +458,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -491,8 +470,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -503,8 +481,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -518,8 +495,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -538,8 +514,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -552,8 +527,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -565,8 +539,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -583,8 +556,7 @@ class AmfControllerTest < ActionController::TestCase 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 @@ -601,8 +573,7 @@ class AmfControllerTest < ActionController::TestCase 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 @@ -614,8 +585,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -629,8 +599,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -649,8 +618,7 @@ class AmfControllerTest < ActionController::TestCase # 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") @@ -664,8 +632,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -675,8 +642,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -695,8 +661,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -711,8 +676,7 @@ class AmfControllerTest < ActionController::TestCase # 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") @@ -737,8 +701,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -774,8 +737,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -821,8 +783,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -857,8 +818,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -874,8 +834,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -897,8 +856,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -915,8 +873,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -933,8 +890,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -956,8 +912,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -978,8 +933,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1000,8 +954,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1050,8 +1003,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1078,8 +1030,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1099,8 +1050,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1156,8 +1106,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1186,8 +1135,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1215,8 +1163,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1244,8 +1191,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1272,8 +1218,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1300,8 +1245,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1321,8 +1265,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1338,8 +1281,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1361,8 +1303,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1382,8 +1323,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1397,8 +1337,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1419,8 +1358,7 @@ class AmfControllerTest < ActionController::TestCase 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") @@ -1460,7 +1398,7 @@ class AmfControllerTest < ActionController::TestCase 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. @@ -1499,8 +1437,7 @@ class AmfControllerTest < ActionController::TestCase # 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 diff --git a/test/controllers/changesets_controller_test.rb b/test/controllers/changesets_controller_test.rb index 867b599eb..35ee9c469 100644 --- a/test/controllers/changesets_controller_test.rb +++ b/test/controllers/changesets_controller_test.rb @@ -77,18 +77,18 @@ class ChangesetsControllerTest < ActionController::TestCase def test_create basic_authorization create(:user, :data_public => false).email, "test" # Create the first user's changeset - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_require_public_data basic_authorization create(:user).email, "test" # Create the first user's changeset - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :success, "Creation of changeset did not return sucess status" newid = @response.body.to_i @@ -111,14 +111,14 @@ class ChangesetsControllerTest < ActionController::TestCase def test_create_invalid basic_authorization create(:user, :data_public => false).email, "test" - content "" - put :create + xml = "" + put :create, :body => xml assert_require_public_data ## Try the public user basic_authorization create(:user).email, "test" - content "" - put :create + xml = "" + put :create, :body => xml assert_response :bad_request, "creating a invalid changeset should fail" end @@ -325,8 +325,7 @@ class ChangesetsControllerTest < ActionController::TestCase 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}" @@ -355,8 +354,7 @@ CHANGESET 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}" @@ -385,8 +383,7 @@ CHANGESET 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}" @@ -430,8 +427,7 @@ CHANGESET 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}" @@ -495,8 +491,7 @@ CHANGESET 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}" @@ -523,8 +518,7 @@ CHANGESET diff = "" # 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}" @@ -540,11 +534,11 @@ CHANGESET basic_authorization create(:user).email, "test" # create a temporary changeset - content "" \ - "" \ - "" + xml = "" \ + "" \ + "" assert_difference "Changeset.count", 1 do - put :create + put :create, :body => xml end assert_response :success end @@ -554,8 +548,7 @@ CHANGESET basic_authorization create(:user).email, "test" # create a changeset - content "" - put :create + put :create, :body => "" assert_response :success, "Should be able to create a changeset: #{@response.body}" changeset_id = @response.body.to_i @@ -587,8 +580,7 @@ CHANGESET # 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}" @@ -630,8 +622,7 @@ CHANGESET 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 @@ -674,8 +665,7 @@ CHANGESET 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}" @@ -728,8 +718,7 @@ CHANGESET 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 @@ -771,8 +760,7 @@ CHANGESET 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}" @@ -833,8 +821,7 @@ CHANGESET 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" @@ -870,8 +857,7 @@ CHANGESET 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}" @@ -900,8 +886,7 @@ CHANGESET 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 @@ -922,8 +907,7 @@ CHANGESET 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 @@ -942,8 +926,7 @@ CHANGESET 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 @@ -976,8 +959,7 @@ CHANGESET 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}" @@ -1014,8 +996,7 @@ CHANGESET 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}" @@ -1043,8 +1024,7 @@ CHANGESET 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 @@ -1075,8 +1055,7 @@ CHANGESET 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 @@ -1099,8 +1078,7 @@ CHANGESET 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 @@ -1132,8 +1110,7 @@ CHANGESET 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 @@ -1156,8 +1133,7 @@ CHANGESET 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 @@ -1169,10 +1145,10 @@ CHANGESET def test_upload_node_move basic_authorization create(:user).email, "test" - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :success changeset_id = @response.body.to_i @@ -1189,8 +1165,7 @@ CHANGESET 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" @@ -1207,10 +1182,10 @@ CHANGESET def test_upload_way_extend basic_authorization create(:user).email, "test" - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :success changeset_id = @response.body.to_i @@ -1229,8 +1204,7 @@ CHANGESET 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" @@ -1254,8 +1228,7 @@ CHANGESET "", ""].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 @@ -1278,9 +1251,8 @@ CHANGESET 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" @@ -1300,20 +1272,20 @@ CHANGESET basic_authorization create(:user, :data_public => false).email, "test" # create a temporary changeset - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :forbidden ## Now try with a normal user basic_authorization create(:user).email, "test" # create a temporary changeset - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :success changeset_id = @response.body.to_i @@ -1334,8 +1306,7 @@ CHANGESET 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}" @@ -1356,10 +1327,10 @@ CHANGESET basic_authorization create(:user).email, "test" # create a temporary changeset - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :success changeset_id = @response.body.to_i @@ -1393,8 +1364,7 @@ CHANGESET 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}" @@ -1418,10 +1388,10 @@ OSMFILE basic_authorization create(:user).email, "test" # create a temporary changeset - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml assert_response :success changeset_id = @response.body.to_i @@ -1449,8 +1419,7 @@ OSMFILE 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}" @@ -1501,15 +1470,15 @@ CHANGESET basic_authorization create(:user).email, "test" # create a new changeset - content "" - put :create + xml = "" + 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 "" - put :create + xml = "" + put :create, :body => xml assert_response :success, "Couldn't create node." end @@ -1523,8 +1492,8 @@ CHANGESET # add another node to it with_controller(NodesController.new) do - content "" - put :create + xml = "" + put :create, :body => xml assert_response :success, "Couldn't create second node." end @@ -1538,8 +1507,8 @@ CHANGESET # 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 @@ -1558,8 +1527,7 @@ CHANGESET basic_authorization create(:user).display_name, "test" # create a new changeset - content "" - put :create + put :create, :body => "" assert_response :success, "Creating of changeset failed." changeset_id = @response.body.to_i @@ -1580,8 +1548,8 @@ CHANGESET basic_authorization create(:user).display_name, "test" # create a new changeset - content "" - put :create + xml = "" + put :create, :body => xml assert_response :success, "Creating of changeset failed." changeset_id = @response.body.to_i @@ -1589,18 +1557,18 @@ CHANGESET lat = -0.45 # Try and put - content "" - put :expand_bbox, :params => { :id => changeset_id } + xml = "" + 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 "" - get :expand_bbox, :params => { :id => changeset_id } + xml = "" + 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 "" - post :expand_bbox, :params => { :id => changeset_id + 13245 } + xml = "" + 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 @@ -1734,20 +1702,19 @@ CHANGESET 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 @@ -1757,21 +1724,20 @@ CHANGESET 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 @@ -1792,8 +1758,7 @@ CHANGESET 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 @@ -1804,8 +1769,8 @@ CHANGESET basic_authorization create(:user).email, "test" # open a new changeset - content "" - put :create + xml = "" + put :create, :body => xml assert_response :success, "can't create a new changeset" cs_id = @response.body.to_i @@ -1819,8 +1784,8 @@ CHANGESET with_controller(NodesController.new) do # create a new node - content "" - put :create + xml = "" + put :create, :body => xml assert_response :success, "can't create a new node" node_id = @response.body.to_i @@ -1835,8 +1800,7 @@ CHANGESET 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 @@ -1845,8 +1809,7 @@ CHANGESET 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 @@ -2230,8 +2193,8 @@ CHANGESET ## # call the include method and assert properties of the bbox def check_after_include(changeset_id, lon, lat, bbox) - content "" - post :expand_bbox, :params => { :id => changeset_id } + xml = "" + post :expand_bbox, :params => { :id => changeset_id }, :body => xml assert_response :success, "Setting include of changeset failed: #{@response.body}" # check exactly one changeset diff --git a/test/controllers/nodes_controller_test.rb b/test/controllers/nodes_controller_test.rb index 3cd4244e1..77a6d372b 100644 --- a/test/controllers/nodes_controller_test.rb +++ b/test/controllers/nodes_controller_test.rb @@ -38,9 +38,9 @@ class NodesControllerTest < ActionController::TestCase ## First try with no auth # create a minimal xml file - content("") + xml = "" 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" @@ -49,9 +49,9 @@ class NodesControllerTest < ActionController::TestCase basic_authorization private_user.email, "test" # create a minimal xml file - content("") + xml = "" 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" @@ -60,8 +60,8 @@ class NodesControllerTest < ActionController::TestCase basic_authorization user.email, "test" # create a minimal xml file - content("") - put :create + xml = "" + put :create, :body => xml # hope for success assert_response :success, "node upload did not return success status" @@ -88,46 +88,46 @@ class NodesControllerTest < ActionController::TestCase lon = 3.23 # test that the upload is rejected when xml is valid, but osm doc isn't - content("") - put :create + xml = "" + 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 . 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("") - put :create + xml = "" + 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 . lat missing", @response.body # test that the upload is rejected when no lon is supplied # create a minimal xml file - content("") - put :create + xml = "" + 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 . lon missing", @response.body # test that the upload is rejected when lat is non-numeric # create a minimal xml file - content("") - put :create + xml = "" + 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 . lat not a number", @response.body # test that the upload is rejected when lon is non-numeric # create a minimal xml file - content("") - put :create + xml = "" + 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 . lon not a number", @response.body # test that the upload is rejected when we have a tag which is too long - content("") - put :create + xml = "" + 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 @@ -163,23 +163,23 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -191,16 +191,16 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -211,31 +211,31 @@ class NodesControllerTest < ActionController::TestCase 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, :params => { :id => node.id } + xml = "" + 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 @@ -244,8 +244,8 @@ class NodesControllerTest < ActionController::TestCase "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 @@ -258,8 +258,8 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -269,8 +269,8 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -288,8 +288,8 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -300,50 +300,50 @@ class NodesControllerTest < ActionController::TestCase ## 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 @@ -352,76 +352,76 @@ class NodesControllerTest < ActionController::TestCase ## 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 "" - put :update, :params => { :id => node.id } + xml = "" + 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 @@ -477,8 +477,7 @@ class NodesControllerTest < ActionController::TestCase 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 @@ -496,10 +495,10 @@ class NodesControllerTest < ActionController::TestCase # try and put something into a string that the API might # use unquoted and therefore allow code injection... - content "" \ - '' \ - "" - put :create + xml = "" \ + '' \ + "" + 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 @@ -507,10 +506,10 @@ class NodesControllerTest < ActionController::TestCase # try and put something into a string that the API might # use unquoted and therefore allow code injection... - content "" \ - '' \ - "" - put :create + xml = "" \ + '' \ + "" + put :create, :body => xml assert_response :success nodeid = @response.body diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index 2568cbfd8..53c507234 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -59,8 +59,7 @@ class OldNodesControllerTest < ActionController::TestCase 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 @@ -75,8 +74,7 @@ class OldNodesControllerTest < ActionController::TestCase 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 @@ -109,8 +107,7 @@ class OldNodesControllerTest < ActionController::TestCase 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 @@ -125,8 +122,7 @@ class OldNodesControllerTest < ActionController::TestCase 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 diff --git a/test/controllers/relations_controller_test.rb b/test/controllers/relations_controller_test.rb index 224caa642..fe35637bd 100644 --- a/test/controllers/relations_controller_test.rb +++ b/test/controllers/relations_controller_test.rb @@ -206,8 +206,8 @@ class RelationsControllerTest < ActionController::TestCase basic_authorization private_user.email, "test" # create an relation without members - content "" - put :create + xml = "" + put :create, :body => xml # hope for forbidden, due to user assert_response :forbidden, "relation upload should have failed with forbidden" @@ -215,10 +215,10 @@ class RelationsControllerTest < ActionController::TestCase ### # create an relation with a node as member # This time try with a role attribute in the relation - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml # hope for forbidden due to user assert_response :forbidden, "relation upload did not return forbidden status" @@ -226,20 +226,20 @@ class RelationsControllerTest < ActionController::TestCase ### # create an relation with a node as member, this time test that we don't # need a role attribute to be included - content "" \ - "" + "" - put :create + xml = "" \ + "" + "" + 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 "" \ - "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" \ + "" + put :create, :body => xml # hope for forbidden, due to user assert_response :forbidden, "relation upload did not return success status" @@ -248,8 +248,8 @@ class RelationsControllerTest < ActionController::TestCase basic_authorization user.email, "test" # create an relation without members - content "" - put :create + xml = "" + put :create, :body => xml # hope for success assert_response :success, "relation upload did not return success status" @@ -276,10 +276,10 @@ class RelationsControllerTest < ActionController::TestCase ### # create an relation with a node as member # This time try with a role attribute in the relation - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml # hope for success assert_response :success, "relation upload did not return success status" @@ -307,9 +307,9 @@ class RelationsControllerTest < ActionController::TestCase ### # create an relation with a node as member, this time test that we don't # need a role attribute to be included - content "" \ - "" + "" - put :create + xml = "" \ + "" + "" + put :create, :body => xml # hope for success assert_response :success, "relation upload did not return success status" @@ -336,11 +336,11 @@ class RelationsControllerTest < ActionController::TestCase ### # create an relation with a way and a node as members - content "" \ - "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" \ + "" + put :create, :body => xml # hope for success assert_response :success, "relation upload did not return success status" @@ -443,8 +443,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -460,10 +459,10 @@ class RelationsControllerTest < ActionController::TestCase basic_authorization user.email, "test" # create a relation with non-existing node as member - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml # expect failure assert_response :precondition_failed, "relation upload with invalid node did not return 'precondition failed'" @@ -481,10 +480,10 @@ class RelationsControllerTest < ActionController::TestCase basic_authorization user.email, "test" # create some xml that should return an error - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml # expect failure assert_response :bad_request assert_match(/Cannot parse valid relation from xml string/, @response.body) @@ -520,34 +519,34 @@ class RelationsControllerTest < ActionController::TestCase assert_response :forbidden # try to delete without specifying a changeset - content "" - delete :delete, :params => { :id => relation.id } + xml = "" + 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 @@ -562,43 +561,43 @@ class RelationsControllerTest < ActionController::TestCase assert_response :bad_request # try to delete without specifying a changeset - content "" - delete :delete, :params => { :id => relation.id } + xml = "" + 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 @@ -607,19 +606,19 @@ class RelationsControllerTest < ActionController::TestCase "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})" @@ -654,8 +653,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -688,8 +686,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -721,8 +718,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -752,8 +748,7 @@ class RelationsControllerTest < ActionController::TestCase 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 @@ -773,8 +768,7 @@ OSM 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 @@ -815,15 +809,13 @@ OSM ## 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 @@ -856,8 +848,7 @@ OSM 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 @@ -896,8 +887,7 @@ OSM 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, @@ -940,8 +930,8 @@ OSM # 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 "" - put :create + xml = "" + put :create, :body => xml assert_response :forbidden, "shouldn't be able to create changeset for modify test, as should get forbidden" end @@ -951,8 +941,8 @@ OSM # 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 "" - put :create + xml = "" + put :create, :body => xml assert_response :success, "couldn't create changeset for modify test" @response.body.to_i end @@ -995,8 +985,7 @@ OSM # 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 @@ -1027,8 +1016,7 @@ OSM 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 diff --git a/test/controllers/traces_controller_test.rb b/test/controllers/traces_controller_test.rb index 2c01ef6f1..cd30746fe 100644 --- a/test/controllers/traces_controller_test.rb +++ b/test/controllers/traces_controller_test.rb @@ -929,32 +929,27 @@ class TracesControllerTest < ActionController::TestCase 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" @@ -963,8 +958,7 @@ class TracesControllerTest < ActionController::TestCase 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 @@ -977,8 +971,7 @@ class TracesControllerTest < ActionController::TestCase 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) diff --git a/test/controllers/user_preferences_controller_test.rb b/test/controllers/user_preferences_controller_test.rb index 3e5cbb369..ddd7e2a40 100644 --- a/test/controllers/user_preferences_controller_test.rb +++ b/test/controllers/user_preferences_controller_test.rb @@ -96,8 +96,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # try a put without auth assert_no_difference "UserPreference.count" do - content "" - put :update + put :update, :body => "" end assert_response :unauthorized, "should be authenticated" assert_equal "value", UserPreference.find([user.id, "key"]).v @@ -111,8 +110,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # try the put again assert_no_difference "UserPreference.count" do - content "" - put :update + put :update, :body => "" end assert_response :success assert_equal "text/plain", @response.content_type @@ -125,8 +123,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # try a put with duplicate keys assert_no_difference "UserPreference.count" do - content "" - put :update + put :update, :body => "" end assert_response :bad_request assert_equal "text/plain", @response.content_type @@ -135,8 +132,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # 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 @@ -149,8 +145,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # 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 @@ -162,8 +157,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # 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 @@ -172,8 +166,7 @@ class UserPreferencesControllerTest < ActionController::TestCase # 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 diff --git a/test/controllers/ways_controller_test.rb b/test/controllers/ways_controller_test.rb index 1199e5d94..091ce18c4 100644 --- a/test/controllers/ways_controller_test.rb +++ b/test/controllers/ways_controller_test.rb @@ -127,10 +127,10 @@ class WaysControllerTest < ActionController::TestCase changeset_id = private_changeset.id # create a way with pre-existing nodes - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml # hope for failure assert_response :forbidden, "way upload did not return forbidden status" @@ -142,10 +142,10 @@ class WaysControllerTest < ActionController::TestCase changeset_id = changeset.id # create a way with pre-existing nodes - content "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" + put :create, :body => xml # hope for success assert_response :success, "way upload did not return success status" @@ -187,25 +187,25 @@ class WaysControllerTest < ActionController::TestCase # use the first user's open changeset # create a way with non-existing node - content "" \ - "" - put :create + xml = "" \ + "" + 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 "" \ - "" - put :create + xml = "" \ + "" + 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 "" \ - "" - put :create + xml = "" \ + "" + put :create, :body => xml # expect failure assert_response :forbidden, "way upload to closed changeset with a private user did not return 'forbidden'" @@ -215,37 +215,37 @@ class WaysControllerTest < ActionController::TestCase # use the first user's open changeset # create a way with non-existing node - content "" \ - "" - put :create + xml = "" \ + "" + 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 "" \ - "" - put :create + xml = "" \ + "" + 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 "" \ - "" - put :create + xml = "" \ + "" + 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 "" \ - "" \ - "" \ - "" - put :create + xml = "" \ + "" \ + "" \ + "" + put :create, :body => xml # expect failure assert_response :bad_request, "way upload to with too long tag did not return 'bad_request'" @@ -284,23 +284,23 @@ class WaysControllerTest < ActionController::TestCase assert_response :forbidden # Now try without having a changeset - content "" - delete :delete, :params => { :id => private_way.id } + xml = "" + 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 @@ -310,13 +310,13 @@ class WaysControllerTest < ActionController::TestCase # "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" @@ -333,23 +333,23 @@ class WaysControllerTest < ActionController::TestCase assert_response :bad_request # Now try without having a changeset - content "" - delete :delete, :params => { :id => way.id } + xml = "" + 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 @@ -359,13 +359,13 @@ class WaysControllerTest < ActionController::TestCase "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 @@ -389,8 +389,8 @@ class WaysControllerTest < ActionController::TestCase ## 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 @@ -401,34 +401,34 @@ class WaysControllerTest < ActionController::TestCase ## 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 @@ -439,68 +439,68 @@ class WaysControllerTest < ActionController::TestCase ## 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 "" - put :update, :params => { :id => way.id } + xml = "" + 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 @@ -530,8 +530,7 @@ class WaysControllerTest < ActionController::TestCase 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'" @@ -549,8 +548,7 @@ class WaysControllerTest < ActionController::TestCase 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 @@ -580,8 +578,7 @@ class WaysControllerTest < ActionController::TestCase 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'" @@ -599,8 +596,7 @@ class WaysControllerTest < ActionController::TestCase 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 @@ -630,8 +626,7 @@ class WaysControllerTest < ActionController::TestCase 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'" @@ -651,8 +646,7 @@ class WaysControllerTest < ActionController::TestCase 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 @@ -679,8 +673,7 @@ class WaysControllerTest < ActionController::TestCase way_str << "" # 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'" @@ -695,8 +688,7 @@ class WaysControllerTest < ActionController::TestCase way_str << "" # 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 diff --git a/test/test_helper.rb b/test/test_helper.rb index fca1f64c9..747edf016 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -94,12 +94,6 @@ module ActiveSupport @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