Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-03 18:09:03 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 18:58:58 +0300
commit9e5a305f18377c9fbe74e44dcef7606ab109291c (patch)
tree2a9a2bc4f69a2ff93264bdfb69640f5a8e3ed800 /spec/services/boards/lists/move_service_spec.rb
parent2c00d5928c69744138c9a411c533ff3a098f2804 (diff)
Use zero-based positions on issues board services
Diffstat (limited to 'spec/services/boards/lists/move_service_spec.rb')
-rw-r--r--spec/services/boards/lists/move_service_spec.rb48
1 files changed, 28 insertions, 20 deletions
diff --git a/spec/services/boards/lists/move_service_spec.rb b/spec/services/boards/lists/move_service_spec.rb
index aa93cbad7f4..11de74a96a1 100644
--- a/spec/services/boards/lists/move_service_spec.rb
+++ b/spec/services/boards/lists/move_service_spec.rb
@@ -7,10 +7,10 @@ describe Boards::Lists::MoveService, services: true do
let(:user) { create(:user) }
let!(:backlog) { create(:backlog_list, board: board) }
- let!(:planning) { create(:list, board: board, position: 1) }
- let!(:development) { create(:list, board: board, position: 2) }
- let!(:review) { create(:list, board: board, position: 3) }
- let!(:staging) { create(:list, board: board, position: 4) }
+ let!(:planning) { create(:list, board: board, position: 0) }
+ let!(:development) { create(:list, board: board, position: 1) }
+ let!(:review) { create(:list, board: board, position: 2) }
+ let!(:staging) { create(:list, board: board, position: 3) }
let!(:done) { create(:done_list, board: board) }
context 'when list type is set to label' do
@@ -19,15 +19,15 @@ describe Boards::Lists::MoveService, services: true do
service.execute
- expect(current_list_positions).to eq [1, 2, 3, 4]
+ expect(current_list_positions).to eq [0, 1, 2, 3]
end
it 'keeps position of lists when new positon is equal to old position' do
- service = described_class.new(project, user, id: planning.id, position: 1)
+ service = described_class.new(project, user, id: planning.id, position: planning.position)
service.execute
- expect(current_list_positions).to eq [1, 2, 3, 4]
+ expect(current_list_positions).to eq [0, 1, 2, 3]
end
it 'keeps position of lists when new positon is negative' do
@@ -35,47 +35,55 @@ describe Boards::Lists::MoveService, services: true do
service.execute
- expect(current_list_positions).to eq [1, 2, 3, 4]
+ expect(current_list_positions).to eq [0, 1, 2, 3]
+ end
+
+ it 'keeps position of lists when new positon is equal to number of labels lists' do
+ service = described_class.new(project, user, id: planning.id, position: board.lists.label.size)
+
+ service.execute
+
+ expect(current_list_positions).to eq [0, 1, 2, 3]
end
it 'keeps position of lists when new positon is greater than number of labels lists' do
- service = described_class.new(project, user, id: planning.id, position: 6)
+ service = described_class.new(project, user, id: planning.id, position: board.lists.label.size + 1)
service.execute
- expect(current_list_positions).to eq [1, 2, 3, 4]
+ expect(current_list_positions).to eq [0, 1, 2, 3]
end
it 'increments position of intermediate lists when new positon is equal to first position' do
- service = described_class.new(project, user, id: staging.id, position: 1)
+ service = described_class.new(project, user, id: staging.id, position: 0)
service.execute
- expect(current_list_positions).to eq [2, 3, 4, 1]
+ expect(current_list_positions).to eq [1, 2, 3, 0]
end
it 'decrements position of intermediate lists when new positon is equal to last position' do
- service = described_class.new(project, user, id: planning.id, position: 4)
+ service = described_class.new(project, user, id: planning.id, position: board.lists.label.last.position)
service.execute
- expect(current_list_positions).to eq [4, 1, 2, 3]
+ expect(current_list_positions).to eq [3, 0, 1, 2]
end
it 'decrements position of intermediate lists when new position is greater than old position' do
- service = described_class.new(project, user, id: planning.id, position: 3)
+ service = described_class.new(project, user, id: planning.id, position: 2)
service.execute
- expect(current_list_positions).to eq [3, 1, 2, 4]
+ expect(current_list_positions).to eq [2, 0, 1, 3]
end
it 'increments position of intermediate lists when new position is lower than old position' do
- service = described_class.new(project, user, id: staging.id, position: 2)
+ service = described_class.new(project, user, id: staging.id, position: 1)
service.execute
- expect(current_list_positions).to eq [1, 3, 4, 2]
+ expect(current_list_positions).to eq [0, 2, 3, 1]
end
end
@@ -84,7 +92,7 @@ describe Boards::Lists::MoveService, services: true do
service.execute
- expect(current_list_positions).to eq [1, 2, 3, 4]
+ expect(current_list_positions).to eq [0, 1, 2, 3]
end
it 'keeps position of lists when list type is done' do
@@ -92,7 +100,7 @@ describe Boards::Lists::MoveService, services: true do
service.execute
- expect(current_list_positions).to eq [1, 2, 3, 4]
+ expect(current_list_positions).to eq [0, 1, 2, 3]
end
end