diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 15:44:42 +0000 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /spec/workers/issuables | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) | |
download | gitlab-ce-4555e1b21c365ed8303ffb7a3325d773c9b8bf31.tar.gz |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'spec/workers/issuables')
-rw-r--r-- | spec/workers/issuables/clear_groups_issue_counter_worker_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/workers/issuables/clear_groups_issue_counter_worker_spec.rb b/spec/workers/issuables/clear_groups_issue_counter_worker_spec.rb new file mode 100644 index 00000000000..ac430f42e7a --- /dev/null +++ b/spec/workers/issuables/clear_groups_issue_counter_worker_spec.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Issuables::ClearGroupsIssueCounterWorker do + describe '#perform' do + let_it_be(:user) { create(:user) } + let_it_be(:parent_group) { create(:group) } + let_it_be(:root_group) { create(:group, parent: parent_group) } + let_it_be(:subgroup) { create(:group, parent: root_group) } + + let(:count_service) { Groups::OpenIssuesCountService } + let(:instance1) { instance_double(count_service) } + let(:instance2) { instance_double(count_service) } + + it_behaves_like 'an idempotent worker' do + let(:job_args) { [[root_group.id]] } + let(:exec_times) { IdempotentWorkerHelper::WORKER_EXEC_TIMES } + + it 'clears the cached issue count in given groups and ancestors' do + expect(count_service).to receive(:new) + .exactly(exec_times).times.with(root_group).and_return(instance1) + expect(count_service).to receive(:new) + .exactly(exec_times).times.with(parent_group).and_return(instance2) + expect(count_service).not_to receive(:new).with(subgroup) + + [instance1, instance2].all? do |instance| + expect(instance).to receive(:clear_all_cache_keys).exactly(exec_times).times + end + + subject + end + end + + it 'does not call count service or rise error when group_ids is empty' do + expect(count_service).not_to receive(:new) + expect(Gitlab::ErrorTracking).not_to receive(:log_exception) + + described_class.new.perform([]) + end + end +end |