Commit 1491f03e authored by Douwe Maan's avatar Douwe Maan

Merge branch 'ee-53655-board-milestone-fix' into 'master'

Fix removing milestones when moving between board lists

Closes gitlab-ce#53655

See merge request gitlab-org/gitlab-ee!8875
parents 8cc098e5 7a4a878a
......@@ -41,7 +41,7 @@ module EE
def milestone_id(issue)
# We want to nullify the issue milestone.
return if moving_to_list.backlog?
return if moving_to_list.backlog? && moving_from_list.milestone?
# Moving to a list which is not a 'milestone list' will keep
# the already existent milestone.
......
---
title: Don't remove milestones when moving issues to board backlog from non-milestone list
merge_request:
author:
type: fixed
......@@ -102,7 +102,7 @@ describe Boards::Issues::MoveService, services: true do
end
shared_examples 'moving an issue to/from assignee lists' do
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) }
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development], milestone: milestone1) }
let(:params) { { board_id: board1.id, from_list_id: label_list1.id, to_list_id: label_list2.id } }
context 'from assignee to label list' do
......@@ -116,11 +116,12 @@ describe Boards::Issues::MoveService, services: true do
issue.reload
expect(issue.labels).to contain_exactly(bug, development, testing)
expect(issue.assignees).to contain_exactly(user_list1.user)
expect(issue.milestone).to eq(milestone1)
end
end
context 'from assignee to backlog' do
it 'removes assignment' do
it 'removes assignment and keeps milestone' do
params = { board_id: board1.id, from_list_id: user_list1.id, to_list_id: backlog.id }
issue.assignees.push(user_list1.user)
expect(issue.assignees).to contain_exactly(user_list1.user)
......@@ -130,6 +131,7 @@ describe Boards::Issues::MoveService, services: true do
issue.reload
expect(issue.assignees).to eq([])
expect(issue).not_to be_closed
expect(issue.milestone).to eq(milestone1)
end
end
......@@ -144,6 +146,7 @@ describe Boards::Issues::MoveService, services: true do
issue.reload
expect(issue.assignees).to contain_exactly(user_list1.user)
expect(issue).to be_closed
expect(issue.milestone).to eq(milestone1)
end
end
......@@ -156,6 +159,7 @@ describe Boards::Issues::MoveService, services: true do
issue.reload
expect(issue.labels).to contain_exactly(bug, development)
expect(issue.assignees).to contain_exactly(user_list1.user)
expect(issue.milestone).to eq(milestone1)
end
end
......@@ -170,6 +174,7 @@ describe Boards::Issues::MoveService, services: true do
issue.reload
expect(issue.labels).to contain_exactly(bug, development)
expect(issue.assignees).to contain_exactly(user)
expect(issue.milestone).to eq(milestone1)
end
end
end
......
......@@ -39,6 +39,22 @@ shared_examples 'issues move service' do |group|
end
end
context 'when moving to backlog' do
let(:milestone) { create(:milestone, project: project) }
let!(:backlog) { create(:backlog_list, board: board1) }
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing, regression], milestone: milestone) }
let(:params) { { board_id: board1.id, from_list_id: list2.id, to_list_id: backlog.id } }
it 'keeps labels and milestone' do
described_class.new(parent, user, params).execute(issue)
issue.reload
expect(issue.labels).to contain_exactly(bug, regression)
expect(issue.milestone).to eq(milestone)
end
end
context 'when moving from closed' do
let(:issue) { create(:labeled_issue, :closed, project: project, labels: [bug]) }
let(:params) { { board_id: board1.id, from_list_id: closed.id, to_list_id: list2.id } }
......
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