diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-29 12:06:35 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-05 11:11:59 -0500 |
commit | fe13f110412d85c05dc68e5ee1db499f681bf722 (patch) | |
tree | 4a2d172bb5a490ac8cadbcf376fbf815393ef22b /config | |
parent | dc7939337e0d72d2391c3bbb3082d644a54195af (diff) | |
download | gitlab-ce-fe13f110412d85c05dc68e5ee1db499f681bf722.tar.gz |
Create and use project path helpers that only need a project, no namespace
Diffstat (limited to 'config')
-rw-r--r-- | config/application.rb | 20 | ||||
-rw-r--r-- | config/initializers/doorkeeper_openid_connect.rb | 2 | ||||
-rw-r--r-- | config/initializers/relative_naming_ci_namespace.rb | 4 |
3 files changed, 23 insertions, 3 deletions
diff --git a/config/application.rb b/config/application.rb index 3f39170a123..a9a961d7520 100644 --- a/config/application.rb +++ b/config/application.rb @@ -162,5 +162,25 @@ module Gitlab config.generators do |g| g.factory_girl false end + + config.after_initialize do + Rails.application.reload_routes! + + project_url_helpers = Module.new do + Gitlab::Application.routes.named_routes.helper_names.each do |name| + next unless name.include?('namespace_project') + + define_method(name.sub('namespace_project', 'project')) do |project, *args| + send(name, project&.namespace, project, *args) + end + end + end + + Gitlab::Routing.url_helpers.include project_url_helpers + Gitlab::Routing.url_helpers.extend project_url_helpers + + GitlabRoutingHelper.include project_url_helpers + GitlabRoutingHelper.extend project_url_helpers + end end end diff --git a/config/initializers/doorkeeper_openid_connect.rb b/config/initializers/doorkeeper_openid_connect.rb index 4ff9019c43c..c58f425b19b 100644 --- a/config/initializers/doorkeeper_openid_connect.rb +++ b/config/initializers/doorkeeper_openid_connect.rb @@ -29,7 +29,7 @@ Doorkeeper::OpenidConnect.configure do o.claim(:email) { |user| user.public_email } o.claim(:email_verified) { |user| true if user.public_email? } o.claim(:website) { |user| user.full_website_url if user.website_url? } - o.claim(:profile) { |user| Rails.application.routes.url_helpers.user_url user } + o.claim(:profile) { |user| Gitlab::Routing.url_helpers.user_url user } o.claim(:picture) { |user| user.avatar_url(only_path: false) } end end diff --git a/config/initializers/relative_naming_ci_namespace.rb b/config/initializers/relative_naming_ci_namespace.rb index 03ac55be0b6..d9d3034150f 100644 --- a/config/initializers/relative_naming_ci_namespace.rb +++ b/config/initializers/relative_naming_ci_namespace.rb @@ -4,10 +4,10 @@ # - [project.namespace, project, build] # # instead of: -# - namespace_project_job_path(project.namespace, project, build) +# - project_job_path(project, build) # # Without that, Ci:: namespace is used for resolving routes: -# - namespace_project_ci_build_path(project.namespace, project, build) +# - project_ci_build_path(project, build) module Ci def self.use_relative_model_naming? |