Commit 9d11e9c9 authored by charlieablett's avatar charlieablett

Fix `group_epic_link_path` method

- Use epic group rather than parent group
- Use path rather than name in reference test
- Test child epics in subgroups
parent b98072f4
......@@ -24,7 +24,7 @@ class EpicPresenter < Gitlab::View::Presenter::Delegated
def group_epic_link_path
return unless epic.parent
url_builder.group_epic_link_path(epic.group, epic.parent.iid, epic.id)
url_builder.group_epic_link_path(epic.parent.group, epic.parent.iid, epic.id)
end
def epic_reference(full: false)
......
......@@ -7,11 +7,11 @@ describe EpicPresenter do
include Gitlab::Routing.url_helpers
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:parent_epic) { create(:epic, group: group, start_date: Date.new(2000, 1, 10), due_date: Date.new(2000, 1, 20)) }
let(:group) { create(:group, path: "pukeko_parent_group") }
let(:parent_epic) { create(:epic, group: group, start_date: Date.new(2000, 1, 10), due_date: Date.new(2000, 1, 20), iid: 10) }
let(:epic) { create(:epic, group: group, author: user, parent: parent_epic) }
let(:presenter) { described_class.new(epic, current_user: user) }
subject(:presenter) { described_class.new(epic, current_user: user) }
describe '#show_data' do
let(:milestone1) { create(:milestone, title: 'make me a sandwich', start_date: '2010-01-01', due_date: '2019-12-31') }
......@@ -72,6 +72,19 @@ describe EpicPresenter do
expect(presenter.group_epic_link_path).to eq group_epic_link_path(epic.group, epic.parent.iid, epic.id)
end
context 'when in subgroups' do
let!(:subgroup) { create(:group, parent: group, path: "hedgehogs_subgroup") }
let(:child_epic) { create(:epic, group: subgroup, iid: 1, parent: epic) }
subject(:presenter) { described_class.new(child_epic, current_user: user) }
it 'returns the correct path' do
expected_result = "/groups/#{group.path}/-/epics/#{epic.iid}/links/#{child_epic.id}"
expect(presenter.group_epic_link_path).to eq expected_result
end
end
it 'returns nothing with nil parent' do
epic.parent = nil
......@@ -85,7 +98,7 @@ describe EpicPresenter do
end
it 'returns a full reference' do
expect(presenter.epic_reference(full: true)).to eq "#{epic.parent.group.name}&#{epic.iid}"
expect(presenter.epic_reference(full: true)).to eq "#{epic.parent.group.path}&#{epic.iid}"
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