diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 15:08:44 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-28 15:08:44 +0300 |
commit | db24ab2b72dbff24c201410a0561e929ae7e8061 (patch) | |
tree | 67297286aad8cc590ae325330a0bfe1e2a7e51dc /spec/requests/api/group_export_spec.rb | |
parent | 7e8278c0f46cf6058efad5afd0aef177977bd663 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests/api/group_export_spec.rb')
-rw-r--r-- | spec/requests/api/group_export_spec.rb | 80 |
1 files changed, 58 insertions, 22 deletions
diff --git a/spec/requests/api/group_export_spec.rb b/spec/requests/api/group_export_spec.rb index ac4853e5388..6128f2e4a87 100644 --- a/spec/requests/api/group_export_spec.rb +++ b/spec/requests/api/group_export_spec.rb @@ -30,25 +30,39 @@ describe API::GroupExport do group.add_owner(user) end - context 'when export file exists' do + context 'group_import_export feature flag enabled' do before do - upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz") - upload.save! + stub_feature_flags(group_import_export: true) end - it 'downloads exported group archive' do - get api(download_path, user) + context 'when export file exists' do + before do + upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz") + upload.save! + end - expect(response).to have_gitlab_http_status(200) - end + it 'downloads exported group archive' do + get api(download_path, user) - context 'when export_file.file does not exist' do - before do - expect_next_instance_of(ImportExportUploader) do |uploader| - expect(uploader).to receive(:file).and_return(nil) + expect(response).to have_gitlab_http_status(200) + end + + context 'when export_file.file does not exist' do + before do + expect_next_instance_of(ImportExportUploader) do |uploader| + expect(uploader).to receive(:file).and_return(nil) + end + end + + it 'returns 404' do + get api(download_path, user) + + expect(response).to have_gitlab_http_status(404) end end + end + context 'when export file does not exist' do it 'returns 404' do get api(download_path, user) @@ -57,8 +71,12 @@ describe API::GroupExport do end end - context 'when export file does not exist' do - it 'returns 404' do + context 'group_import_export feature flag disabled' do + before do + stub_feature_flags(group_import_export: false) + end + + it 'responds with 404 Not Found' do get api(download_path, user) expect(response).to have_gitlab_http_status(404) @@ -67,27 +85,45 @@ describe API::GroupExport do end describe 'POST /groups/:group_id/export' do - context 'when user is a group owner' do + context 'group_import_export feature flag enabled' do before do - group.add_owner(user) + stub_feature_flags(group_import_export: true) end - it 'accepts download' do - post api(path, user) + context 'when user is a group owner' do + before do + group.add_owner(user) + end + + it 'accepts download' do + post api(path, user) + + expect(response).to have_gitlab_http_status(202) + end + end + + context 'when user is not a group owner' do + before do + group.add_developer(user) + end - expect(response).to have_gitlab_http_status(202) + it 'forbids the request' do + post api(path, user) + + expect(response).to have_gitlab_http_status(403) + end end end - context 'when user is not a group owner' do + context 'group_import_export feature flag disabled' do before do - group.add_developer(user) + stub_feature_flags(group_import_export: false) end - it 'forbids the request' do + it 'responds with 404 Not Found' do post api(path, user) - expect(response).to have_gitlab_http_status(403) + expect(response).to have_gitlab_http_status(404) end end end |