2019-10-17 15:06:17 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-11-18 21:09:32 +00:00
|
|
|
RSpec.describe Releases::CreateEvidenceWorker do
|
2020-06-16 15:08:32 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:release) { create(:release, project: project) }
|
|
|
|
let(:pipeline) { create(:ci_empty_pipeline, sha: release.sha, project: project) }
|
2019-10-17 15:06:17 +00:00
|
|
|
|
2020-06-16 15:08:32 +00:00
|
|
|
# support old scheduled workers without pipeline
|
2020-03-24 12:09:42 +00:00
|
|
|
it 'creates a new Evidence record' do
|
2020-06-16 15:08:32 +00:00
|
|
|
expect_next_instance_of(::Releases::CreateEvidenceService, release, pipeline: nil) do |service|
|
2020-06-02 18:08:32 +00:00
|
|
|
expect(service).to receive(:execute).and_call_original
|
|
|
|
end
|
|
|
|
|
2020-03-24 12:09:42 +00:00
|
|
|
expect { described_class.new.perform(release.id) }.to change(Releases::Evidence, :count).by(1)
|
2019-10-17 15:06:17 +00:00
|
|
|
end
|
2020-06-16 15:08:32 +00:00
|
|
|
|
|
|
|
it 'creates a new Evidence record with pipeline' do
|
|
|
|
expect_next_instance_of(::Releases::CreateEvidenceService, release, pipeline: pipeline) do |service|
|
|
|
|
expect(service).to receive(:execute).and_call_original
|
|
|
|
end
|
|
|
|
|
|
|
|
expect { described_class.new.perform(release.id, pipeline.id) }.to change(Releases::Evidence, :count).by(1)
|
|
|
|
end
|
2019-10-17 15:06:17 +00:00
|
|
|
end
|