Commit 558ad76f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Recreate ancestor milestones when moving projects

This fixes a bug where only direct parent group
milestones were checked
parent 26dfc31b
......@@ -46,7 +46,7 @@ module Milestones
Milestone.joins(:issues)
.where(
issues: { project_id: project.id },
group_id: old_group.id
group_id: old_group.self_and_ancestors
)
end
# rubocop: enable CodeReuse/ActiveRecord
......@@ -56,7 +56,7 @@ module Milestones
Milestone.joins(:merge_requests)
.where(
merge_requests: { target_project_id: project.id },
group_id: old_group.id
group_id: old_group.self_and_ancestors
)
end
# rubocop: enable CodeReuse/ActiveRecord
......
---
title: Fix invalid ancestor group milestones when moving projects
merge_request: 27262
author:
type: fixed
......@@ -40,6 +40,16 @@ describe Milestones::TransferService do
expect(new_milestone.project_milestone?).to be_truthy
end
context 'when milestone is from an ancestor group' do
let(:old_group_ancestor) { create(:group) }
let(:old_group) { create(:group, parent: old_group_ancestor) }
let(:group_milestone) { create(:milestone, group: old_group_ancestor)}
it 'recreates the missing group milestones at project level' do
expect { service.execute }.to change(project.milestones, :count).by(1)
end
end
it 'deletes milestone issue counters cache for both milestones' do
new_milestone = create(:milestone, project: project, title: group_milestone.title)
......
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