Commit c6c7552e authored by Marin Jankovski's avatar Marin Jankovski

Build the urls inside of the service.

parent 537cd66d
...@@ -16,32 +16,19 @@ module IssuesHelper ...@@ -16,32 +16,19 @@ module IssuesHelper
def url_for_project_issues(project = @project) def url_for_project_issues(project = @project)
return '' if project.nil? return '' if project.nil?
if project.default_issues_tracker? project.issues_tracker.project_url
project_issues_path(project)
else
project.external_issue_tracker.project_url
end
end end
def url_for_new_issue(project = @project) def url_for_new_issue(project = @project)
return '' if project.nil? return '' if project.nil?
if project.default_issues_tracker? project.issues_tracker.new_issue_url
url = new_project_issue_path project_id: project
else
project.external_issue_tracker.new_issue_url
end
end end
def url_for_issue(issue_iid, project = @project) def url_for_issue(issue_iid, project = @project)
return '' if project.nil? return '' if project.nil?
if project.default_issues_tracker? project.issues_tracker.issue_url(issue_iid)
url = project_issue_url project_id: project, id: issue_iid
else
url = project.external_issue_tracker.issues_url
url.gsub(':id', issue_iid.to_s)
end
end end
def title_for_issue(issue_iid, project = @project) def title_for_issue(issue_iid, project = @project)
......
class GitlabIssueTrackerService < IssueTrackerService class GitlabIssueTrackerService < IssueTrackerService
include Rails.application.routes.url_helpers
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
...@@ -10,4 +10,16 @@ class GitlabIssueTrackerService < IssueTrackerService ...@@ -10,4 +10,16 @@ class GitlabIssueTrackerService < IssueTrackerService
def to_param def to_param
'gitlab' 'gitlab'
end end
def project_url
project_issues_path(project)
end
def new_issue_url
new_project_issue_path project_id: project
end
def issue_url(iid)
"#{Gitlab.config.gitlab.url}#{project_issue_path project_id: project, id: iid}"
end
end end
...@@ -22,6 +22,10 @@ class IssueTrackerService < Service ...@@ -22,6 +22,10 @@ class IssueTrackerService < Service
# implement inside child # implement inside child
end end
def issue_url(iid)
self.issues_url.gsub(':id', iid.to_s)
end
def fields def fields
[ [
{ type: 'text', name: 'description', placeholder: description }, { type: 'text', name: 'description', placeholder: description },
......
...@@ -23,6 +23,7 @@ describe GitlabMarkdownHelper do ...@@ -23,6 +23,7 @@ describe GitlabMarkdownHelper do
@project = project @project = project
@ref = 'markdown' @ref = 'markdown'
@repository = project.repository @repository = project.repository
@request.host = Gitlab.config.gitlab.host
end end
describe "#gfm" do describe "#gfm" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment