Skip to content

Fix grape-route-helper route shadowing

Mario de la Ossa requested to merge grape-router-helpers-bugfix into master

What does this MR do?

Fixes a bug on grape-route-helpers gem in which a route with less arguments can shadow another route with more arguments but the same name (example: api_v4_projects_merge_requests_path(id: 1, merge_request_iid: 2) and api_v4_projects_merge_requests_path(id: 3))

Are there points in the code the reviewer needs to double check?

The tests I added depend on existing API routes and so run the risk of breaking if these routes are changed

Why was this MR needed?

I attempted to fix this bug upstream but the project is abandoned. Since it's only a one-line fix I opted to monkey-patch the fix directly inside the pre-existing grape_route_helpers_fix.rb file.

This bug can be surprising when using grape-route-helpers as you would expect a route with the same name but more params than another to work. Instead though the route ends up shadowed and requires the developer to set a different name explicitly in order to be able to access it.

Screenshots (if relevant)

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Merge request reports

Loading