Getting ActionController::UrlGenerationError in controller test after upgrade from 3.2.22 to 4.0.13

16 views
Skip to first unread message

powi

unread,
Aug 6, 2015, 5:00:04 AM8/6/15
to Ruby on Rails: Talk
Hello.

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!
Reply all
Reply to author
Forward
0 new messages