-
-
Notifications
You must be signed in to change notification settings - Fork 426
AJAX POST content-type Warning #260
Comments
👍 |
I have similar issue. |
I actually think this is a Rails UJS issue, not something that can be fixed in capybara-webkit. The docs you point out are for when making POST requests from within Qt. However, the error your're getting is from testing the action of UJS. Here are the headers from a UJS action:
Note that there is no Content-Type header. capybara-webkit (really, QWebPage) is handling the POST via JavaScript, but because the UJS helpers don't set the header, it defaults to application/octet-stream. We don't want (and probably can't) to set the default header to application/octet-stream, as this may cause unexpected side-effects. Hope this helps. |
It's not that big of a deal. I don't think capybara-webkit should set the header; I was just hoping there was a way to keep the warnings out of my Cucumber output. I suppose a work-around would be to set the header in UJS. I think I tried hooking into the AJAX send, but wasn't able to get the warning to go away that way, but honestly I don't remember... Thanks for taking the time to look into the issue. |
I have the same problem and it's actually causing intermittent failures in my cucumber specs. You can see that the spec fails here when the content type is missing:
But then I run the same spec 2 seconds later and it passes:
The line where the POST request is sent in my app is here:
I'll have a look at fixing this by setting the content type and add an update. |
hi, I have the same issue! :( |
Same here. following thread. |
Following thread, same issue here |
Yep. |
same here. following |
Is this actually causing issues for anyone, or is it simply the warning that is causing concern? Last time I checked, this issue was caused by Rails omission of a content type header. Without changing Rails UJS, there's not much that can be done on our side. |
For me it was more annoyance - there were so many of these messages on the screen that it made it hard to see what tests were passing/failing. |
Same after latest update. Following |
+1 |
For those of you using link_to with remote: true and method: post you can manually set the Content-Type header to silence the warning: CoffeeScript:
JavaScript:
Of course you can adjust the jQuery selector as needed to reduce the scope of remote links that are affected. jquery-ujs should probably be doing this itself, so when I get a chance I'll put together a pull request for them. |
@santry , When I put in your code, my controllers start trying to treat the request as HTML instead of JS (eg. "Processing by DailyPlansController#edit as HTML") in integration tests. |
@jsgarvin can you post a gist with some of the code? |
@santry Here is the current content of my app/assets/javascripts/missing_content_type_patch.js. When I include this file in my assets manifest, I get integration test errors and failures resulting from the controller treating the requests as HTML instead of JS. When I remove the file from the manifest, I simply get the
There's no difference if don't put it inside a document ready block, so that's apparently not necessary, but doesn't seem to help either. |
@jsgarvin you seem to have mixed my CoffeScript in with your JavaScript, resulting in a syntax error. You want this instead:
|
Ha! That's a bit embarrassing. Let's see if I can redeem myself. Your version works great now for any links that were on the page at the time the page was initially loaded. However, links drawn on the page as a result of an earlier AJAX call were still producing the missing content type warning/error. The following version seems to address those as well, at least for me.
|
@jsgarvin yes, that'll fix links added after the initial page render. Hopefully the jquery-ujs guys will accept my pull request and this will all be taken care of! |
what's the status on this? will it be merged? (why not?) |
@oma there isn't anything to merge here yet. The code snippets in the comments address an issue in rails-ujs and can't be generically applied from capybara-webkit. See rails/jquery-ujs#301. We have a general discussion of warning suppression going on in #502. We're not happy with the current solution, but there's some discussion in there if anybody wants to try to put together an alternate. I may get a chance to work on that at some point, but my time is limited and #494 is my next priority. |
thanks for explaining @jferris - appreciated! |
I'll close this issue due to inactivity. Please re-open it if you're still experiencing these issues. |
I have a link that does a POST, e.g.
In my Cucumber output I get the message:
According to the docs, this warning can be muted by setting the following:
If you don't want to or can't add it, is there another way to stop this warning from showing up?
Thanks,
-Damien
The text was updated successfully, but these errors were encountered: