diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-19 01:45:44 +0000 |
commit | 85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch) | |
tree | 9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/workers/issue_rebalancing_worker_spec.rb | |
parent | 15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff) | |
download | gitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/workers/issue_rebalancing_worker_spec.rb')
-rw-r--r-- | spec/workers/issue_rebalancing_worker_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/workers/issue_rebalancing_worker_spec.rb b/spec/workers/issue_rebalancing_worker_spec.rb new file mode 100644 index 00000000000..8b0fcd4bc5a --- /dev/null +++ b/spec/workers/issue_rebalancing_worker_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe IssueRebalancingWorker do + describe '#perform' do + let_it_be(:issue) { create(:issue) } + + it 'runs an instance of IssueRebalancingService' do + service = double(execute: nil) + expect(IssueRebalancingService).to receive(:new).with(issue).and_return(service) + + described_class.new.perform(nil, issue.project_id) + end + + it 'anticipates the inability to find the issue' do + expect(Gitlab::ErrorTracking).to receive(:log_exception).with(ActiveRecord::RecordNotFound, include(project_id: -1)) + expect(IssueRebalancingService).not_to receive(:new) + + described_class.new.perform(nil, -1) + end + + it 'anticipates there being too many issues' do + service = double + allow(service).to receive(:execute) { raise IssueRebalancingService::TooManyIssues } + expect(IssueRebalancingService).to receive(:new).with(issue).and_return(service) + expect(Gitlab::ErrorTracking).to receive(:log_exception).with(IssueRebalancingService::TooManyIssues, include(project_id: issue.project_id)) + + described_class.new.perform(nil, issue.project_id) + end + + it 'takes no action if the value is nil' do + expect(IssueRebalancingService).not_to receive(:new) + expect(Gitlab::ErrorTracking).not_to receive(:log_exception) + + described_class.new.perform(nil, nil) + end + end +end |