Skip to content

Commit

Permalink
Add spec showing that HttpMethodOverrideHandler fails on invalid json (
Browse files Browse the repository at this point in the history
…#854)

Because part of this handler looks at the request body, it can fail if the json is malformed.  I believe this is totally acceptable behavior.  The reason I point this out is because in lucky-cli, this handler is put before the ErrorHandler ([reference](https://github.com/luckyframework/lucky_cli/blob/master/src/web_app_skeleton/src/app_server.cr.ecr\#L5-L15)) when it probably shouldn't be. This is most likely the cause of #852
  • Loading branch information
Matthew McGarvey authored and jwoertink committed Jul 18, 2019
1 parent 89f7fda commit d22cbf3
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions spec/http_method_override_handler_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ describe Lucky::HttpMethodOverrideHandler do
it "works when there is no overridden method" do
should_handle "GET", overridden_method: nil, and_return: "GET"
end

it "fails if request body contains malformed json" do
request = build_request "GET", body: "{ \"bad_json\": 123", content_type: "application/json"

expect_raises(JSON::ParseException) do
Lucky::HttpMethodOverrideHandler.new.call(build_context(request: request))
end
end
end
end

Expand Down

0 comments on commit d22cbf3

Please sign in to comment.