diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-29 15:10:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-29 15:10:08 +0000 |
commit | 20fda899a62cc27a4d40a168640e7e926c69eb62 (patch) | |
tree | 8fa2bca2431010c15b681fdec8c0cfba2ad78885 /spec/workers | |
parent | 933a571ac8c9ada219dd15079221ff3dba8043be (diff) | |
download | gitlab-ce-20fda899a62cc27a4d40a168640e7e926c69eb62.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
3 files changed, 112 insertions, 0 deletions
diff --git a/spec/workers/propagate_integration_group_worker_spec.rb b/spec/workers/propagate_integration_group_worker_spec.rb new file mode 100644 index 00000000000..b3c9255db57 --- /dev/null +++ b/spec/workers/propagate_integration_group_worker_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe PropagateIntegrationGroupWorker do + describe '#perform' do + let_it_be(:group1) { create(:group) } + let_it_be(:group2) { create(:group) } + let_it_be(:integration) { create(:redmine_service, :instance) } + + before do + allow(BulkCreateIntegrationService).to receive(:new) + .with(integration, match_array([group1, group2]), 'group') + .and_return(double(execute: nil)) + end + + it_behaves_like 'an idempotent worker' do + let(:job_args) { [integration.id, group1.id, group2.id] } + + it 'calls to BulkCreateIntegrationService' do + expect(BulkCreateIntegrationService).to receive(:new) + .with(integration, match_array([group1, group2]), 'group') + .and_return(double(execute: nil)) + + subject + end + end + + context 'with an invalid integration id' do + it 'returns without failure' do + expect(BulkCreateIntegrationService).not_to receive(:new) + + subject.perform(0, group1.id, group2.id) + end + end + end +end diff --git a/spec/workers/propagate_integration_inherit_worker_spec.rb b/spec/workers/propagate_integration_inherit_worker_spec.rb new file mode 100644 index 00000000000..88946b9926e --- /dev/null +++ b/spec/workers/propagate_integration_inherit_worker_spec.rb @@ -0,0 +1,38 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe PropagateIntegrationInheritWorker do + describe '#perform' do + let_it_be(:integration) { create(:redmine_service, :instance) } + let_it_be(:integration1) { create(:redmine_service, inherit_from_id: integration.id) } + let_it_be(:integration2) { create(:bugzilla_service, inherit_from_id: integration.id) } + let_it_be(:integration3) { create(:redmine_service) } + + before do + allow(BulkUpdateIntegrationService).to receive(:new) + .with(integration, match_array(integration1)) + .and_return(double(execute: nil)) + end + + it_behaves_like 'an idempotent worker' do + let(:job_args) { [integration.id, integration1.id, integration3.id] } + + it 'calls to BulkCreateIntegrationService' do + expect(BulkUpdateIntegrationService).to receive(:new) + .with(integration, match_array(integration1)) + .and_return(double(execute: nil)) + + subject + end + end + + context 'with an invalid integration id' do + it 'returns without failure' do + expect(BulkUpdateIntegrationService).not_to receive(:new) + + subject.perform(0, integration1.id, integration3.id) + end + end + end +end diff --git a/spec/workers/propagate_integration_project_worker_spec.rb b/spec/workers/propagate_integration_project_worker_spec.rb new file mode 100644 index 00000000000..3742ce5fde8 --- /dev/null +++ b/spec/workers/propagate_integration_project_worker_spec.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe PropagateIntegrationProjectWorker do + describe '#perform' do + let_it_be(:project1) { create(:project) } + let_it_be(:project2) { create(:project) } + let_it_be(:integration) { create(:redmine_service, :instance) } + + before do + allow(BulkCreateIntegrationService).to receive(:new) + .with(integration, match_array([project1, project2]), 'project') + .and_return(double(execute: nil)) + end + + it_behaves_like 'an idempotent worker' do + let(:job_args) { [integration.id, project1.id, project2.id] } + + it 'calls to BulkCreateIntegrationService' do + expect(BulkCreateIntegrationService).to receive(:new) + .with(integration, match_array([project1, project2]), 'project') + .and_return(double(execute: nil)) + + subject + end + end + + context 'with an invalid integration id' do + it 'returns without failure' do + expect(BulkCreateIntegrationService).not_to receive(:new) + + subject.perform(0, project1.id, project2.id) + end + end + end +end |