diff options
author | Marin Jankovski <marin@gitlab.com> | 2015-03-04 04:08:52 +0300 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2015-03-04 04:08:52 +0300 |
commit | 3d6d0e1e778061aa96ab4e4b888138997b363207 (patch) | |
tree | 85973fe997b93d5c91875f8430454c6abfd9269f | |
parent | 66fa4b09edd5e347882aa2d5646b5faeeac3b37d (diff) | |
parent | 2088cee935e47b569f0c79b10dcb2c506b666af3 (diff) |
Merge branch 'fix-namespace-merge-request-url' into 'master'
Fix namespace in merge request url building
Changes in 42387b733b76dfc1f72585015910a50f094e264f now require namespace specification and broke abc69c890513fb58c1ceae7548f4fbcc221b7c34.
There are additional helper functions in c530ca00b0f40ec0e0df4d1885ce55e47a59b70d, but this seemed easier not to rely on them.
See merge request !363
-rw-r--r-- | lib/gitlab/url_builder.rb | 18 | ||||
-rw-r--r-- | spec/lib/gitlab/url_builder_spec.rb | 2 |
2 files changed, 8 insertions, 12 deletions
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb index 7ab3f090a89..ab7c8ad89f3 100644 --- a/lib/gitlab/url_builder.rb +++ b/lib/gitlab/url_builder.rb @@ -1,6 +1,7 @@ module Gitlab class UrlBuilder include Rails.application.routes.url_helpers + include GitlabRoutingHelper def initialize(type) @type = type @@ -9,27 +10,22 @@ module Gitlab def build(id) case @type when :issue - issue_url(id) + build_issue_url(id) when :merge_request - merge_request_url(id) + build_merge_request_url(id) end end private - def issue_url(id) + def build_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']) + issue_url(issue, host: Gitlab.config.gitlab['url']) end - def merge_request_url(id) + def build_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']) + merge_request_url(merge_request, host: Gitlab.config.gitlab['url']) end end end diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb index 518239fab6d..94b2fd5508e 100644 --- a/spec/lib/gitlab/url_builder_spec.rb +++ b/spec/lib/gitlab/url_builder_spec.rb @@ -13,7 +13,7 @@ describe Gitlab::UrlBuilder do it 'returns the merge request url' do merge_request = create(:merge_request) url = Gitlab::UrlBuilder.new(:merge_request).build(merge_request.id) - expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.to_param}/merge_requests/#{merge_request.id}" + expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.path_with_namespace}/merge_requests/#{merge_request.iid}" end end end |