rails-controller-testing icon indicating copy to clipboard operation
rails-controller-testing copied to clipboard

Rails 6.1 bug involving params with a nested param named param

Open sholden opened this issue 4 years ago • 0 comments

When calling get :action, params: { params: 'string' }, RouteSet#url_for is trying to merge! the inner params string into the params hash.

https://github.com/rails/rails/blob/main/actionpack/lib/action_dispatch/routing/route_set.rb#L826

I added a failing test here:

https://github.com/sholden/rails-controller-testing/blob/bug/merge-nested-params/test/controllers/template_assertions_test.rb#L190

The issue came up while migrating to 6.1, looking into writing a failing spec directly in rails/rails, rather than through controller testing, but this one helped pinpoint the issue as it showed up in our code.

We could change RouteSet to check if options.key?(:params) && options[:params].is_a?(Hash) before attempting a merge, but maybe there's a better way?

sholden avatar Apr 20 '21 01:04 sholden