summaryrefslogtreecommitdiff
path: root/spec/controllers
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-01 17:11:56 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-17 12:58:58 -0300
commit0fb9210dbb38cd45fc8da052317a9aaf830e1db9 (patch)
tree62a34f98cb2eae7d87352654789a916c3e3427da /spec/controllers
parent4f45d11363c4bedb9a68fc461d931abf6f93b5f0 (diff)
downloadgitlab-ce-0fb9210dbb38cd45fc8da052317a9aaf830e1db9.tar.gz
Add endpoint to allow users to move lists
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/projects/board_lists_controller_spec.rb52
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/controllers/projects/board_lists_controller_spec.rb b/spec/controllers/projects/board_lists_controller_spec.rb
index 906edeb1c17..c34e815c164 100644
--- a/spec/controllers/projects/board_lists_controller_spec.rb
+++ b/spec/controllers/projects/board_lists_controller_spec.rb
@@ -46,4 +46,56 @@ describe Projects::BoardListsController do
end
end
end
+
+ describe 'PATCH #update' do
+ let!(:planning) { create(:list, board: project.board, position: 1) }
+ let!(:development) { create(:list, board: project.board, position: 2) }
+
+ context 'with valid position' do
+ it 'returns a successful 200 response' do
+ patch :update, namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: planning.to_param,
+ list: { position: 2 },
+ format: :json
+
+ expect(response).to have_http_status(200)
+ end
+
+ it 'moves the list to the desired position' do
+ patch :update, namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: planning.to_param,
+ list: { position: 2 },
+ format: :json
+
+ expect(planning.reload.position).to eq 2
+ end
+ end
+
+ context 'with invalid position' do
+ it 'returns a unprocessable entity 422 response' do
+ patch :update, namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: planning.to_param,
+ list: { position: 6 },
+ format: :json
+
+ expect(response).to have_http_status(422)
+ end
+ end
+
+ context 'with invalid list id' do
+ it 'returns a not found 404 response' do
+ patch :update, namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: 999,
+ list: { position: 2 },
+ format: :json
+
+ expect(response).to have_http_status(404)
+ end
+ end
+ end
+ end
end