Commit fb8425a7 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-invalid-milestones-when-moving-projects' into 'master'

Recreate ancestor milestones when moving projects

See merge request gitlab-org/gitlab!27262
parents 5c32fdaf 558ad76f
......@@ -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