- { :controller => "api/nodes", :action => "delete", :id => "1" }
+ { :controller => "api/nodes", :action => "destroy", :id => "1" }
+ )
+
+ assert_recognizes(
+ { :controller => "api/nodes", :action => "create" },
+ { :path => "/api/0.6/node/create", :method => :put }
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
assert_difference("OldNode.count", 0) do
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
assert_difference("OldNode.count", 0) do
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>"
assert_difference("Node.count", 0) do
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{private_changeset.id}'/></osm>"
assert_difference("Node.count", 0) do
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
# test that the upload is rejected when no lat is supplied
# create a minimal xml file
xml = "<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>"
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <create/>. XML doesn't contain an osm/node element.", @response.body
# test that the upload is rejected when no lat is supplied
# create a minimal xml file
xml = "<osm><node lon='#{lon}' changeset='#{changeset.id}'/></osm>"
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lon=\"3.23\" changeset=\"#{changeset.id}\"/>. lat missing", @response.body
# test that the upload is rejected when no lon is supplied
# create a minimal xml file
xml = "<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>"
# test that the upload is rejected when no lon is supplied
# create a minimal xml file
xml = "<osm><node lat='#{lat}' changeset='#{changeset.id}'/></osm>"
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"3.434\" changeset=\"#{changeset.id}\"/>. lon missing", @response.body
# test that the upload is rejected when lat is non-numeric
# create a minimal xml file
xml = "<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
# test that the upload is rejected when lat is non-numeric
# create a minimal xml file
xml = "<osm><node lat='abc' lon='#{lon}' changeset='#{changeset.id}'/></osm>"
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"abc\" lon=\"#{lon}\" changeset=\"#{changeset.id}\"/>. lat not a number", @response.body
# test that the upload is rejected when lon is non-numeric
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>"
# test that the upload is rejected when lon is non-numeric
# create a minimal xml file
xml = "<osm><node lat='#{lat}' lon='abc' changeset='#{changeset.id}'/></osm>"
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
# test that the upload is rejected when we have a tag which is too long
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
# hope for success
assert_response :bad_request, "node upload did not return bad_request status"
assert_equal "Cannot parse valid node from xml string <node lat=\"#{lat}\" lon=\"abc\" changeset=\"#{changeset.id}\"/>. lon not a number", @response.body
# test that the upload is rejected when we have a tag which is too long
xml = "<osm><node lat='#{lat}' lon='#{lon}' changeset='#{changeset.id}'><tag k='foo' v='#{'x' * 256}'/></node></osm>"
assert_response :bad_request, "node upload did not return bad_request status"
assert_match(/ v: is too long \(maximum is 255 characters\) /, @response.body)
end
assert_response :bad_request, "node upload did not return bad_request status"
assert_match(/ v: is too long \(maximum is 255 characters\) /, @response.body)
end
- def test_show
- # check that a visible node is returned properly
- get api_node_path(create(:node))
- assert_response :success
+ def test_show_not_found
+ get api_node_path(0)
+ assert_response :not_found
+ end
- # check chat a non-existent node is not returned
- get api_node_path(0)
- assert_response :not_found
+ def test_show
+ node = create(:node, :timestamp => "2021-02-03T00:00:00Z")
+
+ get api_node_path(node)
+
+ assert_response :success
+ assert_not_nil @response.header["Last-Modified"]
+ assert_equal "2021-02-03T00:00:00Z", Time.parse(@response.header["Last-Modified"]).utc.xmlschema
private_user = create(:user, :data_public => false)
private_user_changeset = create(:changeset, :user => private_user)
private_user_closed_changeset = create(:changeset, :closed, :user => private_user)
private_user = create(:user, :data_public => false)
private_user_changeset = create(:changeset, :user => private_user)
private_user_closed_changeset = create(:changeset, :closed, :user => private_user)
xml = "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
"<tag k='\#{@user.inspect}' v='0'/>" \
"</node></osm>"
xml = "<osm><node lat='0' lon='0' changeset='#{private_changeset.id}'>" \
"<tag k='\#{@user.inspect}' v='0'/>" \
"</node></osm>"
assert_require_public_data "Shouldn't be able to create with non-public user"
## Then try with the public data user
assert_require_public_data "Shouldn't be able to create with non-public user"
## Then try with the public data user
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
"<tag k='\#{@user.inspect}' v='0'/>" \
"</node></osm>"
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'>" \
"<tag k='\#{@user.inspect}' v='0'/>" \
"</node></osm>"
assert_response :success, "node create did not return success status"
# get the id of the node we created
assert_response :success, "node create did not return success status"
# get the id of the node we created
# try creating a node, which should be rate limited
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
# try creating a node, which should be rate limited
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
assert_response :success, "node create did not return success status"
# get the id of the node we created
assert_response :success, "node create did not return success status"
# get the id of the node we created
# try creating a node, which should be rate limited
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"
# try creating a node, which should be rate limited
xml = "<osm><node lat='0' lon='0' changeset='#{changeset.id}'/></osm>"