Skip to content
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

Comment about passing params as JSON in Controller Tests #166

Open
carlesjove opened this issue Oct 16, 2014 · 4 comments
Open

Comment about passing params as JSON in Controller Tests #166

carlesjove opened this issue Oct 16, 2014 · 4 comments

Comments

@carlesjove
Copy link
Contributor

Today I spent four hours or so trying to figure out why my controller tests (functional) was breaking when trying to pass params as JSON. I thought that I was doing something wrong and that I better get another job, unitl I learnt that this is really a Rails bug (not to be fixed anytime soon, by the way, since it's in the 5.0 milestone).

Then I learnt that you can pass params as JSON in Integration tests. (Yeah!!!)

So, since Rails-API is really meant for APIs and JSON will be probably the most common media-type, wouldn't it we useful to either:

  1. Add a comment on POST and PATCH methods like "If you need to pass params as JSON, write an Integration test"
  2. Generate and integration test automatically for the create and update actions
  3. Add a sample of Integration test with params as JSON when the app is generated, commented.

I think that 3) and a comment would be cool. What do you think?

@corprew
Copy link

corprew commented Nov 17, 2014

I think the code would be cool, but a statement to that effect in the documentation would also be handy.

@waleedasif322
Copy link

+1

@spastorino
Copy link
Contributor

Is there any news about this?

@carlesjove
Copy link
Contributor Author

I was waiting for some more feedback, but I guess that there's enough alrady. I'll try to submit a PR in the next days with either 2) or 3). I guess that option 2) would be the most useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants