-
Notifications
You must be signed in to change notification settings - Fork 365
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
Query String passed when using POST #123
Comments
query_string
created when using POST
query_string
created when using POST
This is failing because you're doing header 'Content-Type', 'application/json' Rails is expecting the POST body to be JSON, instead it's sending let(:raw_post) { params.to_json } RAD will take care of generating that params hash for you. |
@oestrich I ran into the same problem - if the content-type is json, shouldn't RAD default to posting the params in json accordingly? |
FYI: I would have assumed the same The whole raw_post approach feels like a hack.
|
FYI i wrote a monkey patch for this in my app (normally i would do a fork/fix/PR but we have too many conflicting gems right now with rad master so i just did this for now - but maybe it helps somebody or can be intro'd into master) ./monkey_patch_rad.rb:
and in the specs (or in some helper)
|
We've talked about it before and I don't think I want to have RAD peak into headers and change the post body for you. I prefer doing a shared context so it is more clear and less "magical." shared_context :json do
header "Content-Type", "application/json"
let(:raw_post) { params.to_json }
end
describe "Orders" do
include_context :json
post "/orders" do
example_request "Creating an order" do
# ...
end
end
end |
thanks - will think about it. personally i see "request bodys are json" more like a configuration setting for my http client than a flag for my tests. therefore i would be personally ok with a bit of magic (or setting) |
@andreasklinger What do you think of #142? |
love it. i think that's the way to go |
Closing this now that #142 is on master. |
Unless I am misunderstanding, the
query_string
parameter should only be passed on GET requests. I was having trouble this morning testing a POST due to it passing thequery_string
on top of myparams
that were being passed.this is the error that occurs
I discovered I could resolve this by overriding the params by
let
ingraw_post
.I shouldn't have to do this according to the documentation though. Am I doing something wrong or is this a bug?
Thank you for your time. I love this project! Keep up the amazing work!
The text was updated successfully, but these errors were encountered: