summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-03 12:45:44 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 12:58:58 -0300
commitc08a14c3c20de35018a36f89dec0b10c99a4fd86 (patch)
tree1fabc001dc0ba350ac07809130fd5af668432c0f
parent9e5a305f18377c9fbe74e44dcef7606ab109291c (diff)
downloadgitlab-ce-c08a14c3c20de35018a36f89dec0b10c99a4fd86.tar.gz
Removes all list-labels when moving to Backlog/Done
-rw-r--r--app/services/boards/issues/move_service.rb19
-rw-r--r--spec/services/boards/issues/move_service_spec.rb18
2 files changed, 26 insertions, 11 deletions
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 657268e67b3..398a02ebbfd 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -45,10 +45,25 @@ module Boards
def issue_params
{
- add_label_ids: [moving_to.label_id].compact,
- remove_label_ids: [moving_from.label_id].compact
+ add_label_ids: add_label_ids,
+ remove_label_ids: remove_label_ids
}
end
+
+ def add_label_ids
+ [moving_to.label_id].compact
+ end
+
+ def remove_label_ids
+ label_ids =
+ if moving_to.label?
+ moving_from.label_id
+ else
+ board.lists.label.pluck(:label_id)
+ end
+
+ Array(label_ids).compact
+ end
end
end
end
diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb
index 9a477b38d47..ca03ec2d904 100644
--- a/spec/services/boards/issues/move_service_spec.rb
+++ b/spec/services/boards/issues/move_service_spec.rb
@@ -10,10 +10,10 @@ describe Boards::Issues::MoveService, services: true do
let(:development) { create(:label, project: project, name: 'Development') }
let(:testing) { create(:label, project: project, name: 'Testing') }
- let(:backlog) { create(:backlog_list, board: board) }
- let(:list1) { create(:list, board: board, label: development, position: 0) }
- let(:list2) { create(:list, board: board, label: testing, position: 1) }
- let(:done) { create(:done_list, board: board) }
+ let!(:backlog) { create(:backlog_list, board: board) }
+ let!(:list1) { create(:list, board: board, label: development, position: 0) }
+ let!(:list2) { create(:list, board: board, label: testing, position: 1) }
+ let!(:done) { create(:done_list, board: board) }
before do
project.team << [user, :developer]
@@ -31,8 +31,8 @@ describe Boards::Issues::MoveService, services: true do
end
context 'when moving to backlog' do
- it 'remove the label of the list it came from' do
- issue = create(:labeled_issue, project: project, labels: [bug, development])
+ it 'removes all list-labels' do
+ issue = create(:labeled_issue, project: project, labels: [bug, development, testing])
params = { id: issue.iid, from: list1.id, to: backlog.id }
described_class.new(project, user, params).execute
@@ -64,7 +64,7 @@ describe Boards::Issues::MoveService, services: true do
described_class.new(project, user, params).execute
end
- it 'removes the label from the list it came from and adds the label of the list it goes to' do
+ it 'removess the label from the list it came from and adds the label of the list it goes to' do
described_class.new(project, user, params).execute
expect(issue.reload.labels).to contain_exactly(bug, testing)
@@ -72,7 +72,7 @@ describe Boards::Issues::MoveService, services: true do
end
context 'when moving to done' do
- let(:issue) { create(:labeled_issue, project: project, labels: [bug, testing]) }
+ let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing]) }
let(:params) { { id: issue.iid, from: list2.id, to: done.id } }
it 'delegates the close proceedings to Issues::CloseService' do
@@ -81,7 +81,7 @@ describe Boards::Issues::MoveService, services: true do
described_class.new(project, user, params).execute
end
- it 'remove the label of the list it came from and close the issue' do
+ it 'removes all list-labels and close the issue' do
described_class.new(project, user, params).execute
issue.reload