Do not shadow helpers with same method but more params#21
Open
mdelaossa wants to merge 1 commit intoreprah:masterfrom
Open
Do not shadow helpers with same method but more params#21mdelaossa wants to merge 1 commit intoreprah:masterfrom
mdelaossa wants to merge 1 commit intoreprah:masterfrom
Conversation
Author
|
BTW your travis build is failing on jruby-19 due to |
markglenfletcher
pushed a commit
to gitlabhq/gitlabhq
that referenced
this pull request
Feb 7, 2018
Bringing in reprah/grape-route-helpers#21 as a monkey patch since the grape-route-helpers project seems to be abandoned
mayra-cabrera
pushed a commit
to gitlabhq/gitlabhq
that referenced
this pull request
May 30, 2018
This gem (https://gitlab.com/gitlab-org/grape-path-helpers) makes a number of changes: 1. Brings in @mdelaossa's changes in reprah/grape-route-helpers#21 2. Fixes some broken specs and code for Grape 1.0+ 3. Optimizes the generation of paths by bringing in @dblessing's HashWithIndifferentAccess changes in https://gitlab.com/gitlab-org/gitlab-ce/issues/45718#note_70123793 Closes #45718
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When two helper methods are the same, but have different arguments (for example:
api_v1_cats_owners_path(id: 1)vsapi_v1_cats_owners_path(id: 1, owner_id: 2)) if the helper method with the least number of arguments is defined first (because the route was defined first) then it will shadow the longer route.Example:
Consider the following routes:
The helper methods return:
which is wrong.
api_v1_cats_owners_path(id: 1, owner_id: 2)should return'/api/v1/cats/1/owners/2.json'This PR fixes this issue in the simplest possible way: when
GrapeRouteHelpers::AllRoutesis generating@decorated_routes, it sorts the routes in descending order by the count ofdynamic_path_segmentsit has.Fixes #22