diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 21:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 21:10:03 +0300 |
commit | 24f8aa38dc0ddd3489f0c98d5dd0517096caf05e (patch) | |
tree | eaa46caaad6cb5b0e3f4b59ac930c7c2d36396ce /spec/workers | |
parent | be4b3134a282f7a8812306777abd2d3150deecdc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/bulk_imports/relation_export_worker_spec.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/spec/workers/bulk_imports/relation_export_worker_spec.rb b/spec/workers/bulk_imports/relation_export_worker_spec.rb new file mode 100644 index 00000000000..63f1992d186 --- /dev/null +++ b/spec/workers/bulk_imports/relation_export_worker_spec.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe BulkImports::RelationExportWorker do + let_it_be(:jid) { 'jid' } + let_it_be(:relation) { 'labels' } + let_it_be(:user) { create(:user) } + let_it_be(:group) { create(:group) } + + let(:job_args) { [user.id, group.id, group.class.name, relation] } + + describe '#perform' do + include_examples 'an idempotent worker' do + context 'when export record does not exist' do + let(:another_group) { create(:group) } + let(:job_args) { [user.id, another_group.id, another_group.class.name, relation] } + + it 'creates export record' do + another_group.add_owner(user) + + expect { perform_multiple(job_args) } + .to change { another_group.bulk_import_exports.count } + .from(0) + .to(1) + end + end + + it 'executes RelationExportService' do + group.add_owner(user) + + service = instance_double(BulkImports::RelationExportService) + + expect(BulkImports::RelationExportService) + .to receive(:new) + .with(user, group, relation, anything) + .twice + .and_return(service) + expect(service) + .to receive(:execute) + .twice + + perform_multiple(job_args) + end + end + end +end |