From e042baebb81ebd2b60becd9bebd2d088881aeca4 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 24 Jan 2018 17:05:39 +0800 Subject: Eliminate the last warning for redis wrapper --- config/application.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'config') diff --git a/config/application.rb b/config/application.rb index 2067428ff62..751307de975 100644 --- a/config/application.rb +++ b/config/application.rb @@ -6,6 +6,7 @@ Bundler.require(:default, Rails.env) module Gitlab class Application < Rails::Application + require_dependency Rails.root.join('lib/gitlab/redis/wrapper') require_dependency Rails.root.join('lib/gitlab/redis/cache') require_dependency Rails.root.join('lib/gitlab/redis/queues') require_dependency Rails.root.join('lib/gitlab/redis/shared_state') -- cgit v1.2.1 From 233a9861113df678e1f54dfbd13d9ab23fd5d5a0 Mon Sep 17 00:00:00 2001 From: Mario de la Ossa Date: Mon, 29 Jan 2018 14:56:43 -0600 Subject: Fix grape-route-helper route shadowing Bringing in https://github.com/reprah/grape-route-helpers/pull/21 as a monkey patch since the grape-route-helpers project seems to be abandoned --- config/initializers/grape_route_helpers_fix.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'config') diff --git a/config/initializers/grape_route_helpers_fix.rb b/config/initializers/grape_route_helpers_fix.rb index d3cf9e453d0..612cca3dfbd 100644 --- a/config/initializers/grape_route_helpers_fix.rb +++ b/config/initializers/grape_route_helpers_fix.rb @@ -1,5 +1,21 @@ 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. -- cgit v1.2.1