Ruby on Rails
Thursday, August 6, 2015
Hello.
While I was missing the `:id` param, the test actually worked; it successfully called the `show` action no matter the missing required param. Maybe this was not so correct behavior on behalf of Rails, but it was like that.
If I add the `id: 1` part in my test, it works fine (as it should).
-- While on 3.2 I had a controller spec which was calling an action:
# ...
get :show
# ...
The route was this:
guides_show GET /guides/:id(.:name.html)(.:format) guides#show {:id=>/\d+/}
While I was missing the `:id` param, the test actually worked; it successfully called the `show` action no matter the missing required param. Maybe this was not so correct behavior on behalf of Rails, but it was like that.
After upgrading to Rails 4.0.13, I now get the following _expected_ error:
Failure/Error: get :show ActionController::UrlGenerationError: No route matches {:action=>"show", :controller=>"guides"} # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_dispatch/journey/formatter.rb:40:in `generate' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:597:in `generate' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:627:in `generate' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:622:in `generate_extras' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_dispatch/routing/route_set.rb:618:in `extra_keys' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:189:in `assign_parameters' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:560:in `process' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:64:in `process' # /Users/as/.gem/ruby/2.1.5/gems/actionpack-4.0.13/lib/action_controller/test_case.rb:472:in `get'
If I add the `id: 1` part in my test, it works fine (as it should).
While this change seems perfectly rational and more correct than the behavior in Rails 3.2, I'm trying to find the actual commit/issue that made this change but can't find anything (searched in CHANGELOG, rails upgrade notes, googled issues).
I'm not looking for a solution to my "issue" here, I'm just trying to find the actual change in Rails 4.0.x that changed the behavior.
Thanks!
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8f91e8ab-7ae5-4cdd-87b4-fe399a162ea8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment