From 5ae4592637a134bc14f4b082f0bf2b023a884e22 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sat, 8 Jul 2017 16:24:18 -0500 Subject: Also inject new route helpers into includers of GitlabRoutingHelper --- app/helpers/gitlab_routing_helper.rb | 4 ++++ lib/gitlab/routing.rb | 13 +++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb index 2e36d0fdb5a..0517a699ae0 100644 --- a/app/helpers/gitlab_routing_helper.rb +++ b/app/helpers/gitlab_routing_helper.rb @@ -2,6 +2,10 @@ module GitlabRoutingHelper extend ActiveSupport::Concern + included do + Gitlab::Routing.includes_helpers(self) + end + # Project def project_tree_path(project, ref = nil, *args) namespace_project_tree_path(project.namespace, project, ref || @ref || project.repository.root_ref, *args) # rubocop:disable Cop/ProjectPathHelper diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb index ac1e864433b..e57890f1143 100644 --- a/lib/gitlab/routing.rb +++ b/lib/gitlab/routing.rb @@ -6,21 +6,26 @@ module Gitlab self._includers = [] included do - Gitlab::Routing._includers << self + Gitlab::Routing.includes_helpers(self) + include Gitlab::Routing.url_helpers end + def self.includes_helpers(klass) + self._includers << klass + end + def self.add_helpers(mod) url_helpers.include mod url_helpers.extend mod + GitlabRoutingHelper.include mod + GitlabRoutingHelper.extend mod + app_url_helpers = Gitlab::Application.routes.named_routes.url_helpers_module app_url_helpers.include mod app_url_helpers.extend mod - GitlabRoutingHelper.include mod - GitlabRoutingHelper.extend mod - _includers.each do |klass| klass.include mod end -- cgit v1.2.1