Cleanup trailing whitespace
This commit is contained in:
parent
e1f79d84ad
commit
34e3e51456
129 changed files with 1056 additions and 1076 deletions
|
@ -24,7 +24,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
amf_content "getway", "/1", [id]
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
amf_parse_response
|
||||
way = amf_result("/1")
|
||||
assert_equal 0, way[0]
|
||||
assert_equal "", way[1]
|
||||
|
@ -55,7 +55,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
amf_content "getway", "/1", [id]
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
amf_parse_response
|
||||
way = amf_result("/1")
|
||||
assert_equal 0, way[0]
|
||||
assert_equal "", way[1]
|
||||
|
@ -72,7 +72,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
amf_content "getway", "/1", [id]
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
amf_parse_response
|
||||
way = amf_result("/1")
|
||||
assert_equal 0, way[0]
|
||||
assert_equal "", way[1]
|
||||
|
@ -90,7 +90,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
amf_content "getway", "/1", [id]
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
amf_parse_response
|
||||
way = amf_result("/1")
|
||||
assert_equal 0, way[0]
|
||||
assert_equal "", way[1]
|
||||
|
@ -125,7 +125,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
amf_content "whichways", "/1", [minlon, minlat, maxlon, maxlat]
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
amf_parse_response
|
||||
|
||||
# check contents of message
|
||||
map = amf_result "/1"
|
||||
|
@ -230,7 +230,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
amf_content "whichways_deleted", "/1", bbox
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
amf_parse_response
|
||||
|
||||
map = amf_result "/1"
|
||||
assert_deleted_boundary_error map, " The server said: The maximum bbox size is 0.25, and your request was too large. Either request a smaller area, or use planet.osm"
|
||||
|
@ -280,11 +280,11 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# instead of a version number...
|
||||
# try to get version 1
|
||||
v1 = ways(:way_with_versions_v1)
|
||||
{ latest.id => '',
|
||||
{ latest.id => '',
|
||||
v1.way_id => v1.timestamp.strftime("%d %b %Y, %H:%M:%S")
|
||||
}.each do |id, t|
|
||||
amf_content "getway_old", "/1", [id, t]
|
||||
post :amf_read
|
||||
post :amf_read
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
returned_way = amf_result("/1")
|
||||
|
@ -294,7 +294,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_equal latest.version, returned_way[5]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# test that the server doesn't fall over when rubbish is passed
|
||||
# into the method args.
|
||||
|
@ -323,8 +323,8 @@ class AmfControllerTest < ActionController::TestCase
|
|||
v1 = ways(:way_with_versions_v1)
|
||||
# try to get last visible version of non-existent way
|
||||
# try to get specific version of non-existent way
|
||||
[[0, ''],
|
||||
[0, '1 Jan 1970, 00:00:00'],
|
||||
[[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]
|
||||
|
@ -351,7 +351,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
|
||||
# ['way',wayid,history]
|
||||
assert_equal 'way', history[0]
|
||||
assert_equal latest.id, history[1]
|
||||
assert_equal latest.id, history[1]
|
||||
# We use dates rather than version numbers here, because you might
|
||||
# have moved a node within a way (i.e. way version not incremented).
|
||||
# The timestamp is +1 because we say "give me the revision of 15:33:02",
|
||||
|
@ -384,14 +384,14 @@ class AmfControllerTest < ActionController::TestCase
|
|||
# ['node',nodeid,history]
|
||||
# note that (as per getway_history) we actually round up
|
||||
# to the next second
|
||||
assert_equal history[0], 'node',
|
||||
assert_equal history[0], 'node',
|
||||
'first element should be "node"'
|
||||
assert_equal history[1], latest.id,
|
||||
'second element should be the input node ID'
|
||||
assert_equal history[2].first[0],
|
||||
assert_equal history[2].first[0],
|
||||
(latest.timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
|
||||
'first element in third element (array) should be the latest version'
|
||||
assert_equal history[2].last[0],
|
||||
assert_equal history[2].last[0],
|
||||
(nodes(:node_with_versions_v1).timestamp + 1).strftime("%d %b %Y, %H:%M:%S"),
|
||||
'last element in third element (array) should be the initial version'
|
||||
end
|
||||
|
@ -419,13 +419,13 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_response :success
|
||||
amf_parse_response
|
||||
result = amf_result("/1")
|
||||
|
||||
|
||||
assert_equal 0, result[0]
|
||||
assert_equal "", result[1]
|
||||
assert_equal nd.id, result[2]
|
||||
assert_equal nd.id, result[3]
|
||||
assert_equal nd.version+1, result[4]
|
||||
|
||||
|
||||
# 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
|
||||
|
@ -434,14 +434,14 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_response :success
|
||||
amf_parse_response
|
||||
result = amf_result("/2")
|
||||
|
||||
|
||||
assert_equal 0, result[0]
|
||||
assert_equal "", result[1]
|
||||
assert_equal nd.id, result[2]
|
||||
assert_equal nd.id, result[3]
|
||||
assert_equal nd.version+2, result[4]
|
||||
end
|
||||
|
||||
|
||||
# Check that we can create a no valid poi
|
||||
# Using similar method for the node controller test
|
||||
def test_putpoi_create_valid
|
||||
|
@ -452,21 +452,21 @@ class AmfControllerTest < ActionController::TestCase
|
|||
lon = rand(100)-50 + rand
|
||||
# normal user has a changeset open
|
||||
changeset = changesets(:public_user_first_change)
|
||||
|
||||
|
||||
amf_content "putpoi", "/1", ["test@example.com:test", changeset.id, nil, nil, lon, lat, {}, nil]
|
||||
post :amf_write
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
result = amf_result("/1")
|
||||
|
||||
|
||||
# check the array returned by the amf
|
||||
assert_equal 5, result.size
|
||||
assert_equal 0, result[0], "expected to get the status ok from the amf"
|
||||
assert_equal 0, result[2], "The old id should be 0"
|
||||
assert result[3] > 0, "The new id should be greater than 0"
|
||||
assert_equal 1, result[4], "The new version should be 1"
|
||||
|
||||
# Finally check that the node that was saved has saved the data correctly
|
||||
|
||||
# Finally check that the node that was saved has saved the data correctly
|
||||
# in both the current and history tables
|
||||
# First check the current table
|
||||
current_node = Node.find(result[3].to_i)
|
||||
|
@ -482,7 +482,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_in_delta lon, first_historic_node.lon, 0.00001, "The longitude was not retreuved correctly"
|
||||
assert_equal 0, first_historic_node.tags.size, "There seems to be a tag that have been attached to this node"
|
||||
assert_equal result[4], first_historic_node.version, "The version returned, is different to the one returned by the amf"
|
||||
|
||||
|
||||
####
|
||||
# This node has some tags
|
||||
tnd = Node.new
|
||||
|
@ -491,7 +491,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
lon = rand(100)-50 + rand
|
||||
# normal user has a changeset open
|
||||
changeset = changesets(:public_user_first_change)
|
||||
|
||||
|
||||
amf_content "putpoi", "/2", ["test@example.com:test", changeset.id, nil, nil, lon, lat, { "key" => "value", "ping" => "pong" }, nil]
|
||||
post :amf_write
|
||||
assert_response :success
|
||||
|
@ -504,8 +504,8 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_equal 0, result[2], "The old id should be 0"
|
||||
assert result[3] > 0, "The new id should be greater than 0"
|
||||
assert_equal 1, result[4], "The new version should be 1"
|
||||
|
||||
# Finally check that the node that was saved has saved the data correctly
|
||||
|
||||
# Finally check that the node that was saved has saved the data correctly
|
||||
# in both the current and history tables
|
||||
# First check the current table
|
||||
current_node = Node.find(result[3].to_i)
|
||||
|
@ -524,7 +524,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
assert_equal({ "key" => "value", "ping" => "pong" }, first_historic_node.tags, "tags are different")
|
||||
assert_equal result[4], first_historic_node.version, "The version returned, is different to the one returned by the amf"
|
||||
end
|
||||
|
||||
|
||||
# try creating a POI with rubbish in the tags
|
||||
def test_putpoi_create_with_control_chars
|
||||
# This node has no tags
|
||||
|
@ -534,24 +534,24 @@ class AmfControllerTest < ActionController::TestCase
|
|||
lon = rand(100)-50 + rand
|
||||
# normal user has a changeset open
|
||||
changeset = changesets(:public_user_first_change)
|
||||
|
||||
|
||||
mostly_invalid = (0..31).to_a.map {|i| i.chr}.join
|
||||
tags = { "something" => "foo#{mostly_invalid}bar" }
|
||||
|
||||
|
||||
amf_content "putpoi", "/1", ["test@example.com:test", changeset.id, nil, nil, lon, lat, tags, nil]
|
||||
post :amf_write
|
||||
assert_response :success
|
||||
amf_parse_response
|
||||
result = amf_result("/1")
|
||||
|
||||
|
||||
# check the array returned by the amf
|
||||
assert_equal 5, result.size
|
||||
assert_equal 0, result[0], "Expected to get the status ok in the amf"
|
||||
assert_equal 0, result[2], "The old id should be 0"
|
||||
assert result[3] > 0, "The new id should be greater than 0"
|
||||
assert_equal 1, result[4], "The new version should be 1"
|
||||
|
||||
# Finally check that the node that was saved has saved the data correctly
|
||||
|
||||
# Finally check that the node that was saved has saved the data correctly
|
||||
# in both the current and history tables
|
||||
# First check the current table
|
||||
current_node = Node.find(result[3].to_i)
|
||||
|
@ -569,10 +569,10 @@ class AmfControllerTest < ActionController::TestCase
|
|||
lon = rand(100)-50 + rand
|
||||
# normal user has a changeset open
|
||||
changeset = changesets(:public_user_first_change)
|
||||
|
||||
|
||||
invalid = "\xc0\xc0"
|
||||
tags = { "something" => "foo#{invalid}bar" }
|
||||
|
||||
|
||||
amf_content "putpoi", "/1", ["test@example.com:test", changeset.id, nil, nil, lon, lat, tags, nil]
|
||||
post :amf_write
|
||||
assert_response :success
|
||||
|
@ -581,29 +581,29 @@ class AmfControllerTest < ActionController::TestCase
|
|||
|
||||
assert_equal 2, result.size
|
||||
assert_equal -1, result[0], "Expected to get the status FAIL in the amf"
|
||||
assert_equal "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1.", result[1]
|
||||
assert_equal "One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1.", result[1]
|
||||
end
|
||||
|
||||
|
||||
def test_putpoi_delete_valid
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def test_putpoi_delete_already_deleted
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def test_putpoi_delete_not_found
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
def test_putpoi_invalid_latlon
|
||||
|
||||
|
||||
end
|
||||
|
||||
def test_startchangeset_invalid_xmlchar_comment
|
||||
invalid = "\035\022"
|
||||
comment = "foo#{invalid}bar"
|
||||
|
||||
|
||||
amf_content "startchangeset", "/1", ["test@example.com:test", Hash.new, nil, comment, 1]
|
||||
post :amf_write
|
||||
assert_response :success
|
||||
|
@ -691,7 +691,7 @@ class AmfControllerTest < ActionController::TestCase
|
|||
yield map, bbox
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# this should be what AMF controller returns when the bbox of a
|
||||
# whichways request is invalid or too large.
|
||||
def assert_boundary_error(map, msg=nil, error_hint=nil)
|
||||
|
|
|
@ -3,16 +3,16 @@ require 'api_controller'
|
|||
|
||||
class ApiControllerTest < ActionController::TestCase
|
||||
api_fixtures
|
||||
|
||||
|
||||
def setup
|
||||
super
|
||||
@badbigbbox = %w{ -0.1,-0.1,1.1,1.1 10,10,11,11 }
|
||||
@badmalformedbbox = %w{ -0.1 hello
|
||||
@badmalformedbbox = %w{ -0.1 hello
|
||||
10N2W10.1N2.1W }
|
||||
@badlatmixedbbox = %w{ 0,0.1,0.1,0 -0.1,80,0.1,70 0.24,54.34,0.25,54.33 }
|
||||
@badlonmixedbbox = %w{ 80,-0.1,70,0.1 54.34,0.24,54.33,0.25 }
|
||||
@badlonmixedbbox = %w{ 80,-0.1,70,0.1 54.34,0.24,54.33,0.25 }
|
||||
#@badlatlonoutboundsbbox = %w{ 191,-0.1,193,0.1 -190.1,89.9,-190,90 }
|
||||
@goodbbox = %w{ -0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0
|
||||
@goodbbox = %w{ -0.1,-0.1,0.1,0.1 51.1,-0.1,51.2,0
|
||||
-0.1,%20-0.1,%200.1,%200.1 -0.1edcd,-0.1d,0.1,0.1 -0.1E,-0.1E,0.1S,0.1N S0.1,W0.1,N0.1,E0.1}
|
||||
# That last item in the goodbbox really shouldn't be there, as the API should
|
||||
# reall reject it, however this is to test to see if the api changes.
|
||||
|
@ -26,7 +26,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
{ :controller => "api", :action => "capabilities" }
|
||||
)
|
||||
assert_recognizes(
|
||||
{ :controller => "api", :action => "capabilities" },
|
||||
{ :controller => "api", :action => "capabilities" },
|
||||
{ :path => "/api/0.6/capabilities", :method => :get }
|
||||
)
|
||||
assert_routing(
|
||||
|
@ -75,7 +75,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
# Should also test for the ways and relation
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# This differs from the above test in that we are making the bbox exactly
|
||||
# the same as the node we are looking at
|
||||
def test_map_inclusive
|
||||
|
@ -92,7 +92,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
# Should also test for the ways and relation
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_tracepoints
|
||||
point = gpx_files(:public_trace_file)
|
||||
minlon = point.longitude-0.001
|
||||
|
@ -108,7 +108,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_tracepoints_trackable
|
||||
point = gpx_files(:trackable_trace_file)
|
||||
minlon = point.longitude-0.002
|
||||
|
@ -130,7 +130,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_tracepoints_identifiable
|
||||
point = gpx_files(:identifiable_trace_file)
|
||||
minlon = point.longitude-0.002
|
||||
|
@ -153,7 +153,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_map_without_bbox
|
||||
["trackpoints", "map"].each do |tq|
|
||||
get tq
|
||||
|
@ -161,7 +161,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
assert_equal "The parameter bbox is required, and must be of the form min_lon,min_lat,max_lon,max_lat", @response.body, "A bbox param was expected"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_traces_page_less_than_0
|
||||
-10.upto(-1) do |i|
|
||||
get :trackpoints, :page => i, :bbox => "-0.1,-0.1,0.1,0.1"
|
||||
|
@ -173,7 +173,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
assert_response :success, "The page number was #{i} and should have been accepted"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_bbox_too_big
|
||||
@badbigbbox.each do |bbox|
|
||||
[ "trackpoints", "map" ].each do |tq|
|
||||
|
@ -183,7 +183,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_bbox_malformed
|
||||
@badmalformedbbox.each do |bbox|
|
||||
[ "trackpoints", "map" ].each do |tq|
|
||||
|
@ -193,7 +193,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_bbox_lon_mixedup
|
||||
@badlonmixedbbox.each do |bbox|
|
||||
[ "trackpoints", "map" ].each do |tq|
|
||||
|
@ -203,7 +203,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_bbox_lat_mixedup
|
||||
@badlatmixedbbox.each do |bbox|
|
||||
["trackpoints", "map"].each do |tq|
|
||||
|
@ -213,7 +213,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# We can't actually get an out of bounds error, as the bbox is sanitised.
|
||||
#def test_latlon_outofbounds
|
||||
# @badlatlonoutboundsbbox.each do |bbox|
|
||||
|
@ -225,8 +225,8 @@ class ApiControllerTest < ActionController::TestCase
|
|||
# end
|
||||
# end
|
||||
#end
|
||||
|
||||
# MySQL and Postgres require that the C based functions are installed for
|
||||
|
||||
# MySQL and Postgres require that the C based functions are installed for
|
||||
# this test to work. More information is available from:
|
||||
# http://wiki.openstreetmap.org/wiki/Rails#Installing_the_quadtile_functions
|
||||
# or by looking at the readme in db/README
|
||||
|
@ -235,7 +235,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
get :changes
|
||||
assert_response :success
|
||||
#print @response.body
|
||||
# As we have loaded the fixtures, we can assume that there are no
|
||||
# As we have loaded the fixtures, we can assume that there are no
|
||||
# changes at the time we have frozen at
|
||||
now = Time.now.getutc
|
||||
hourago = now - 1.hour
|
||||
|
@ -244,7 +244,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
|
||||
def test_changes_zoom_invalid
|
||||
zoom_to_test = %w{ p -1 0 17 one two }
|
||||
zoom_to_test.each do |zoom|
|
||||
|
@ -253,7 +253,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
assert_equal @response.body, "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_changes_zoom_valid
|
||||
1.upto(16) do |zoom|
|
||||
get :changes, :zoom => zoom
|
||||
|
@ -265,7 +265,7 @@ class ApiControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_hours_invalid
|
||||
invalid = %w{ -21 335 -1 0 25 26 100 one two three ping pong : }
|
||||
invalid.each do |hour|
|
||||
|
@ -274,14 +274,14 @@ class ApiControllerTest < ActionController::TestCase
|
|||
assert_equal @response.body, "Requested zoom is invalid, or the supplied start is after the end time, or the start duration is more than 24 hours", "Problem with the hour: #{hour}."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_hours_valid
|
||||
1.upto(24) do |hour|
|
||||
get :changes, :hours => hour
|
||||
assert_response :success
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_capabilities
|
||||
get :capabilities
|
||||
assert_response :success
|
||||
|
|
|
@ -1922,7 +1922,7 @@ EOF
|
|||
assert_no_difference('ChangesetComment.count') do
|
||||
post :comment, { :id => changesets(:normal_user_closed_change).id, :text => '' }
|
||||
end
|
||||
assert_response :bad_request
|
||||
assert_response :bad_request
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -2062,7 +2062,7 @@ EOF
|
|||
post :unhide_comment, { :id => comment.id }
|
||||
assert_response :unauthorized
|
||||
end
|
||||
|
||||
|
||||
basic_authorization(users(:public_user).email, 'test')
|
||||
|
||||
# not a moderator
|
||||
|
|
|
@ -89,12 +89,12 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
get :new
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :user, :action => "login", :referer => "/diary/new"
|
||||
# Now pretend to login by using the session hash, with the
|
||||
# Now pretend to login by using the session hash, with the
|
||||
# id of the person we want to login as through session(:user)=user.id
|
||||
get(:new, nil, {'user' => users(:normal_user).id})
|
||||
assert_response :success
|
||||
#print @response.body
|
||||
|
||||
|
||||
#print @response.to_yaml
|
||||
assert_select "title", :text => /New Diary Entry/, :count => 1
|
||||
assert_select "div.content-heading", :count => 1 do
|
||||
|
@ -112,16 +112,16 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_editing_diary_entry
|
||||
entry = diary_entries(:normal_user_entry_1)
|
||||
|
||||
# Make sure that you are redirected to the login page when you are
|
||||
# Make sure that you are redirected to the login page when you are
|
||||
# not logged in, without and with the id of the entry you want to edit
|
||||
get :edit, :display_name => entry.user.display_name, :id => entry.id
|
||||
assert_response :redirect
|
||||
assert_redirected_to :controller => :user, :action => "login", :referer => "/user/#{entry.user.display_name}/diary/#{entry.id}/edit"
|
||||
|
||||
|
||||
# Verify that you get a not found error, when you pass a bogus id
|
||||
get(:edit, {:display_name => entry.user.display_name, :id => 9999}, {'user' => entry.user.id})
|
||||
assert_response :not_found
|
||||
|
@ -129,7 +129,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_select "h2", :text => "No entry with the id: 9999", :count => 1
|
||||
end
|
||||
|
||||
# Now pass the id, and check that you can edit it, when using the same
|
||||
# Now pass the id, and check that you can edit it, when using the same
|
||||
# user as the person who created the entry
|
||||
get(:edit, {:display_name => entry.user.display_name, :id => entry.id}, {'user' => entry.user.id})
|
||||
assert_response :success
|
||||
|
@ -157,13 +157,13 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
new_latitude = "1.1"
|
||||
new_longitude = "2.2"
|
||||
new_language_code = "en"
|
||||
post(:edit, {:display_name => entry.user.display_name, :id => entry.id, 'commit' => 'save',
|
||||
post(:edit, {:display_name => entry.user.display_name, :id => entry.id, 'commit' => 'save',
|
||||
'diary_entry'=>{'title' => new_title, 'body' => new_body, 'latitude' => new_latitude,
|
||||
'longitude' => new_longitude, 'language_code' => new_language_code} },
|
||||
{'user' => entry.user.id})
|
||||
assert_response :redirect
|
||||
assert_redirected_to :action => :view, :display_name => entry.user.display_name, :id => entry.id
|
||||
|
||||
|
||||
# Now check that the new data is rendered, when logged in
|
||||
get :view, {:display_name => entry.user.display_name, :id => entry.id}, {'user' => entry.user.id}
|
||||
assert_response :success
|
||||
|
@ -203,13 +203,13 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_edit_diary_entry_i18n
|
||||
get :edit, {:display_name => users(:normal_user).display_name, :id => diary_entries(:normal_user_entry_1).id}, {'user' => users(:normal_user).id}
|
||||
assert_response :success
|
||||
assert_select "span[class=translation_missing]", false, "Missing translation in edit diary entry"
|
||||
end
|
||||
|
||||
|
||||
def test_create_diary_entry
|
||||
# Make sure that you are redirected to the login page when you
|
||||
# are not logged in
|
||||
|
@ -245,7 +245,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
new_longitude = "2.2"
|
||||
new_language_code = "en"
|
||||
assert_difference "DiaryEntry.count", 1 do
|
||||
post(:new, {'commit' => 'save',
|
||||
post(:new, {'commit' => 'save',
|
||||
'diary_entry'=>{'title' => new_title, 'body' => new_body, 'latitude' => new_latitude,
|
||||
'longitude' => new_longitude, 'language_code' => new_language_code} },
|
||||
{:user => users(:normal_user).id})
|
||||
|
@ -260,14 +260,14 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_equal new_longitude.to_f, entry.longitude
|
||||
assert_equal new_language_code, entry.language_code
|
||||
end
|
||||
|
||||
|
||||
def test_creating_diary_comment
|
||||
entry = diary_entries(:normal_user_entry_1)
|
||||
|
||||
# Make sure that you are denied when you are not logged in
|
||||
post :comment, :display_name => entry.user.display_name, :id => entry.id
|
||||
assert_response :forbidden
|
||||
|
||||
|
||||
# Verify that you get a not found error, when you pass a bogus id
|
||||
post :comment, {:display_name => entry.user.display_name, :id => 9999}, {:user => users(:public_user).id}
|
||||
assert_response :not_found
|
||||
|
@ -304,7 +304,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_select ".richtext", :text => /New comment/, :count => 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Check that you can get the expected response and template for all available languages
|
||||
# Should test that there are no <span class="translation_missing">
|
||||
def test_listing_diary_entries
|
||||
|
@ -312,14 +312,14 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_response :success, "Should be able to list the diary entries in locale"
|
||||
assert_template 'list', "Should use the list template in locale"
|
||||
assert_select "span[class=translation_missing]", false, "Missing translation in list of diary entries"
|
||||
|
||||
|
||||
# Now try to find a specific user's diary entry
|
||||
get :list, {:display_name => users(:normal_user).display_name}
|
||||
assert_response :success, "Should be able to list the diary entries for a user in locale"
|
||||
assert_template 'list', "Should use the list template for a user in locale"
|
||||
assert_no_missing_translations
|
||||
end
|
||||
|
||||
|
||||
def test_rss
|
||||
get :rss, {:format => :rss}
|
||||
assert_response :success, "Should be able to get a diary RSS"
|
||||
|
@ -331,13 +331,13 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_rss_language
|
||||
get :rss, {:language => diary_entries(:normal_user_entry_1).language_code, :format => :rss}
|
||||
assert_response :success, "Should be able to get a specific language diary RSS"
|
||||
assert_select "rss>channel>item", :count => 1 #, "Diary entries should be filtered by language"
|
||||
end
|
||||
|
||||
|
||||
# def test_rss_nonexisting_language
|
||||
# get :rss, {:language => 'xx', :format => :rss}
|
||||
# assert_response :not_found, "Should not be able to get a nonexisting language diary RSS"
|
||||
|
@ -354,7 +354,7 @@ class DiaryEntryControllerTest < ActionController::TestCase
|
|||
assert_response :success, "Should be able to get a specific users diary RSS"
|
||||
assert_select "rss>channel>item", :count => 2 #, "Diary entries should be filtered by user"
|
||||
end
|
||||
|
||||
|
||||
def test_rss_nonexisting_user
|
||||
# Try a user that has never existed
|
||||
get :rss, {:display_name => 'fakeUsername76543', :format => :rss}
|
||||
|
|
|
@ -22,7 +22,7 @@ class ExportControllerTest < ActionController::TestCase
|
|||
assert_response :redirect
|
||||
assert_redirected_to "http://api.openstreetmap.org/api/#{API_VERSION}/map?bbox=0.0,50.0,1.0,51.0"
|
||||
end
|
||||
|
||||
|
||||
###
|
||||
# test the finish action for mapnik images
|
||||
def test_finish_mapnik
|
||||
|
|
|
@ -31,7 +31,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
def test_create
|
||||
# cannot read password from fixture as it is stored as MD5 digest
|
||||
## First try with no auth
|
||||
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100)-50 + rand
|
||||
lon = rand(100)-50 + rand
|
||||
|
@ -45,11 +45,11 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# hope for unauthorized
|
||||
assert_response :unauthorized, "node upload did not return unauthorized status"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Now try with the user which doesn't have their data public
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100)-50 + rand
|
||||
lon = rand(100)-50 + rand
|
||||
|
@ -64,10 +64,10 @@ class NodeControllerTest < ActionController::TestCase
|
|||
assert_require_public_data "node create did not return forbidden status"
|
||||
|
||||
|
||||
|
||||
|
||||
## Now try with the user that has the public data
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
|
||||
# create a node with random lat/lon
|
||||
lat = rand(100)-50 + rand
|
||||
lon = rand(100)-50 + rand
|
||||
|
@ -99,7 +99,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
changeset = changesets(:public_user_first_change)
|
||||
lat = 3.434
|
||||
lon = 3.23
|
||||
|
||||
|
||||
# test that the upload is rejected when xml is valid, but osm doc isn't
|
||||
content("<create/>")
|
||||
put :create
|
||||
|
@ -166,10 +166,10 @@ class NodeControllerTest < ActionController::TestCase
|
|||
## first try to delete node without auth
|
||||
delete :delete, :id => current_nodes(:visible_node).id
|
||||
assert_response :unauthorized
|
||||
|
||||
|
||||
|
||||
|
||||
## now set auth for the non-data public user
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
|
||||
# try to delete with an invalid (closed) changeset
|
||||
content update_changeset(current_nodes(:visible_node).to_xml,
|
||||
|
@ -209,10 +209,10 @@ class NodeControllerTest < ActionController::TestCase
|
|||
assert_require_public_data
|
||||
"shouldn't be able to delete a node used in a relation (#{@response.body})"
|
||||
|
||||
|
||||
|
||||
|
||||
## now set auth for the public data user
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
|
||||
# try to delete with an invalid (closed) changeset
|
||||
content update_changeset(current_nodes(:visible_node).to_xml,
|
||||
|
@ -228,13 +228,13 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# try to delete a node with a different ID
|
||||
content(nodes(:public_visible_node).to_xml)
|
||||
delete :delete, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"should not be able to delete a node with a different ID from the XML"
|
||||
|
||||
# try to delete a node rubbish in the payloads
|
||||
content("<delete/>")
|
||||
delete :delete, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"should not be able to delete a node without a valid XML payload"
|
||||
|
||||
# valid delete now takes a payload
|
||||
|
@ -282,11 +282,11 @@ class NodeControllerTest < ActionController::TestCase
|
|||
content current_nodes(:visible_node).to_xml
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :unauthorized
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Second test with the private user
|
||||
|
||||
|
||||
# setup auth
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
|
||||
|
@ -317,7 +317,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', -91.0);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lat=-91 should be forbidden, when data isn't public"
|
||||
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', 181.0);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lon=181 should be forbidden, when data isn't public"
|
||||
|
@ -325,20 +325,20 @@ class NodeControllerTest < ActionController::TestCase
|
|||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', -181.0);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_require_public_data "node at lon=-181 should be forbidden, when data isn't public"
|
||||
|
||||
|
||||
## finally, produce a good request which should work
|
||||
content current_nodes(:visible_node).to_xml
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
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 delete node without auth
|
||||
content current_nodes(:visible_node).to_xml
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :forbidden
|
||||
|
||||
|
||||
# setup auth
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
|
@ -369,7 +369,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lat', -91.0);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request, "node at lat=-91 should be rejected"
|
||||
|
||||
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml, 'lon', 181.0);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request, "node at lon=181 should be rejected"
|
||||
|
@ -382,34 +382,34 @@ class NodeControllerTest < ActionController::TestCase
|
|||
current_node_version = current_nodes(:visible_node).version
|
||||
|
||||
# try and submit a version behind
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
'version', current_node_version - 1);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :conflict, "should have failed on old version number"
|
||||
|
||||
|
||||
# try and submit a version ahead
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
'version', current_node_version + 1);
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :conflict, "should have failed on skipped version number"
|
||||
|
||||
# try and submit total crap in the version field
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
content xml_attr_rewrite(current_nodes(:visible_node).to_xml,
|
||||
'version', 'p1r4t3s!');
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :conflict,
|
||||
assert_response :conflict,
|
||||
"should not be able to put 'p1r4at3s!' in the version field"
|
||||
|
||||
|
||||
## try an update with the wrong ID
|
||||
content current_nodes(:public_visible_node).to_xml
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"should not be able to update a node with a different ID from the XML"
|
||||
|
||||
## try an update with a minimal valid XML doc which isn't a well-formed OSM doc.
|
||||
content "<update/>"
|
||||
put :update, :id => current_nodes(:visible_node).id
|
||||
assert_response :bad_request,
|
||||
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
|
||||
|
@ -464,7 +464,7 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content node_xml
|
||||
put :update, :id => current_nodes(:public_visible_node).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"adding duplicate tags to a node should fail with 'bad request'"
|
||||
assert_equal "Element node/#{current_nodes(:public_visible_node).id} has duplicate tags with key #{current_node_tags(:t1).k}", @response.body
|
||||
end
|
||||
|
@ -475,20 +475,20 @@ class NodeControllerTest < ActionController::TestCase
|
|||
basic_authorization(users(:normal_user).email, "test")
|
||||
changeset_id = changesets(:normal_user_first_change).id
|
||||
|
||||
# try and put something into a string that the API might
|
||||
# try and put something into a string that the API might
|
||||
# use unquoted and therefore allow code injection...
|
||||
content "<osm><node lat='0' lon='0' changeset='#{changeset_id}'>" +
|
||||
'<tag k="#{@user.inspect}" v="0"/>' +
|
||||
'</node></osm>'
|
||||
put :create
|
||||
assert_require_public_data "Shouldn't be able to create with non-public user"
|
||||
|
||||
|
||||
|
||||
|
||||
## Then try with the public data user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
changeset_id = changesets(:public_user_first_change).id
|
||||
|
||||
# try and put something into a string that the API might
|
||||
# try and put something into a string that the API might
|
||||
# use unquoted and therefore allow code injection...
|
||||
content "<osm><node lat='0' lon='0' changeset='#{changeset_id}'>" +
|
||||
'<tag k="#{@user.inspect}" v="0"/>' +
|
||||
|
@ -500,13 +500,13 @@ class NodeControllerTest < ActionController::TestCase
|
|||
# find the node in the database
|
||||
checknode = Node.find(nodeid)
|
||||
assert_not_nil checknode, "node not found in data base after upload"
|
||||
|
||||
|
||||
# and grab it using the api
|
||||
get :read, :id => nodeid
|
||||
assert_response :success
|
||||
apinode = Node.from_xml(@response.body)
|
||||
assert_not_nil apinode, "downloaded node is nil, but shouldn't be"
|
||||
|
||||
|
||||
# check the tags are not corrupted
|
||||
assert_equal checknode.tags, apinode.tags
|
||||
assert apinode.tags.include?('#{@user.inspect}')
|
||||
|
|
|
@ -724,7 +724,7 @@ class NotesControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
get :feed, {:bbox => "1,1,1.2,1.2", :format => "rss"}
|
||||
assert_response :success
|
||||
assert_response :success
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_select "rss", :count => 1 do
|
||||
assert_select "channel", :count => 1 do
|
||||
|
@ -755,6 +755,6 @@ class NotesControllerTest < ActionController::TestCase
|
|||
assert_response :success
|
||||
|
||||
get :mine, {:display_name => "non-existent"}
|
||||
assert_response :not_found
|
||||
assert_response :not_found
|
||||
end
|
||||
end
|
||||
|
|
|
@ -89,8 +89,8 @@ class OauthClientsControllerTest < ActionController::TestCase
|
|||
}
|
||||
end
|
||||
assert_response :success
|
||||
assert_template "new"
|
||||
|
||||
assert_template "new"
|
||||
|
||||
assert_difference "ClientApplication.count", 1 do
|
||||
post :create, {
|
||||
:display_name => user.display_name,
|
||||
|
@ -161,7 +161,7 @@ class OauthClientsControllerTest < ActionController::TestCase
|
|||
assert_template "not_found"
|
||||
|
||||
put :update, {
|
||||
:display_name => user.display_name,
|
||||
:display_name => user.display_name,
|
||||
:id => client.id,
|
||||
:client_application => {
|
||||
:name => "New Name",
|
||||
|
@ -174,7 +174,7 @@ class OauthClientsControllerTest < ActionController::TestCase
|
|||
assert_template "edit"
|
||||
|
||||
put :update, {
|
||||
:display_name => user.display_name,
|
||||
:display_name => user.display_name,
|
||||
:id => client.id,
|
||||
:client_application => {
|
||||
:name => "New Name",
|
||||
|
|
|
@ -27,16 +27,16 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
|
||||
##
|
||||
# test the version call by submitting several revisions of a new node
|
||||
# to the API and ensuring that later calls to version return the
|
||||
# to the API and ensuring that later calls to version return the
|
||||
# matching versions of the object.
|
||||
#
|
||||
##
|
||||
# FIXME Move this test to being an integration test since it spans multiple controllers
|
||||
# FIXME Move this test to being an integration test since it spans multiple controllers
|
||||
def test_version
|
||||
## First try this with a non-public user
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
changeset_id = changesets(:normal_user_first_change).id
|
||||
|
||||
|
||||
# setup a simple XML node
|
||||
xml_doc = current_nodes(:visible_node).to_xml
|
||||
xml_node = xml_doc.find("//osm/node").first
|
||||
|
@ -50,7 +50,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
versions[xml_node['version']] = xml_doc.to_s
|
||||
|
||||
# randomly move the node about
|
||||
20.times do
|
||||
20.times do
|
||||
# move the node somewhere else
|
||||
xml_node['lat'] = precision(rand * 180 - 90).to_s
|
||||
xml_node['lon'] = precision(rand * 360 - 180).to_s
|
||||
|
@ -65,7 +65,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# add a bunch of random tags
|
||||
30.times do
|
||||
30.times do
|
||||
xml_tag = XML::Node.new("tag")
|
||||
xml_tag['k'] = random_string
|
||||
xml_tag['v'] = random_string
|
||||
|
@ -83,7 +83,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
|
||||
# probably should check that they didn't get written to the database
|
||||
|
||||
|
||||
|
||||
## Now do it with the public user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
changeset_id = changesets(:public_user_first_change).id
|
||||
|
@ -101,7 +101,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
versions[xml_node['version']] = xml_doc.to_s
|
||||
|
||||
# randomly move the node about
|
||||
20.times do
|
||||
20.times do
|
||||
# move the node somewhere else
|
||||
xml_node['lat'] = precision(rand * 180 - 90).to_s
|
||||
xml_node['lon'] = precision(rand * 360 - 180).to_s
|
||||
|
@ -116,7 +116,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
# add a bunch of random tags
|
||||
30.times do
|
||||
30.times do
|
||||
xml_tag = XML::Node.new("tag")
|
||||
xml_tag['k'] = random_string
|
||||
xml_tag['v'] = random_string
|
||||
|
@ -145,21 +145,21 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
assert_nodes_are_equal check_node, api_node
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_not_found_version
|
||||
check_not_found_id_version(70000,312344)
|
||||
check_not_found_id_version(-1, -13)
|
||||
check_not_found_id_version(nodes(:visible_node).id, 24354)
|
||||
check_not_found_id_version(24356, nodes(:visible_node).version)
|
||||
end
|
||||
|
||||
|
||||
def check_not_found_id_version(id, version)
|
||||
get :version, :id => id, :version => version
|
||||
assert_response :not_found
|
||||
rescue ActionController::UrlGenerationError => ex
|
||||
assert_match /No route matches/, ex.to_s
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# Test that getting the current version is identical to picking
|
||||
# that version with the version URI call.
|
||||
|
@ -181,7 +181,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the redaction of an old version of a node, while being
|
||||
# test the redaction of an old version of a node, while being
|
||||
# authorised as a normal user.
|
||||
def test_redact_node_normal_user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
@ -200,10 +200,10 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
do_redact_node(nodes(:node_with_versions_v4),
|
||||
redactions(:example))
|
||||
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# test that redacted nodes aren't visible, regardless of
|
||||
# test that redacted nodes aren't visible, regardless of
|
||||
# authorisation except as moderator...
|
||||
def test_version_redacted
|
||||
node = nodes(:redacted_node_redacted_version)
|
||||
|
@ -234,7 +234,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the redaction of an old version of a node, while being
|
||||
# test the redaction of an old version of a node, while being
|
||||
# authorised as a moderator.
|
||||
def test_redact_node_moderator
|
||||
node = nodes(:node_with_versions_v3)
|
||||
|
@ -249,7 +249,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
|
||||
get :version, :id => node.node_id, :version => node.version, :show_redactions => 'true'
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => node.node_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
|
@ -274,7 +274,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
# check can't see the redacted data
|
||||
get :version, :id => node.node_id, :version => node.version
|
||||
assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
|
||||
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => node.node_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
|
@ -284,7 +284,7 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
def do_redact_node(node, redaction)
|
||||
get :version, :id => node.node_id, :version => node.version
|
||||
assert_response :success, "should be able to get version #{node.version} of node #{node.node_id}."
|
||||
|
||||
|
||||
# now redact it
|
||||
post :redact, :id => node.node_id, :version => node.version, :redaction => redaction.id
|
||||
end
|
||||
|
@ -293,14 +293,14 @@ class OldNodeControllerTest < ActionController::TestCase
|
|||
# get the current version of the node
|
||||
current_node = with_controller(NodeController.new) do
|
||||
get :read, :id => node_id
|
||||
assert_response :success, "cant get current node #{node_id}"
|
||||
assert_response :success, "cant get current node #{node_id}"
|
||||
Node.from_xml(@response.body)
|
||||
end
|
||||
assert_not_nil current_node, "getting node #{node_id} returned nil"
|
||||
|
||||
# get the "old" version of the node from the old_node interface
|
||||
get :version, :id => node_id, :version => current_node.version
|
||||
assert_response :success, "cant get old node #{node_id}, v#{current_node.version}"
|
||||
assert_response :success, "cant get old node #{node_id}, v#{current_node.version}"
|
||||
old_node = Node.from_xml(@response.body)
|
||||
|
||||
# check the nodes are the same
|
||||
|
|
|
@ -44,7 +44,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the redaction of an old version of a relation, while being
|
||||
# test the redaction of an old version of a relation, while being
|
||||
# authorised as a normal user.
|
||||
def test_redact_relation_normal_user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
@ -63,10 +63,10 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
do_redact_relation(relations(:relation_with_versions_v4),
|
||||
redactions(:example))
|
||||
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# test that redacted relations aren't visible, regardless of
|
||||
# test that redacted relations aren't visible, regardless of
|
||||
# authorisation except as moderator...
|
||||
def test_version_redacted
|
||||
relation = relations(:relation_with_redacted_versions_v2)
|
||||
|
@ -98,7 +98,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the redaction of an old version of a relation, while being
|
||||
# test the redaction of an old version of a relation, while being
|
||||
# authorised as a moderator.
|
||||
def test_redact_relation_moderator
|
||||
relation = relations(:relation_with_versions_v3)
|
||||
|
@ -113,7 +113,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
|
||||
get :version, :id => relation.relation_id, :version => relation.version, :show_redactions => 'true'
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => relation.relation_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
|
@ -138,7 +138,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
# check can't see the redacted data
|
||||
get :version, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
|
||||
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => relation.relation_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
|
@ -183,7 +183,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
assert_response :success, "couldn't get relation #{relation_id}, v#{history_relation.version}"
|
||||
version_relation = Relation.from_xml(@response.body)
|
||||
assert_not_nil version_relation, "failed to parse #{relation_id}, v#{history_relation.version}"
|
||||
|
||||
|
||||
assert_relations_are_equal history_relation, version_relation
|
||||
end
|
||||
end
|
||||
|
@ -191,7 +191,7 @@ class OldRelationControllerTest < ActionController::TestCase
|
|||
def do_redact_relation(relation, redaction)
|
||||
get :version, :id => relation.relation_id, :version => relation.version
|
||||
assert_response :success, "should be able to get version #{relation.version} of node #{relation.relation_id}."
|
||||
|
||||
|
||||
# now redact it
|
||||
post :redact, :id => relation.relation_id, :version => relation.version, :redaction => redaction.id
|
||||
end
|
||||
|
|
|
@ -30,19 +30,19 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
get :history, :id => ways(:visible_way).way_id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
def test_history_invisible
|
||||
# check that an invisible way's history is returned properly
|
||||
get :history, :id => ways(:invisible_way).way_id
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
|
||||
def test_history_invalid
|
||||
# check chat a non-existent way is not returned
|
||||
get :history, :id => 0
|
||||
assert_response :not_found
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# check that we can retrieve versions of a way
|
||||
def test_version
|
||||
|
@ -52,7 +52,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# check that returned history is the same as getting all
|
||||
# check that returned history is the same as getting all
|
||||
# versions of a way from the api.
|
||||
def test_history_equals_versions
|
||||
check_history_equals_versions(current_ways(:visible_way).id)
|
||||
|
@ -70,7 +70,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the redaction of an old version of a way, while being
|
||||
# test the redaction of an old version of a way, while being
|
||||
# authorised as a normal user.
|
||||
def test_redact_way_normal_user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
@ -89,10 +89,10 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
do_redact_way(ways(:way_with_versions_v4),
|
||||
redactions(:example))
|
||||
assert_response :bad_request, "shouldn't be OK to redact current version as moderator."
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
# test that redacted ways aren't visible, regardless of
|
||||
# test that redacted ways aren't visible, regardless of
|
||||
# authorisation except as moderator...
|
||||
def test_version_redacted
|
||||
way = ways(:way_with_redacted_versions_v2)
|
||||
|
@ -124,7 +124,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
end
|
||||
|
||||
##
|
||||
# test the redaction of an old version of a way, while being
|
||||
# test the redaction of an old version of a way, while being
|
||||
# authorised as a moderator.
|
||||
def test_redact_way_moderator
|
||||
way = ways(:way_with_versions_v3)
|
||||
|
@ -139,7 +139,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
assert_response :forbidden, "After redaction, node should be gone for moderator, when flag not passed."
|
||||
get :version, :id => way.way_id, :version => way.version, :show_redactions => 'true'
|
||||
assert_response :success, "After redaction, node should not be gone for moderator, when flag passed."
|
||||
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => way.way_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
|
@ -164,7 +164,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
# check can't see the redacted data
|
||||
get :version, :id => way.way_id, :version => way.version
|
||||
assert_response :forbidden, "Redacted node shouldn't be visible via the version API."
|
||||
|
||||
|
||||
# and when accessed via history
|
||||
get :history, :id => way.way_id
|
||||
assert_response :success, "Redaction shouldn't have stopped history working."
|
||||
|
@ -209,7 +209,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
assert_response :success, "couldn't get way #{way_id}, v#{history_way.version}"
|
||||
version_way = Way.from_xml(@response.body)
|
||||
assert_not_nil version_way, "failed to parse #{way_id}, v#{history_way.version}"
|
||||
|
||||
|
||||
assert_ways_are_equal history_way, version_way
|
||||
end
|
||||
end
|
||||
|
@ -217,7 +217,7 @@ class OldWayControllerTest < ActionController::TestCase
|
|||
def do_redact_way(way, redaction)
|
||||
get :version, :id => way.way_id, :version => way.version
|
||||
assert_response :success, "should be able to get version #{way.version} of node #{way.way_id}."
|
||||
|
||||
|
||||
# now redact it
|
||||
post :redact, :id => way.way_id, :version => way.version, :redaction => redaction.id
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
# check that all relations containing a particular node, and no extra
|
||||
# relations, are returned from the relations_for_node call.
|
||||
def test_relations_for_node
|
||||
check_relations_for_element(:relations_for_node, "node",
|
||||
check_relations_for_element(:relations_for_node, "node",
|
||||
current_nodes(:node_used_by_relationship).id,
|
||||
[ :visible_relation, :used_relation ])
|
||||
end
|
||||
|
@ -146,7 +146,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
|
||||
def test_create
|
||||
basic_authorization users(:normal_user).email, "test"
|
||||
|
||||
|
||||
# put the relation in a dummy fixture changset
|
||||
changeset_id = changesets(:normal_user_first_change).id
|
||||
|
||||
|
@ -154,7 +154,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
content "<osm><relation changeset='#{changeset_id}'><tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for forbidden, due to user
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"relation upload should have failed with forbidden"
|
||||
|
||||
###
|
||||
|
@ -166,11 +166,11 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for forbidden due to user
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"relation upload did not return forbidden status"
|
||||
|
||||
|
||||
###
|
||||
# create an relation with a node as member, this time test that we don't
|
||||
# create an relation with a node as member, this time test that we don't
|
||||
# need a role attribute to be included
|
||||
nid = current_nodes(:used_node_1).id
|
||||
content "<osm><relation changeset='#{changeset_id}'>" +
|
||||
|
@ -178,7 +178,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for forbidden due to user
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"relation upload did not return forbidden status"
|
||||
|
||||
###
|
||||
|
@ -191,14 +191,14 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for forbidden, due to user
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"relation upload did not return success status"
|
||||
|
||||
|
||||
|
||||
## Now try with the public user
|
||||
basic_authorization users(:public_user).email, "test"
|
||||
|
||||
|
||||
# put the relation in a dummy fixture changset
|
||||
changeset_id = changesets(:public_user_first_change).id
|
||||
|
||||
|
@ -206,23 +206,23 @@ class RelationControllerTest < ActionController::TestCase
|
|||
content "<osm><relation changeset='#{changeset_id}'><tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
assert_response :success,
|
||||
assert_response :success,
|
||||
"relation upload did not return success status"
|
||||
# read id of created relation and search for it
|
||||
relationid = @response.body
|
||||
checkrelation = Relation.find(relationid)
|
||||
assert_not_nil checkrelation,
|
||||
assert_not_nil checkrelation,
|
||||
"uploaded relation not found in data base after upload"
|
||||
# compare values
|
||||
assert_equal checkrelation.members.length, 0,
|
||||
assert_equal checkrelation.members.length, 0,
|
||||
"saved relation contains members but should not"
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
"saved relation does not contain exactly one tag"
|
||||
assert_equal changeset_id, checkrelation.changeset.id,
|
||||
"saved relation does not belong in the changeset it was assigned to"
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
"saved relation does not belong to user that created it"
|
||||
assert_equal true, checkrelation.visible,
|
||||
assert_equal true, checkrelation.visible,
|
||||
"saved relation is not visible"
|
||||
# ok the relation is there but can we also retrieve it?
|
||||
get :read, :id => relationid
|
||||
|
@ -238,32 +238,32 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
assert_response :success,
|
||||
assert_response :success,
|
||||
"relation upload did not return success status"
|
||||
# read id of created relation and search for it
|
||||
relationid = @response.body
|
||||
checkrelation = Relation.find(relationid)
|
||||
assert_not_nil checkrelation,
|
||||
assert_not_nil checkrelation,
|
||||
"uploaded relation not found in data base after upload"
|
||||
# compare values
|
||||
assert_equal checkrelation.members.length, 1,
|
||||
assert_equal checkrelation.members.length, 1,
|
||||
"saved relation does not contain exactly one member"
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
"saved relation does not contain exactly one tag"
|
||||
assert_equal changeset_id, checkrelation.changeset.id,
|
||||
"saved relation does not belong in the changeset it was assigned to"
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
"saved relation does not belong to user that created it"
|
||||
assert_equal true, checkrelation.visible,
|
||||
assert_equal true, checkrelation.visible,
|
||||
"saved relation is not visible"
|
||||
# ok the relation is there but can we also retrieve it?
|
||||
|
||||
|
||||
get :read, :id => relationid
|
||||
assert_response :success
|
||||
|
||||
|
||||
|
||||
|
||||
###
|
||||
# create an relation with a node as member, this time test that we don't
|
||||
# create an relation with a node as member, this time test that we don't
|
||||
# need a role attribute to be included
|
||||
nid = current_nodes(:used_node_1).id
|
||||
content "<osm><relation changeset='#{changeset_id}'>" +
|
||||
|
@ -271,26 +271,26 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
assert_response :success,
|
||||
assert_response :success,
|
||||
"relation upload did not return success status"
|
||||
# read id of created relation and search for it
|
||||
relationid = @response.body
|
||||
checkrelation = Relation.find(relationid)
|
||||
assert_not_nil checkrelation,
|
||||
assert_not_nil checkrelation,
|
||||
"uploaded relation not found in data base after upload"
|
||||
# compare values
|
||||
assert_equal checkrelation.members.length, 1,
|
||||
assert_equal checkrelation.members.length, 1,
|
||||
"saved relation does not contain exactly one member"
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
"saved relation does not contain exactly one tag"
|
||||
assert_equal changeset_id, checkrelation.changeset.id,
|
||||
"saved relation does not belong in the changeset it was assigned to"
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
"saved relation does not belong to user that created it"
|
||||
assert_equal true, checkrelation.visible,
|
||||
assert_equal true, checkrelation.visible,
|
||||
"saved relation is not visible"
|
||||
# ok the relation is there but can we also retrieve it?
|
||||
|
||||
|
||||
get :read, :id => relationid
|
||||
assert_response :success
|
||||
|
||||
|
@ -304,23 +304,23 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></relation></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
assert_response :success,
|
||||
assert_response :success,
|
||||
"relation upload did not return success status"
|
||||
# read id of created relation and search for it
|
||||
relationid = @response.body
|
||||
checkrelation = Relation.find(relationid)
|
||||
assert_not_nil checkrelation,
|
||||
assert_not_nil checkrelation,
|
||||
"uploaded relation not found in data base after upload"
|
||||
# compare values
|
||||
assert_equal checkrelation.members.length, 2,
|
||||
assert_equal checkrelation.members.length, 2,
|
||||
"saved relation does not have exactly two members"
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
assert_equal checkrelation.tags.length, 1,
|
||||
"saved relation does not contain exactly one tag"
|
||||
assert_equal changeset_id, checkrelation.changeset.id,
|
||||
"saved relation does not belong in the changeset it was assigned to"
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
assert_equal users(:public_user).id, checkrelation.changeset.user_id,
|
||||
"saved relation does not belong to user that created it"
|
||||
assert_equal true, checkrelation.visible,
|
||||
assert_equal true, checkrelation.visible,
|
||||
"saved relation is not visible"
|
||||
# ok the relation is there but can we also retrieve it?
|
||||
get :read, :id => relationid
|
||||
|
@ -334,7 +334,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
|
||||
##
|
||||
# test that, when tags are updated on a relation, the correct things
|
||||
# happen to the correct tables and the API gives sensible results.
|
||||
# happen to the correct tables and the API gives sensible results.
|
||||
# this is to test a case that gregory marler noticed and posted to
|
||||
# josm-dev.
|
||||
## FIXME Move this to an integration test
|
||||
|
@ -364,8 +364,8 @@ class RelationControllerTest < ActionController::TestCase
|
|||
|
||||
##
|
||||
# test that, when tags are updated on a relation when using the diff
|
||||
# upload function, the correct things happen to the correct tables
|
||||
# and the API gives sensible results. this is to test a case that
|
||||
# upload function, the correct things happen to the correct tables
|
||||
# and the API gives sensible results. this is to test a case that
|
||||
# gregory marler noticed and posted to josm-dev.
|
||||
def test_update_relation_tags_via_upload
|
||||
basic_authorization users(:public_user).email, "test"
|
||||
|
@ -407,7 +407,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
"</relation></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :precondition_failed,
|
||||
assert_response :precondition_failed,
|
||||
"relation upload with invalid node did not return 'precondition failed'"
|
||||
assert_equal "Precondition failed: Relation with id cannot be saved due to Node with id 0", @response.body
|
||||
end
|
||||
|
@ -417,10 +417,10 @@ class RelationControllerTest < ActionController::TestCase
|
|||
# -------------------------------------
|
||||
def test_create_invalid_xml
|
||||
basic_authorization users(:public_user).email, "test"
|
||||
|
||||
|
||||
# put the relation in a dummy fixture changeset that works
|
||||
changeset_id = changesets(:public_user_first_change).id
|
||||
|
||||
|
||||
# create some xml that should return an error
|
||||
content "<osm><relation changeset='#{changeset_id}'>" +
|
||||
"<member type='type' ref='#{current_nodes(:used_node_1).id}' role=''/>" +
|
||||
|
@ -431,21 +431,21 @@ class RelationControllerTest < ActionController::TestCase
|
|||
assert_match(/Cannot parse valid relation from xml string/, @response.body)
|
||||
assert_match(/The type is not allowed only, /, @response.body)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
# -------------------------------------
|
||||
# Test deleting relations.
|
||||
# -------------------------------------
|
||||
|
||||
|
||||
def test_delete
|
||||
## First try to delete relation without auth
|
||||
delete :delete, :id => current_relations(:visible_relation).id
|
||||
assert_response :unauthorized
|
||||
|
||||
|
||||
|
||||
|
||||
## Then try with the private user, to make sure that you get a forbidden
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
|
||||
|
||||
# this shouldn't work, as we should need the payload...
|
||||
delete :delete, :id => current_relations(:visible_relation).id
|
||||
assert_response :forbidden
|
||||
|
@ -481,7 +481,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
delete :delete, :id => current_relations(:invisible_relation).id
|
||||
assert_response :forbidden
|
||||
|
||||
# this works now because the relation which was using this one
|
||||
# this works now because the relation which was using this one
|
||||
# has been deleted.
|
||||
content(relations(:used_relation).to_xml)
|
||||
delete :delete, :id => current_relations(:used_relation).id
|
||||
|
@ -491,10 +491,10 @@ class RelationControllerTest < ActionController::TestCase
|
|||
delete :delete, :id => 0
|
||||
assert_response :forbidden
|
||||
|
||||
|
||||
|
||||
|
||||
## now set auth for the public user
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
|
||||
# this shouldn't work, as we should need the payload...
|
||||
delete :delete, :id => current_relations(:visible_relation).id
|
||||
|
@ -520,7 +520,7 @@ class RelationControllerTest < ActionController::TestCase
|
|||
# this won't work because the relation is in a changeset owned by someone else
|
||||
content(relations(:used_relation).to_xml)
|
||||
delete :delete, :id => current_relations(:used_relation).id
|
||||
assert_response :conflict,
|
||||
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
|
||||
|
@ -528,11 +528,11 @@ class RelationControllerTest < ActionController::TestCase
|
|||
delete :delete, :id => current_relations(:used_relation).id
|
||||
assert_not_equal relations(:public_used_relation).id, current_relations(:used_relation).id
|
||||
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(relations(:public_used_relation).to_xml)
|
||||
delete :delete, :id => current_relations(:public_used_relation).id
|
||||
assert_response :precondition_failed,
|
||||
assert_response :precondition_failed,
|
||||
"shouldn't be able to delete a relation used in a relation (#{@response.body})"
|
||||
assert_equal "Precondition failed: The relation 5 is used in relation 6.", @response.body
|
||||
|
||||
|
@ -550,17 +550,17 @@ class RelationControllerTest < ActionController::TestCase
|
|||
content(relations(:invisible_relation).to_xml)
|
||||
delete :delete, :id => current_relations(:invisible_relation).id
|
||||
assert_response :gone
|
||||
|
||||
|
||||
# Public visible relation needs to be deleted
|
||||
content(relations(:public_visible_relation).to_xml)
|
||||
delete :delete, :id => current_relations(:public_visible_relation).id
|
||||
assert_response :success
|
||||
|
||||
# this works now because the relation which was using this one
|
||||
# this works now because the relation which was using this one
|
||||
# has been deleted.
|
||||
content(relations(:public_used_relation).to_xml)
|
||||
delete :delete, :id => current_relations(:public_used_relation).id
|
||||
assert_response :success,
|
||||
assert_response :success,
|
||||
"should be able to delete a relation used in an old relation (#{@response.body})"
|
||||
|
||||
# this won't work since the relation never existed
|
||||
|
@ -582,10 +582,10 @@ class RelationControllerTest < ActionController::TestCase
|
|||
new_tag['k'] = "some_new_tag"
|
||||
new_tag['v'] = "some_new_value"
|
||||
relation_element << new_tag
|
||||
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
update_changeset(relation_xml, changeset_id)
|
||||
|
||||
|
||||
# upload the change
|
||||
content relation_xml
|
||||
put :update, :id => current_relations(:visible_relation).id
|
||||
|
@ -613,25 +613,25 @@ class RelationControllerTest < ActionController::TestCase
|
|||
new_member['type'] = element.class.to_s.downcase
|
||||
new_member['role'] = "some_role"
|
||||
relation_element << new_member
|
||||
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
update_changeset(relation_xml, changeset_id)
|
||||
|
||||
|
||||
# upload the change
|
||||
content relation_xml
|
||||
put :update, :id => current_relations(:visible_relation).id
|
||||
assert_response :success, "can't update relation for add #{element.class}/bbox test: #{@response.body}"
|
||||
|
||||
# get it back and check the ordering
|
||||
# get it back and check the ordering
|
||||
get :read, :id => relation_id
|
||||
assert_response :success, "can't read back the relation: #{@response.body}"
|
||||
check_ordering(relation_xml, @response.body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# remove a member from a relation and check the bounding box is
|
||||
# remove a member from a relation and check the bounding box is
|
||||
# only that element.
|
||||
def test_remove_member_bounding_box
|
||||
check_changeset_modify(BoundingBox.new(5,5,5,5)) do |changeset_id|
|
||||
|
@ -640,22 +640,22 @@ class RelationControllerTest < ActionController::TestCase
|
|||
relation_xml.
|
||||
find("//osm/relation/member[@type='node'][@ref='5']").
|
||||
first.remove!
|
||||
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
update_changeset(relation_xml, changeset_id)
|
||||
|
||||
|
||||
# upload the change
|
||||
content relation_xml
|
||||
put :update, :id => current_relations(:visible_relation).id
|
||||
assert_response :success, "can't update relation for remove node/bbox test"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# check that relations are ordered
|
||||
def test_relation_member_ordering
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
|
||||
doc_str = <<OSM
|
||||
<osm>
|
||||
<relation changeset='4'>
|
||||
|
@ -707,7 +707,7 @@ OSM
|
|||
end
|
||||
end
|
||||
|
||||
##
|
||||
##
|
||||
# check that relations can contain duplicate members
|
||||
def test_relation_member_duplicates
|
||||
doc_str = <<OSM
|
||||
|
@ -723,14 +723,14 @@ OSM
|
|||
doc = XML::Parser.string(doc_str).parse
|
||||
|
||||
## First try with the private user
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
|
||||
content doc
|
||||
put :create
|
||||
assert_response :forbidden
|
||||
|
||||
## Now try with the public user
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
|
||||
content doc
|
||||
put :create
|
||||
|
@ -757,7 +757,7 @@ OSM
|
|||
</osm>
|
||||
OSM
|
||||
doc = XML::Parser.string(doc_str).parse
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
|
||||
content doc
|
||||
put :create
|
||||
|
@ -780,28 +780,28 @@ OSM
|
|||
##
|
||||
# remove all the members from a relation. the result is pretty useless, but
|
||||
# still technically valid.
|
||||
def test_remove_all_members
|
||||
def test_remove_all_members
|
||||
check_changeset_modify(BoundingBox.new(3,3,5,5)) do |changeset_id|
|
||||
relation_xml = current_relations(:visible_relation).to_xml
|
||||
relation_xml.
|
||||
find("//osm/relation/member").
|
||||
each {|m| m.remove!}
|
||||
|
||||
|
||||
# update changeset ID to point to new changeset
|
||||
update_changeset(relation_xml, changeset_id)
|
||||
|
||||
|
||||
# upload the change
|
||||
content relation_xml
|
||||
put :update, :id => current_relations(:visible_relation).id
|
||||
assert_response :success, "can't update relation for remove all members test"
|
||||
checkrelation = Relation.find(current_relations(:visible_relation).id)
|
||||
assert_not_nil(checkrelation,
|
||||
assert_not_nil(checkrelation,
|
||||
"uploaded relation not found in database after upload")
|
||||
assert_equal(0, checkrelation.members.length,
|
||||
"relation contains members but they should have all been deleted")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# ============================================================
|
||||
# utility functions
|
||||
# ============================================================
|
||||
|
@ -830,7 +830,7 @@ OSM
|
|||
# that the changeset bounding box is +bbox+.
|
||||
def check_changeset_modify(bbox)
|
||||
## First test with the private user to check that you get a forbidden
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
|
||||
# create a new changeset for this operation, so we are assured
|
||||
# that the bounding box will be newly-generated.
|
||||
|
@ -840,10 +840,10 @@ OSM
|
|||
assert_response :forbidden, "shouldn't be able to create changeset for modify test, as should get forbidden"
|
||||
end
|
||||
|
||||
|
||||
|
||||
## Now do the whole thing with the public user
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
||||
|
||||
# create a new changeset for this operation, so we are assured
|
||||
# that the bounding box will be newly-generated.
|
||||
changeset_id = with_controller(ChangesetController.new) do
|
||||
|
@ -886,8 +886,8 @@ OSM
|
|||
end
|
||||
|
||||
##
|
||||
# updates the relation (XML) +rel+ and
|
||||
# yields the new version of that relation into the block.
|
||||
# updates the relation (XML) +rel+ and
|
||||
# yields the new version of that relation into the block.
|
||||
# the parsed XML doc is retured.
|
||||
def with_update(rel)
|
||||
rel_id = rel.find("//osm/relation").first["id"].to_i
|
||||
|
@ -908,7 +908,7 @@ OSM
|
|||
|
||||
##
|
||||
# updates the relation (XML) +rel+ via the diff-upload API and
|
||||
# yields the new version of that relation into the block.
|
||||
# yields the new version of that relation into the block.
|
||||
# the parsed XML doc is retured.
|
||||
def with_update_diff(rel)
|
||||
rel_id = rel.find("//osm/relation").first["id"].to_i
|
||||
|
@ -927,29 +927,29 @@ OSM
|
|||
post :upload, :id => cs_id
|
||||
assert_response :success, "can't upload diff relation: #{@response.body}"
|
||||
version = xml_parse(@response.body).find("//diffResult/relation").first["new_version"].to_i
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# now get the new version
|
||||
get :read, :id => rel_id
|
||||
assert_response :success
|
||||
new_rel = xml_parse(@response.body)
|
||||
|
||||
|
||||
yield new_rel
|
||||
|
||||
|
||||
return version
|
||||
end
|
||||
|
||||
##
|
||||
# returns a k->v hash of tags from an xml doc
|
||||
def get_tags_as_hash(a)
|
||||
def get_tags_as_hash(a)
|
||||
a.find("//osm/relation/tag").sort_by { |v| v['k'] }.inject({}) do |h,v|
|
||||
h[v['k']] = v['v']
|
||||
h
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# assert that all tags on relation documents +a+ and +b+
|
||||
# assert that all tags on relation documents +a+ and +b+
|
||||
# are equal
|
||||
def assert_tags_equal(a, b)
|
||||
# turn the XML doc into tags hashes
|
||||
|
@ -958,7 +958,7 @@ OSM
|
|||
|
||||
assert_equal a_tags.keys, b_tags.keys, "Tag keys should be identical."
|
||||
a_tags.each do |k, v|
|
||||
assert_equal v, b_tags[k],
|
||||
assert_equal v, b_tags[k],
|
||||
"Tags which were not altered should be the same. " +
|
||||
"#{a_tags.inspect} != #{b_tags.inspect}"
|
||||
end
|
||||
|
|
|
@ -493,7 +493,7 @@ class TraceControllerTest < ActionController::TestCase
|
|||
basic_authorization(users(:normal_user).display_name, "test")
|
||||
content gpx_files(:anon_trace_file).to_xml
|
||||
put :api_update, :id => gpx_files(:public_trace_file).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"should not be able to update a trace with a different ID from the XML"
|
||||
|
||||
# And finally try an update that should work
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'test_helper'
|
|||
|
||||
class UserControllerTest < ActionController::TestCase
|
||||
fixtures :users
|
||||
|
||||
|
||||
##
|
||||
# test all routes which lead to this controller
|
||||
def test_routes
|
||||
|
@ -269,7 +269,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_template 'new'
|
||||
assert_select "form > fieldset > div.form-row > input.field_with_errors#user_email"
|
||||
end
|
||||
|
||||
|
||||
def test_user_create_submit_duplicate_name
|
||||
user = new_user
|
||||
user.display_name = users(:public_user).display_name
|
||||
|
@ -284,7 +284,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_template 'new'
|
||||
assert_select "form > fieldset > div.form-row > input.field_with_errors#user_display_name"
|
||||
end
|
||||
|
||||
|
||||
def test_user_create_submit_duplicate_name_uppercase
|
||||
user = new_user
|
||||
user.display_name = users(:public_user).display_name.upcase
|
||||
|
@ -556,14 +556,14 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_equal user.new_email, email.to.first
|
||||
ActionMailer::Base.deliveries.clear
|
||||
end
|
||||
|
||||
|
||||
# Check that the user account page will display and contains some relevant
|
||||
# information for the user
|
||||
def test_user_view_account
|
||||
# Test a non-existent user
|
||||
get :view, {:display_name => "unknown"}
|
||||
assert_response :not_found
|
||||
|
||||
|
||||
# Test a normal user
|
||||
get :view, {:display_name => "test"}
|
||||
assert_response :success
|
||||
|
@ -577,7 +577,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_select "a[href='/user/test/blocks_by']", 0
|
||||
assert_select "a[href='/blocks/new/test']", 0
|
||||
end
|
||||
|
||||
|
||||
# Test a user who has been blocked
|
||||
get :view, {:display_name => "blocked"}
|
||||
assert_response :success
|
||||
|
@ -591,7 +591,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
assert_select "a[href='/user/blocked/blocks_by']", 0
|
||||
assert_select "a[href='/blocks/new/blocked']", 0
|
||||
end
|
||||
|
||||
|
||||
# Test a moderator who has applied blocks
|
||||
get :view, {:display_name => "moderator"}
|
||||
assert_response :success
|
||||
|
@ -691,7 +691,7 @@ class UserControllerTest < ActionController::TestCase
|
|||
# check that nothing is returned when not logged in
|
||||
get :api_details
|
||||
assert_response :unauthorized
|
||||
|
||||
|
||||
# check that we get a response when logged in
|
||||
basic_authorization(users(:normal_user).email, "test")
|
||||
get :api_details
|
||||
|
|
|
@ -45,7 +45,7 @@ class UserPreferenceControllerTest < ActionController::TestCase
|
|||
assert_select "preference", :count => 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# authenticate as a user with preferences
|
||||
basic_authorization("test@openstreetmap.org", "test")
|
||||
|
||||
|
|
|
@ -65,11 +65,11 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# otherwise it should say success
|
||||
assert_response :success
|
||||
|
||||
|
||||
# Check the way is correctly returned
|
||||
assert_select "osm way[id='#{way.id}'][version='#{way.version}'][visible='#{way.visible}']", 1
|
||||
|
||||
# check that each node in the way appears once in the output as a
|
||||
|
||||
# check that each node in the way appears once in the output as a
|
||||
# reference and as the node element.
|
||||
way.nodes.each do |n|
|
||||
count = (way.nodes - (way.nodes - [n])).length
|
||||
|
@ -118,14 +118,14 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# use the first user's open changeset
|
||||
changeset_id = changesets(:normal_user_first_change).id
|
||||
|
||||
|
||||
# create a way with pre-existing nodes
|
||||
content "<osm><way changeset='#{changeset_id}'>" +
|
||||
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
||||
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
||||
"<tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"way upload did not return success status"
|
||||
# read id of created way and search for it
|
||||
wayid = @response.body
|
||||
|
@ -137,32 +137,32 @@ class WayControllerTest < ActionController::TestCase
|
|||
|
||||
# use the first user's open changeset
|
||||
changeset_id = changesets(:public_user_first_change).id
|
||||
|
||||
|
||||
# create a way with pre-existing nodes
|
||||
content "<osm><way changeset='#{changeset_id}'>" +
|
||||
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
||||
"<nd ref='#{nid1}'/><nd ref='#{nid2}'/>" +
|
||||
"<tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# hope for success
|
||||
assert_response :success,
|
||||
assert_response :success,
|
||||
"way upload did not return success status"
|
||||
# read id of created way and search for it
|
||||
wayid = @response.body
|
||||
checkway = Way.find(wayid)
|
||||
assert_not_nil checkway,
|
||||
assert_not_nil checkway,
|
||||
"uploaded way not found in data base after upload"
|
||||
# compare values
|
||||
assert_equal checkway.nds.length, 2,
|
||||
assert_equal checkway.nds.length, 2,
|
||||
"saved way does not contain exactly one node"
|
||||
assert_equal checkway.nds[0], nid1,
|
||||
assert_equal checkway.nds[0], nid1,
|
||||
"saved way does not contain the right node on pos 0"
|
||||
assert_equal checkway.nds[1], nid2,
|
||||
assert_equal checkway.nds[1], nid2,
|
||||
"saved way does not contain the right node on pos 1"
|
||||
assert_equal checkway.changeset_id, changeset_id,
|
||||
"saved way does not belong to the correct changeset"
|
||||
assert_equal users(:public_user).id, checkway.changeset.user_id,
|
||||
assert_equal users(:public_user).id, checkway.changeset.user_id,
|
||||
"saved way does not belong to user that created it"
|
||||
assert_equal true, checkway.visible,
|
||||
assert_equal true, checkway.visible,
|
||||
"saved way is not visible"
|
||||
end
|
||||
|
||||
|
@ -180,11 +180,11 @@ class WayControllerTest < ActionController::TestCase
|
|||
nid1 = current_nodes(:used_node_1).id
|
||||
|
||||
# create a way with non-existing node
|
||||
content "<osm><way changeset='#{open_changeset_id}'>" +
|
||||
content "<osm><way changeset='#{open_changeset_id}'>" +
|
||||
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"way upload with invalid node using a private user did not return 'forbidden'"
|
||||
|
||||
# create a way with no nodes
|
||||
|
@ -192,7 +192,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"way upload with no node using a private userdid not return 'forbidden'"
|
||||
|
||||
# create a way inside a closed changeset
|
||||
|
@ -200,10 +200,10 @@ class WayControllerTest < ActionController::TestCase
|
|||
"<nd ref='#{nid1}'/></way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :forbidden,
|
||||
"way upload to closed changeset with a private user did not return 'forbidden'"
|
||||
assert_response :forbidden,
|
||||
"way upload to closed changeset with a private user did not return 'forbidden'"
|
||||
|
||||
|
||||
|
||||
## Now test with a public user
|
||||
basic_authorization users(:public_user).email, "test"
|
||||
|
||||
|
@ -213,11 +213,11 @@ class WayControllerTest < ActionController::TestCase
|
|||
nid1 = current_nodes(:used_node_1).id
|
||||
|
||||
# create a way with non-existing node
|
||||
content "<osm><way changeset='#{open_changeset_id}'>" +
|
||||
content "<osm><way changeset='#{open_changeset_id}'>" +
|
||||
"<nd ref='0'/><tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :precondition_failed,
|
||||
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
|
||||
|
||||
|
@ -226,7 +226,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
"<tag k='test' v='yes' /></way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :precondition_failed,
|
||||
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
|
||||
|
||||
|
@ -235,8 +235,8 @@ class WayControllerTest < ActionController::TestCase
|
|||
"<nd ref='#{nid1}'/></way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :conflict,
|
||||
"way upload to closed changeset did not return 'conflict'"
|
||||
assert_response :conflict,
|
||||
"way upload to closed changeset did not return 'conflict'"
|
||||
|
||||
# create a way with a tag which is too long
|
||||
content "<osm><way changeset='#{open_changeset_id}'>" +
|
||||
|
@ -245,31 +245,31 @@ class WayControllerTest < ActionController::TestCase
|
|||
"</way></osm>"
|
||||
put :create
|
||||
# expect failure
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"way upload to with too long tag did not return 'bad_request'"
|
||||
end
|
||||
|
||||
# -------------------------------------
|
||||
# Test deleting ways.
|
||||
# -------------------------------------
|
||||
|
||||
|
||||
def test_delete
|
||||
# first try to delete way without auth
|
||||
delete :delete, :id => current_ways(:visible_way).id
|
||||
assert_response :unauthorized
|
||||
|
||||
# now set auth using the private user
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
basic_authorization(users(:normal_user).email, "test");
|
||||
|
||||
# this shouldn't work as with the 0.6 api we need pay load to delete
|
||||
delete :delete, :id => current_ways(:visible_way).id
|
||||
assert_response :forbidden
|
||||
|
||||
|
||||
# Now try without having a changeset
|
||||
content "<osm><way id='#{current_ways(:visible_way).id}'/></osm>"
|
||||
delete :delete, :id => current_ways(:visible_way).id
|
||||
assert_response :forbidden
|
||||
|
||||
|
||||
# try to delete with an invalid (closed) changeset
|
||||
content update_changeset(current_ways(:visible_way).to_xml,
|
||||
changesets(:normal_user_closed_change).id)
|
||||
|
@ -300,27 +300,27 @@ class WayControllerTest < ActionController::TestCase
|
|||
# this shouldn't work as the way is used in a relation
|
||||
content current_ways(:used_way).to_xml
|
||||
delete :delete, :id => current_ways(:used_way).id
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"shouldn't be able to delete a way used in a relation (#{@response.body}), when done by a private user"
|
||||
|
||||
# this won't work since the way never existed
|
||||
delete :delete, :id => 0
|
||||
assert_response :forbidden
|
||||
|
||||
|
||||
|
||||
### Now check with a public user
|
||||
# now set auth
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
basic_authorization(users(:public_user).email, "test");
|
||||
|
||||
# this shouldn't work as with the 0.6 api we need pay load to delete
|
||||
delete :delete, :id => current_ways(:visible_way).id
|
||||
assert_response :bad_request
|
||||
|
||||
|
||||
# Now try without having a changeset
|
||||
content "<osm><way id='#{current_ways(:visible_way).id}'/></osm>"
|
||||
delete :delete, :id => current_ways(:visible_way).id
|
||||
assert_response :bad_request
|
||||
|
||||
|
||||
# try to delete with an invalid (closed) changeset
|
||||
content update_changeset(current_ways(:visible_way).to_xml,
|
||||
changesets(:public_user_closed_change).id)
|
||||
|
@ -351,7 +351,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
# this shouldn't work as the way is used in a relation
|
||||
content current_ways(:used_way).to_xml
|
||||
delete :delete, :id => current_ways(:used_way).id
|
||||
assert_response :precondition_failed,
|
||||
assert_response :precondition_failed,
|
||||
"shouldn't be able to delete a way used in a relation (#{@response.body})"
|
||||
assert_equal "Precondition failed: Way 3 is still used by relations 1.", @response.body
|
||||
|
||||
|
@ -383,7 +383,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content way_xml
|
||||
put :update, :id => current_ways(:visible_way).id
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"adding a duplicate tag to a way for a non-public should fail with 'forbidden'"
|
||||
|
||||
## Now try with the public user
|
||||
|
@ -402,7 +402,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content way_xml
|
||||
put :update, :id => current_ways(:visible_way).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"adding a duplicate tag to a way should fail with 'bad request'"
|
||||
assert_equal "Element way/#{current_ways(:visible_way).id} has duplicate tags with key #{current_way_tags(:t1).k}", @response.body
|
||||
end
|
||||
|
@ -428,9 +428,9 @@ class WayControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content way_xml
|
||||
put :update, :id => current_ways(:visible_way).id
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"adding new duplicate tags to a way using a non-public user should fail with 'forbidden'"
|
||||
|
||||
|
||||
## Now test with the public user
|
||||
# setup auth
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
@ -449,10 +449,10 @@ class WayControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content way_xml
|
||||
put :update, :id => current_ways(:visible_way).id
|
||||
assert_response :bad_request,
|
||||
assert_response :bad_request,
|
||||
"adding new duplicate tags to a way should fail with 'bad request'"
|
||||
assert_equal "Element way/#{current_ways(:visible_way).id} has duplicate tags with key i_am_a_duplicate", @response.body
|
||||
|
||||
|
||||
end
|
||||
|
||||
##
|
||||
|
@ -473,9 +473,9 @@ class WayControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content way_str
|
||||
put :create
|
||||
assert_response :forbidden,
|
||||
assert_response :forbidden,
|
||||
"adding new duplicate tags to a way with a non-public user should fail with 'forbidden'"
|
||||
|
||||
|
||||
## Now do it with a public user
|
||||
# setup auth
|
||||
basic_authorization(users(:public_user).email, "test")
|
||||
|
@ -489,7 +489,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
# try and upload it
|
||||
content way_str
|
||||
put :create
|
||||
assert_response :bad_request,
|
||||
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
|
||||
end
|
||||
|
@ -498,7 +498,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
# test that a call to ways_for_node returns all ways that contain the node
|
||||
# and none that don't.
|
||||
def test_ways_for_node
|
||||
# in current fixtures ways 1 and 3 all use node 3. ways 2 and 4
|
||||
# in current fixtures ways 1 and 3 all use node 3. ways 2 and 4
|
||||
# *used* to use it but doesn't.
|
||||
get :ways_for_node, :id => current_nodes(:used_node_1).id
|
||||
assert_response :success
|
||||
|
@ -512,7 +512,7 @@ class WayControllerTest < ActionController::TestCase
|
|||
found_way_ids = ways_xml.find("//osm/way").collect { |w| w["id"].to_i }
|
||||
assert_equal expected_way_ids.sort, found_way_ids.sort,
|
||||
"expected ways for node #{current_nodes(:used_node_1).id} did not match found"
|
||||
|
||||
|
||||
# check the full ways to ensure we're not missing anything
|
||||
expected_way_ids.each do |id|
|
||||
way_xml = ways_xml.find("//osm/way[@id='#{id}']").first
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue