-
Notifications
You must be signed in to change notification settings - Fork 62
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
Respect Content-Type instead of Accept header in consume! #75
Conversation
@apotonick |
That looks great, @pgaertig I always had the feeling that my content type detection is wrong. So, thanks! ❤️ One question, though:
|
I see that Travis CI is not passing against Rails 3.x . I suppose its problem with setting header in tests. I will check it out. |
I think I copied the Accept header bull from the old responders code. I personally think we can just release 1.0. This won't break too many people's code, and if it does, they will see it instantly. If you could look into the builds 👍 |
I've played with this and this will go into 1.0! |
@@ -16,11 +16,25 @@ class ConsumeTest < ActionController::TestCase | |||
tests UnnamespaceSingersController | |||
|
|||
test "#consume parses incoming document and updates the model" do | |||
post :consume_json, "{\"name\": \"Bumi\"}", :format => '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.
So is that a "bug" in Rails AC::TestCase? Passing :format
doesn't seem to set the format right (Content-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.
We can fix that ourselves in Roar::Rails::TestCase#process
!
I've made tests compatible with 3.x. I also updated readme. Please do some proofreading. |
Great work, @pgaertig, really really! ❤️ I am wondering if we can do the Content-type assignment in This goes into 1.0.0, so no one can complain about changed semantics. I always hated that |
Thanks, and finally green tests! I left some typos behind - it is quite late here ;) |
Go to bed!!!! 😴 The idea was to make |
Hm, something like this?:
I hope user won't forget to include Yet I have no idea how to automatically detect content type from content provided other that use some default - XML currently in above |
Your branch is merged here: 144cdfa#diff-56a50d5da8ce4e982d68b9ef16833b2bR31 I removed a lot of checks as we don't need to be all too gentle 😁 I am wondering why (in the linked test) it still finds a representer even though there is no HAL representer available. I might have to change that in |
This one fixes #64 . Today
consume!
incorrectly usesAccept
request header to parse incoming content. TheAccept
header is about response data format not incoming format. This fix changesconsume!
to useContent-Type
of request header to determine format of consumed content. If format is missing, unknown or not registered withMime::Type
the rack based framework will return HTTP status415 Unsupported Media Type
.