Commit 496425bc authored by Jan Provaznik's avatar Jan Provaznik Committed by Dmitriy Zaporozhets

Add epic support to UrlBuilder

This assures that epic and epic note URLs are built correctly
with UrlBuilder.
parent 3c2bc9a8
---
title: Added 'copy link' in epic comment dropdown.
merge_request: 17224
author:
type: added
......@@ -7,10 +7,23 @@ module EE
override :url
def url
return project_design_url(object.project, object) if object.is_a?(DesignManagement::Design)
case object
when DesignManagement::Design
project_design_url(object.project, object)
when Epic
group_epic_url(object.group, object)
else
super
end
end
override :note_url
def note_url
return super unless object.for_epic?
epic = object.noteable
group_epic_url(epic.group, epic, anchor: dom_id(object))
end
end
end
end
......@@ -13,5 +13,26 @@ describe Gitlab::UrlBuilder do
expect(url).to eq "#{Settings.gitlab['url']}/#{design.project.full_path}/-/designs/#{design.id}"
end
end
context 'when passing an epic' do
it 'returns a proper URL' do
epic = build_stubbed(:epic, iid: 42)
url = described_class.build(epic)
expect(url).to eq "#{Settings.gitlab['url']}/groups/#{epic.group.full_path}/-/epics/#{epic.iid}"
end
end
context 'when passing an epic note' do
it 'returns a proper URL' do
epic = create(:epic)
note = build_stubbed(:note_on_epic, noteable: epic)
url = described_class.build(note)
expect(url).to eq "#{Settings.gitlab['url']}/groups/#{epic.group.full_path}/-/epics/#{epic.iid}#note_#{note.id}"
end
end
end
end
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