Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON output nodes, ways, relations, map #2485

Merged
merged 10 commits into from Feb 26, 2020
4 changes: 4 additions & 0 deletions app/controllers/api_controller.rb
Expand Up @@ -45,6 +45,10 @@ def set_default_request_format
request.format = "xml"
break
end

# In case the client requests some other format besides XML, JSON and */*,
# we deliberately don't set request.format. The framework will return an
# ActionController::UnknownFormat error to the client later on in this case.
end
gravitystorm marked this conversation as resolved.
Show resolved Hide resolved
end
end
Expand Down
8 changes: 7 additions & 1 deletion test/controllers/api/map_controller_test.rb
Expand Up @@ -32,7 +32,7 @@ def test_routes
##
# test http accept headers
def test_http_accept_header
node = create(:node, :lat => 7, :lon => 7)
node = create(:node)

minlon = node.lon - 0.1
minlat = node.lat - 0.1
Expand Down Expand Up @@ -99,6 +99,12 @@ def test_http_accept_header
http_accept_format("text/json")
get :index, :params => { :bbox => bbox }
assert_response :internal_server_error, "text/json should fail"

# image/jpeg is a format which we don't support, ActionController::UnknownFormat error is expected
# HTTP 406 Not acceptable would be the correct response error code. That's outside of our control though.
http_accept_format("image/jpeg")
get :index, :params => { :bbox => bbox }
assert_response :internal_server_error, "text/json should fail"
end

# -------------------------------------
Expand Down