blob: 5096691270a4cf03152e7246141cb31bf6300b18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Ci::PipelineArtifacts::CreateQualityReportWorker do
describe '#perform' do
subject { described_class.new.perform(pipeline_id) }
context 'when pipeline exists' do
let(:pipeline) { create(:ci_pipeline, :with_codequality_reports) }
let(:pipeline_id) { pipeline.id }
it 'calls pipeline codequality report service' do
expect_next_instance_of(::Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService) do |quality_report_service|
expect(quality_report_service).to receive(:execute)
end
subject
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { pipeline_id }
it 'does not create another pipeline artifact if already has one' do
expect { subject }.not_to change { pipeline.pipeline_artifacts.count }
end
end
end
context 'when pipeline does not exist' do
let(:pipeline_id) { non_existing_record_id }
it 'does not call pipeline codequality report service' do
expect(Ci::PipelineArtifacts::CreateCodeQualityMrDiffReportService).not_to receive(:execute)
subject
end
end
end
end
|