diff options
author | Stan Hu <stanhu@gmail.com> | 2018-05-30 02:57:46 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-05-30 03:15:03 -0700 |
commit | 990af4fb5dcc08894578cc7d1dd24176c1cbcef2 (patch) | |
tree | 20fba8c1147ea8c4a4c781daffe5d6773af33372 /config | |
parent | 5b1416aa74c4fa80e0c324fd2907166af5ca479b (diff) | |
download | gitlab-ce-990af4fb5dcc08894578cc7d1dd24176c1cbcef2.tar.gz |
Replace grape-route-helpers with our own grape-path-helpers
This gem (https://gitlab.com/gitlab-org/grape-path-helpers) makes a number of changes:
1. Brings in @mdelaossa's changes in https://github.com/reprah/grape-route-helpers/pull/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
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/grape_route_helpers_fix.rb | 51 |
1 files changed, 0 insertions, 51 deletions
diff --git a/config/initializers/grape_route_helpers_fix.rb b/config/initializers/grape_route_helpers_fix.rb deleted file mode 100644 index 612cca3dfbd..00000000000 --- a/config/initializers/grape_route_helpers_fix.rb +++ /dev/null @@ -1,51 +0,0 @@ -if defined?(GrapeRouteHelpers) - module GrapeRouteHelpers - module AllRoutes - # Bringing in PR https://github.com/reprah/grape-route-helpers/pull/21 due to abandonment. - # - # Without the following fix, when two helper methods are the same, but have different arguments - # (for example: api_v1_cats_owners_path(id: 1) vs api_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. - # - # The fix is to sort descending by amount of arguments - def decorated_routes - @decorated_routes ||= all_routes - .map { |r| DecoratedRoute.new(r) } - .sort_by { |r| -r.dynamic_path_segments.count } - end - end - - class DecoratedRoute - # GrapeRouteHelpers gem tries to parse the versions - # from a string, not supporting Grape `version` array definition. - # - # Without the following fix, we get this on route helpers generation: - # - # => undefined method `scan' for ["v3", "v4"] - # - # 2.0.0 implementation of this method: - # - # ``` - # def route_versions - # version_pattern = /[^\[",\]\s]+/ - # if route_version - # route_version.scan(version_pattern) - # else - # [nil] - # end - # end - # ``` - def route_versions - return [nil] if route_version.nil? || route_version.empty? - - if route_version.is_a?(String) - version_pattern = /[^\[",\]\s]+/ - route_version.scan(version_pattern) - else - route_version - end - end - end - end -end |