You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And in the template I'm using a URL method which requires a :seller_id in the path. This works fine serving the page, but in the view spec this causes a No route matches error with missing required keys: [:seller_id].
Expected behaviour
The extra_params should be used when URLs are generated.
The extra_params on the other hand only seem to affect the request.path (maybe used in older Rails versions?). It should also adjust the request.path_parameters which should resolve the issue.
The text was updated successfully, but these errors were encountered:
@JonRowe apologies for bumping an old thread but we've just ran into this today. We have a generic view used for multiple objects where we have the line <%= link_to request.params.merge(sort_by: @name, sort_direction: link_sort_direction) do %>
we also ran into a url generation error where if we used
What Ruby, Rails and RSpec versions are you using?
Ruby version: ruby 3.0.4p208 (2022-04-12 revision 3fa771dded) [x86_64-darwin21]
Rails version: Rails 7.0.4.3
RSpec version: RSpec 3.12
Observed behaviour
This is about a view spec. According to https://github.com/rspec/rspec-rails/blob/main/lib/rspec/rails/view_spec_methods.rb it should be possible to set extra params required for URL generation, but that isn't working (anymore?).
I'm doing something like:
And in the template I'm using a URL method which requires a :seller_id in the path. This works fine serving the page, but in the view spec this causes a
No route matches
error withmissing required keys: [:seller_id]
.Expected behaviour
The
extra_params
should be used when URLs are generated.Investigation / Suggested Fix
Rails is using a
_recall
hash in the options hash passed around for url generation to lookup previous path parameters. This is initialized in https://github.com/rails/rails/blob/58528bf270325789562413eec20b3cbf1a866e7f/actionpack/lib/action_controller/metal/url_for.rb#L33, using therequest.path_parameters
.When I used the following code, the URL generation works fine:
The extra_params on the other hand only seem to affect the
request.path
(maybe used in older Rails versions?). It should also adjust therequest.path_parameters
which should resolve the issue.The text was updated successfully, but these errors were encountered: