-
Notifications
You must be signed in to change notification settings - Fork 27
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
Support multiple JSON mime types #55
Conversation
def content_type_is_json? | ||
JSON_MIME_TYPES.include? @response.content_type | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you feel about moving this to something like HttpRequest#has_json_body?
It would be easier to unit-test over there and it fits with the generic request responsibility of the object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh huh. This doesn't fit with the HttpRequest
object. @response
here is a Rack::Response
. Does it make sense to wrap that in a new class to add this has_json_body?
functionality and test it there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I'm getting confused between request and response 🤦♂️
Would it make sense to extract a HttpResponse
object similar to what was done with HttpRequest
? Or maybe leave everything in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again I think that it makes sense to just leave everything here. It doesn't seem like we gain much by wrapping the response.
expect(json[:content][:text]).to eq body.first | ||
expect(json[:content][:mimeType]).to eq mime_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this test red before you implemented the change? My guess is that this would be true no matter the mime type as long as there is some kind of body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test was red. The JSON content type was hardcoded as "application/json"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, so it failed for application/json
but passed for the others.
This commit expands the content type check in the Har::ResponseSerializer to accept multiple JSON mime types.
c366f09
to
135975e
Compare
…meio#55) Bumps [@readme/eslint-config](https://github.com/readmeio/eslint-config) from 2.0.0 to 2.0.2. - [Release notes](https://github.com/readmeio/eslint-config/releases) - [Changelog](https://github.com/readmeio/eslint-config/blob/master/CHANGELOG.md) - [Commits](readmeio/standards@2.0.0...2.0.2) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
🧰 What's being changed?
This commit expands the content type check in the
Har::ResponseSerializer to accept multiple JSON mime types.
🧪 Testing
Using the following sample application:
And the following curl command:
curl 'http://username:password@localhost:9292/api/foo' -X POST
A request was successfully added to the metrics dashboard with a newly added json mime type.
Automated test coverage was also expanded