(Forgive me if this is incorrect, because I recognized this initially as something in Rails 4.0.0.beta1 and have just done a cursory look over the latest generator code.)
Noticed in Rails 4 that the test generated for a scaffold controller only tests the html format instead of both html and json: https://github.com/rails/rails/blob/3f9baeb2ec08138a0da09870ae60fd6b8165c07f/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb It was like that before, but now it is less obvious that it isn't testing it because of the jbuilder integration 3 months ago here: https://github.com/rails/rails/commit/3bfd99defb559af0b017ee920ca714aa1e367fdd#railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb I know that there is nothing in the code of the generated controller that itself is json-specific, so any generated tests for json format specific behavior (1) would be testing jbuilder, and jbuilder already has tests, and (2) if the generated test forces testing of json, then people that don't care about json or have overwritten the Rails 4 controller generator template would also need to either modify the generated tests or also modify the controller test generator template to keep it from testing json format. However, I see neither of these as reasons that the controller tests should not test json format, since jbuilder views are created as part of the generated scaffold that need to be tested (that is part of the point of the generated test), and even if it doesn't *need* to be tested because we know the default version should work, it would be helpful to show new users how to test both the html and json format of the controller, imo, to ensure that jbuilder views are valid and everything is working correctly as a basic test of the newly generator scaffold. So, Question #1: What do you think of that? Question #2: Actions 'new' and 'edit' could theoretically respond in json format because the routes are there, but there are no jbuilder views for those (since they really wouldn't be used), so they fail. Should the generated restful route be more complicated to disable/not enable routs for new and edit actions for non-html format? Or should that be left as-is and if it was decided that there should be json tests, then there should be no tests for new/edit in json? Thanks! -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
