Module: GitlabRoutingHelper

Included in:
ApplicationController, Gitlab::UrlBuilder
Defined in:
app/helpers/gitlab_routing_helper.rb

Overview

Shorter routing method for project and project items Since update to rails 4.1.9 we are now allowed to use `/` in project routing so we use nested routing for project resources which include project and project namespace. To avoid writing long methods every time we define shortcuts for some of routing.

For example instead of this:

namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request)

We can simply use shortcut:

merge_request_path(merge_request)

Instance Method Summary collapse

Instance Method Details

#activity_project_path(project, *args) ⇒ Object


36
37
38
# File 'app/helpers/gitlab_routing_helper.rb', line 36

def activity_project_path(project, *args)
  activity_namespace_project_path(project.namespace, project, *args)
end

#edit_project_path(project, *args) ⇒ Object


40
41
42
# File 'app/helpers/gitlab_routing_helper.rb', line 40

def edit_project_path(project, *args)
  edit_namespace_project_path(project.namespace, project, *args)
end

#edit_project_url(project, *args) ⇒ Object


68
69
70
# File 'app/helpers/gitlab_routing_helper.rb', line 68

def edit_project_url(project, *args)
  edit_namespace_project_url(project.namespace, project, *args)
end

#issue_path(entity, *args) ⇒ Object


52
53
54
# File 'app/helpers/gitlab_routing_helper.rb', line 52

def issue_path(entity, *args)
  namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args)
end

#issue_url(entity, *args) ⇒ Object


72
73
74
# File 'app/helpers/gitlab_routing_helper.rb', line 72

def issue_url(entity, *args)
  namespace_project_issue_url(entity.project.namespace, entity.project, entity, *args)
end

#merge_request_path(entity, *args) ⇒ Object


56
57
58
# File 'app/helpers/gitlab_routing_helper.rb', line 56

def merge_request_path(entity, *args)
  namespace_project_merge_request_path(entity.project.namespace, entity.project, entity, *args)
end

#merge_request_url(entity, *args) ⇒ Object


76
77
78
# File 'app/helpers/gitlab_routing_helper.rb', line 76

def merge_request_url(entity, *args)
  namespace_project_merge_request_url(entity.project.namespace, entity.project, entity, *args)
end

#milestone_path(entity, *args) ⇒ Object


60
61
62
# File 'app/helpers/gitlab_routing_helper.rb', line 60

def milestone_path(entity, *args)
  namespace_project_milestone_path(entity.project.namespace, entity.project, entity, *args)
end

#project_builds_path(project, *args) ⇒ Object


32
33
34
# File 'app/helpers/gitlab_routing_helper.rb', line 32

def project_builds_path(project, *args)
  namespace_project_builds_path(project.namespace, project, *args)
end

#project_commits_path(project, *args) ⇒ Object


24
25
26
# File 'app/helpers/gitlab_routing_helper.rb', line 24

def project_commits_path(project, *args)
  namespace_project_commits_path(project.namespace, project, @ref || project.repository.root_ref)
end

#project_files_path(project, *args) ⇒ Object


20
21
22
# File 'app/helpers/gitlab_routing_helper.rb', line 20

def project_files_path(project, *args)
  namespace_project_tree_path(project.namespace, project, @ref || project.repository.root_ref)
end

#project_path(project, *args) ⇒ Object


16
17
18
# File 'app/helpers/gitlab_routing_helper.rb', line 16

def project_path(project, *args)
  namespace_project_path(project.namespace, project, *args)
end

#project_pipelines_path(project, *args) ⇒ Object


28
29
30
# File 'app/helpers/gitlab_routing_helper.rb', line 28

def project_pipelines_path(project, *args)
  namespace_project_pipelines_path(project.namespace, project, *args)
end

#project_snippet_url(entity, *args) ⇒ Object


80
81
82
# File 'app/helpers/gitlab_routing_helper.rb', line 80

def project_snippet_url(entity, *args)
  namespace_project_snippet_url(entity.project.namespace, entity.project, entity, *args)
end

#project_url(project, *args) ⇒ Object


64
65
66
# File 'app/helpers/gitlab_routing_helper.rb', line 64

def project_url(project, *args)
  namespace_project_url(project.namespace, project, *args)
end

#runner_path(runner, *args) ⇒ Object


48
49
50
# File 'app/helpers/gitlab_routing_helper.rb', line 48

def runner_path(runner, *args)
  namespace_project_runner_path(@project.namespace, @project, runner, *args)
end

#runners_path(project, *args) ⇒ Object


44
45
46
# File 'app/helpers/gitlab_routing_helper.rb', line 44

def runners_path(project, *args)
  namespace_project_runners_path(project.namespace, project, *args)
end

#toggle_subscription_path(entity, *args) ⇒ Object


84
85
86
87
88
89
90
# File 'app/helpers/gitlab_routing_helper.rb', line 84

def toggle_subscription_path(entity, *args)
  if entity.is_a?(Issue)
    toggle_subscription_namespace_project_issue_path(entity.project.namespace, entity.project, entity)
  else
    toggle_subscription_namespace_project_merge_request_path(entity.project.namespace, entity.project, entity)
  end
end