diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/requests/api/group_export_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/requests/api/group_export_spec.rb')
-rw-r--r-- | spec/requests/api/group_export_spec.rb | 129 |
1 files changed, 48 insertions, 81 deletions
diff --git a/spec/requests/api/group_export_spec.rb b/spec/requests/api/group_export_spec.rb index 31eef21654a..ffa313d4464 100644 --- a/spec/requests/api/group_export_spec.rb +++ b/spec/requests/api/group_export_spec.rb @@ -30,76 +30,62 @@ RSpec.describe API::GroupExport do group.add_owner(user) end - context 'group_import_export feature flag enabled' do + context 'when export file exists' do before do - stub_feature_flags(group_import_export: true) - allow(Gitlab::ApplicationRateLimiter) .to receive(:increment) .and_return(0) - end - - 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 - it 'downloads exported group archive' do - get api(download_path, user) - - expect(response).to have_gitlab_http_status(:ok) - end + upload.export_file = fixture_file_upload('spec/fixtures/group_export.tar.gz', "`/tar.gz") + upload.save! + 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 'downloads exported group archive' do + get api(download_path, user) - it 'returns 404' do - get api(download_path, user) + expect(response).to have_gitlab_http_status(:ok) + end - expect(response).to have_gitlab_http_status(:not_found) + 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 - context 'when object is not present' do - let(:other_group) { create(:group, :with_export) } - let(:other_download_path) { "/groups/#{other_group.id}/export/download" } + it 'returns 404' do + get api(download_path, user) - before do - other_group.add_owner(user) - other_group.export_file.file.delete - end + expect(response).to have_gitlab_http_status(:not_found) + end + end - it 'returns 404' do - get api(other_download_path, user) + context 'when object is not present' do + let(:other_group) { create(:group, :with_export) } + let(:other_download_path) { "/groups/#{other_group.id}/export/download" } - expect(response).to have_gitlab_http_status(:not_found) - expect(json_response['message']).to eq('The group export file is not available yet') - end + before do + other_group.add_owner(user) + other_group.export_file.file.delete end - end - context 'when export file does not exist' do it 'returns 404' do - get api(download_path, user) + get api(other_download_path, user) expect(response).to have_gitlab_http_status(:not_found) + expect(json_response['message']).to eq('The group export file is not available yet') end end end - 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 + context 'when export file does not exist' do + it 'returns 404' do get api(download_path, user) + allow(Gitlab::ApplicationRateLimiter) + .to receive(:increment) + .and_return(0) + expect(response).to have_gitlab_http_status(:not_found) end end @@ -122,58 +108,40 @@ RSpec.describe API::GroupExport do end describe 'POST /groups/:group_id/export' do - context 'group_import_export feature flag enabled' do + context 'when user is a group owner' do before do - stub_feature_flags(group_import_export: true) + group.add_owner(user) end - context 'when user is a group owner' do - before do - group.add_owner(user) - end - - it 'accepts download' do - post api(path, user) + it 'accepts download' do + post api(path, user) - expect(response).to have_gitlab_http_status(:accepted) - end + expect(response).to have_gitlab_http_status(:accepted) end + end - context 'when the export cannot be started' do - before do - group.add_owner(user) - allow(GroupExportWorker).to receive(:perform_async).and_return(nil) - end - - it 'returns an error' do - post api(path, user) - - expect(response).to have_gitlab_http_status(:error) - end + context 'when the export cannot be started' do + before do + group.add_owner(user) + allow(GroupExportWorker).to receive(:perform_async).and_return(nil) end - context 'when user is not a group owner' do - before do - group.add_developer(user) - end - - it 'forbids the request' do - post api(path, user) + it 'returns an error' do + post api(path, user) - expect(response).to have_gitlab_http_status(:forbidden) - end + expect(response).to have_gitlab_http_status(:error) end end - context 'group_import_export feature flag disabled' do + context 'when user is not a group owner' do before do - stub_feature_flags(group_import_export: false) + group.add_developer(user) end - it 'responds with 404 Not Found' do + it 'forbids the request' do post api(path, user) - expect(response).to have_gitlab_http_status(:not_found) + expect(response).to have_gitlab_http_status(:forbidden) end end @@ -202,7 +170,6 @@ RSpec.describe API::GroupExport do let(:status_path) { "/groups/#{group.id}/export_relations/status" } before do - stub_feature_flags(group_import_export: true) group.add_owner(user) end |