debian-mirror-gitlab/spec/workers/ci/pipeline_artifacts/create_quality_report_worker_spec.rb
2021-03-11 19:13:27 +05:30

41 lines
1.2 KiB
Ruby

# 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 'creates a pipeline artifact' do
expect { subject }.to change { pipeline.pipeline_artifacts.count }.by(1)
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