diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 18:10:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-17 18:10:42 +0000 |
commit | 49bb78aac34a111c0fb13aae3a83b078be351fd3 (patch) | |
tree | 510df08e78b39ef88631f8f25bdc371a4661caa9 /spec/workers | |
parent | 68c476dbd8a2c670aeeebffce8b63b554a3ac7f0 (diff) | |
download | gitlab-ce-49bb78aac34a111c0fb13aae3a83b078be351fd3.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/ci/retry_pipeline_worker_spec.rb | 51 | ||||
-rw-r--r-- | spec/workers/issue_placement_worker_spec.rb | 16 | ||||
-rw-r--r-- | spec/workers/issue_rebalancing_worker_spec.rb | 16 |
3 files changed, 81 insertions, 2 deletions
diff --git a/spec/workers/ci/retry_pipeline_worker_spec.rb b/spec/workers/ci/retry_pipeline_worker_spec.rb new file mode 100644 index 00000000000..c7600a24280 --- /dev/null +++ b/spec/workers/ci/retry_pipeline_worker_spec.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Ci::RetryPipelineWorker do + describe '#perform' do + subject(:perform) { described_class.new.perform(pipeline_id, user_id) } + + let(:pipeline) { create(:ci_pipeline) } + + context 'when pipeline exists' do + let(:pipeline_id) { pipeline.id } + + context 'when user exists' do + let(:user) { create(:user) } + let(:user_id) { user.id } + + before do + pipeline.project.add_maintainer(user) + end + + it 'retries the pipeline' do + expect(::Ci::Pipeline).to receive(:find_by_id).with(pipeline.id).and_return(pipeline) + expect(pipeline).to receive(:retry_failed).with(having_attributes(id: user_id)) + + perform + end + end + + context 'when user does not exist' do + let(:user_id) { 1234 } + + it 'does not retry the pipeline' do + expect(::Ci::Pipeline).to receive(:find_by_id).with(pipeline_id).and_return(pipeline) + expect(pipeline).not_to receive(:retry_failed).with(having_attributes(id: user_id)) + + perform + end + end + end + + context 'when pipeline does not exist' do + let(:pipeline_id) { 1234 } + let(:user_id) { 1234 } + + it 'returns nil' do + expect(perform).to be_nil + end + end + end +end diff --git a/spec/workers/issue_placement_worker_spec.rb b/spec/workers/issue_placement_worker_spec.rb index 2fca7a590fd..e0c17bfadee 100644 --- a/spec/workers/issue_placement_worker_spec.rb +++ b/spec/workers/issue_placement_worker_spec.rb @@ -5,7 +5,8 @@ require 'spec_helper' RSpec.describe IssuePlacementWorker do describe '#perform' do let_it_be(:time) { Time.now.utc } - let_it_be(:project) { create(:project) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } let_it_be(:author) { create(:user) } let_it_be(:common_attrs) { { author: author, project: project } } let_it_be(:unplaced) { common_attrs.merge(relative_position: nil) } @@ -117,6 +118,19 @@ RSpec.describe IssuePlacementWorker do let(:worker_arguments) { { issue_id: issue_id, project_id: nil } } it_behaves_like 'running the issue placement worker' + + context 'when block_issue_repositioning is enabled' do + let(:issue_id) { issue.id } + let(:project_id) { project.id } + + before do + stub_feature_flags(block_issue_repositioning: group) + end + + it 'does not run repositioning tasks' do + expect { run_worker }.not_to change { issue.reset.relative_position } + end + end end context 'passing a project ID' do diff --git a/spec/workers/issue_rebalancing_worker_spec.rb b/spec/workers/issue_rebalancing_worker_spec.rb index 8b0fcd4bc5a..e5c6ac3f854 100644 --- a/spec/workers/issue_rebalancing_worker_spec.rb +++ b/spec/workers/issue_rebalancing_worker_spec.rb @@ -4,7 +4,21 @@ require 'spec_helper' RSpec.describe IssueRebalancingWorker do describe '#perform' do - let_it_be(:issue) { create(:issue) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:issue) { create(:issue, project: project) } + + context 'when block_issue_repositioning is enabled' do + before do + stub_feature_flags(block_issue_repositioning: group) + end + + it 'does not run an instance of IssueRebalancingService' do + expect(IssueRebalancingService).not_to receive(:new) + + described_class.new.perform(nil, issue.project_id) + end + end it 'runs an instance of IssueRebalancingService' do service = double(execute: nil) |