diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 15:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-09 15:09:24 +0300 |
commit | a9ced7da447785c57477b3d8dbccc73a78cface1 (patch) | |
tree | 5179d27ab9d801748ee4ed1c64c985974e799812 /spec/services/groups | |
parent | ad0265eead72a624ce7a020847db4f0f0c877e57 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/groups')
-rw-r--r-- | spec/services/groups/import_export/export_service_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/services/groups/import_export/export_service_spec.rb b/spec/services/groups/import_export/export_service_spec.rb index 0d7fa98e16b..e026d2166d6 100644 --- a/spec/services/groups/import_export/export_service_spec.rb +++ b/spec/services/groups/import_export/export_service_spec.rb @@ -3,6 +3,37 @@ require 'spec_helper' describe Groups::ImportExport::ExportService do + describe '#async_execute' do + let(:user) { create(:user) } + let(:group) { create(:group) } + + context 'when the job can be successfully scheduled' do + let(:export_service) { described_class.new(group: group, user: user) } + + it 'enqueues an export job' do + expect(GroupExportWorker).to receive(:perform_async).with(user.id, group.id, {}) + + export_service.async_execute + end + + it 'returns truthy' do + expect(export_service.async_execute).to be_present + end + end + + context 'when the job cannot be scheduled' do + let(:export_service) { described_class.new(group: group, user: user) } + + before do + allow(GroupExportWorker).to receive(:perform_async).and_return(nil) + end + + it 'returns falsey' do + expect(export_service.async_execute).to be_falsey + end + end + end + describe '#execute' do let!(:user) { create(:user) } let(:group) { create(:group) } @@ -103,5 +134,23 @@ describe Groups::ImportExport::ExportService do end end end + + context 'when there is an existing export file' do + subject(:export_service) { described_class.new(group: group, user: user) } + + let(:import_export_upload) do + create( + :import_export_upload, + group: group, + export_file: fixture_file_upload('spec/fixtures/group_export.tar.gz') + ) + end + + it 'removes it' do + existing_file = import_export_upload.export_file + + expect { export_service.execute }.to change { existing_file.file }.to(be_nil) + end + end end end |