blob: 7ab3f090a890d21aeb85b460f970d922e883bc23 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
module Gitlab
class UrlBuilder
include Rails.application.routes.url_helpers
def initialize(type)
@type = type
end
def build(id)
case @type
when :issue
issue_url(id)
when :merge_request
merge_request_url(id)
end
end
private
def issue_url(id)
issue = Issue.find(id)
namespace_project_issue_url(namespace_id: issue.project.namespace,
id: issue.iid,
project_id: issue.project,
host: Gitlab.config.gitlab['url'])
end
def merge_request_url(id)
merge_request = MergeRequest.find(id)
project_merge_request_url(id: merge_request.id,
project_id: merge_request.project,
host: Gitlab.config.gitlab['url'])
end
end
end
|