Commit 91eee51f authored by Michael Kozono's avatar Michael Kozono

Merge branch 'refactoring-merge-job-artifact-spec' into 'master'

Test EE::Ci::JobArtifact in proper spec

See merge request gitlab-org/gitlab!24179
parents 1bbf9af7 233fdeb8
# frozen_string_literal: true
require 'spec_helper'
describe Ci::JobArtifact do
include EE::GeoHelpers
describe '#destroy' do
let_it_be(:primary) { create(:geo_node, :primary) }
let_it_be(:secondary) { create(:geo_node) }
it 'creates a JobArtifactDeletedEvent' do
stub_current_geo_node(primary)
job_artifact = create(:ci_job_artifact, :archive)
expect do
job_artifact.destroy
end.to change { Geo::JobArtifactDeletedEvent.count }.by(1)
end
end
describe '.security_reports' do
subject { described_class.security_reports }
context 'when there is a security report' do
let!(:artifact) { create(:ee_ci_job_artifact, :sast) }
it { is_expected.to eq([artifact]) }
end
context 'when there are no security reports' do
let!(:artifact) { create(:ci_job_artifact, :archive) }
it { is_expected.to be_empty }
end
end
end
......@@ -3,6 +3,23 @@
require 'spec_helper'
describe EE::Ci::JobArtifact do
include EE::GeoHelpers
describe '#destroy' do
let_it_be(:primary) { create(:geo_node, :primary) }
let_it_be(:secondary) { create(:geo_node) }
it 'creates a JobArtifactDeletedEvent' do
stub_current_geo_node(primary)
job_artifact = create(:ee_ci_job_artifact, :archive)
expect do
job_artifact.destroy
end.to change { Geo::JobArtifactDeletedEvent.count }.by(1)
end
end
describe '.license_scanning_reports' do
subject { Ci::JobArtifact.license_scanning_reports }
......@@ -35,6 +52,22 @@ describe EE::Ci::JobArtifact do
end
end
describe '.security_reports' do
subject { Ci::JobArtifact.security_reports }
context 'when there is a security report' do
let!(:artifact) { create(:ee_ci_job_artifact, :sast) }
it { is_expected.to eq([artifact]) }
end
context 'when there are no security reports' do
let!(:artifact) { create(:ci_job_artifact, :archive) }
it { is_expected.to be_empty }
end
end
describe '.associated_file_types_for' do
using RSpec::Parameterized::TableSyntax
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment