Commit ea27c0a7 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '36924-cablett-epic-tree-permissions' into 'master'

Fix `group_epic_link_path` method

Closes #36924

See merge request gitlab-org/gitlab!20610
parents cfd2734c 67a6f127
---
title: Fix removing of child epics that belong to subgroups
merge_request: 20610
author:
type: fixed
......@@ -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