diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-16 03:08:33 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-16 03:08:33 +0300 |
commit | 292d054661cc3e24bb1a4be98dacfd41fa7ad14e (patch) | |
tree | d8a5c9a566603521d1f123130e50cc86938b928e /spec/requests | |
parent | ecfcccb684722316df4cd6c999a2716b44413733 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/project_repository_storage_moves_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/requests/api/project_repository_storage_moves_spec.rb b/spec/requests/api/project_repository_storage_moves_spec.rb index 8d361cf3fd9..40966e31d0d 100644 --- a/spec/requests/api/project_repository_storage_moves_spec.rb +++ b/spec/requests/api/project_repository_storage_moves_spec.rb @@ -111,4 +111,45 @@ describe API::ProjectRepositoryStorageMoves do let(:url) { "/projects/#{project.id}/repository_storage_moves/#{project_repository_storage_move_id}" } end end + + describe 'POST /projects/:id/repository_storage_moves' do + let(:url) { "/projects/#{project.id}/repository_storage_moves" } + let(:destination_storage_name) { 'test_second_storage' } + + def create_project_repository_storage_move + post api(url, user), params: { destination_storage_name: destination_storage_name } + end + + before do + stub_storage_settings('test_second_storage' => { 'path' => 'tmp/tests/extra_storage' }) + end + + it 'schedules a project repository storage move' do + create_project_repository_storage_move + + storage_move = project.repository_storage_moves.last + + expect(response).to have_gitlab_http_status(:created) + expect(response).to match_response_schema('public_api/v4/project_repository_storage_move') + expect(json_response['id']).to eq(storage_move.id) + expect(json_response['state']).to eq('scheduled') + expect(json_response['source_storage_name']).to eq('default') + expect(json_response['destination_storage_name']).to eq(destination_storage_name) + end + + describe 'permissions' do + it { expect { create_project_repository_storage_move }.to be_allowed_for(:admin) } + it { expect { create_project_repository_storage_move }.to be_denied_for(:user) } + end + + context 'destination_storage_name is missing' do + let(:destination_storage_name) { nil } + + it 'returns a validation error' do + create_project_repository_storage_move + + expect(response).to have_gitlab_http_status(:bad_request) + end + end + end end |