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
def url_for_project_issues(project = @project)
return '' if project.nil?
if project.default_issues_tracker?
project_issues_path(project)
else
project.external_issue_tracker.project_url
end
project.issues_tracker.project_url
end
def url_for_new_issue(project = @project)
return '' if project.nil?
if project.default_issues_tracker?
url = new_project_issue_path project_id: project
else
project.external_issue_tracker.new_issue_url
end
project.issues_tracker.new_issue_url
end
def url_for_issue(issue_iid, project = @project)
return '' if project.nil?
if project.default_issues_tracker?
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
project.issues_tracker.issue_url(issue_iid)
end
def title_for_issue(issue_iid, project = @project)
......
class GitlabIssueTrackerService < IssueTrackerService
include Rails.application.routes.url_helpers
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
......@@ -10,4 +10,16 @@ class GitlabIssueTrackerService < IssueTrackerService
def to_param
'gitlab'
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
......@@ -22,6 +22,10 @@ class IssueTrackerService < Service
# implement inside child
end
def issue_url(iid)
self.issues_url.gsub(':id', iid.to_s)
end
def fields
[
{ type: 'text', name: 'description', placeholder: description },
......
......@@ -23,6 +23,7 @@ describe GitlabMarkdownHelper do
@project = project
@ref = 'markdown'
@repository = project.repository
@request.host = Gitlab.config.gitlab.host
end
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