summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-07-05 17:53:00 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-07-05 17:53:00 +0000
commit462b1ed99d729c3ede32d00fbac042ecb32268b1 (patch)
tree7db61c84a1ee413d756cd889df40f7e9feec93db /config
parentc4e3cd9d1e9fc4b1ea988c2bcc78862c11d9e0b6 (diff)
parent873b40555b582638992e7cdeb2081c29d08cae05 (diff)
downloadgitlab-ce-462b1ed99d729c3ede32d00fbac042ecb32268b1.tar.gz
Merge branch 'dm-project-path-helpers-try-2' into 'master'
Create and use project path helpers that only need a project, no namespace See merge request !12566
Diffstat (limited to 'config')
-rw-r--r--config/application.rb20
-rw-r--r--config/initializers/doorkeeper_openid_connect.rb2
-rw-r--r--config/initializers/relative_naming_ci_namespace.rb4
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?