summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 11:50:22 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 12:58:59 -0300
commita8cc69a2816f3d241aa6d1471cb7e3c8d44c8624 (patch)
tree0592cb61fef54a64b88d37fbf4efff666b5d21c6
parent997e77e74a86241defcfb22a40118df7ec8f7493 (diff)
downloadgitlab-ce-a8cc69a2816f3d241aa6d1471cb7e3c8d44c8624.tar.gz
Validate if the lists are different when moving issues between lists
-rw-r--r--app/services/boards/issues/move_service.rb3
-rw-r--r--spec/services/boards/issues/move_service_spec.rb15
2 files changed, 17 insertions, 1 deletions
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index d6eb4adc5dd..84dc3f70e76 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -11,7 +11,8 @@ module Boards
private
def valid_move?
- moving_from_list.present? && moving_to_list.present?
+ moving_from_list.present? && moving_to_list.present? &&
+ moving_from_list != moving_to_list
end
def moving_from_list
diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb
index 65f2247918f..0122159cab8 100644
--- a/spec/services/boards/issues/move_service_spec.rb
+++ b/spec/services/boards/issues/move_service_spec.rb
@@ -121,5 +121,20 @@ describe Boards::Issues::MoveService, services: true do
expect(issue).to be_reopened
end
end
+
+ context 'when moving to same list' do
+ let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) }
+ let(:params) { { from_list_id: list1.id, to_list_id: list1.id } }
+
+ it 'returns false' do
+ expect(described_class.new(project, user, params).execute(issue)).to eq false
+ end
+
+ it 'keeps issues labels' do
+ described_class.new(project, user, params).execute(issue)
+
+ expect(issue.reload.labels).to contain_exactly(bug, development)
+ end
+ end
end
end