Commit 52563cde authored by Alex Kalderimis's avatar Alex Kalderimis

Merge branch '351178_set_name_for_proxy_classes' into 'master'

Set class name for the proxy ingestion tasks

See merge request gitlab-org/gitlab!79169
parents ce9b6707 23c66ba0
......@@ -39,6 +39,8 @@ module Security
def klass
@klass ||= Class.new(model).tap do |klass|
remove_validations(klass)
model.const_set("BulkInsertableProxy", klass)
end.include(BulkInsertSafe)
end
......
......@@ -22,5 +22,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestFindingIdentifiers do
expect { ingest_finding_identifiers }.to change { Vulnerabilities::FindingIdentifier.count }.by(1)
.and change { finding_2.reload.identifiers }.from([]).to([identifier])
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -41,5 +41,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestFindingLinks do
.and change { finding_1.finding_links.count }.by(0)
end
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -14,5 +14,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestFindingPipelines do
it 'associates the findings with pipeline' do
expect { ingest_finding_pipelines }.to change { finding.finding_pipelines.pluck(:pipeline_id) }.from([]).to([pipeline.id])
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -24,5 +24,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestFindingSignatures do
expect { ingest_finding_signatures }.to change { Vulnerabilities::FindingSignature.count }.by(1)
.and change { finding_2.signatures.count }.by(1)
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -23,5 +23,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestFindings do
expect {ingest_findings }.to change { finding_maps.map(&:finding_id) }.from(Array.new(4)).to(expected_finding_ids)
.and change { finding_maps.map(&:vulnerability_id) }.from(Array.new(4)).to(expected_vulnerability_ids)
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -31,5 +31,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestIdentifiers do
.from([])
.to(expected_fingerprints))
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -32,5 +32,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestIssueLinks do
it 'ingests the issue links only for the new records' do
expect { ingest_issue_links }.to change { Vulnerabilities::IssueLink.for_issue(feedback.issue).count }.by(1)
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -32,5 +32,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestRemediations do
.and change { finding_2.reload.association(:remediations).scope.count }.from(0).to(2)
.and not_change { finding_1.reload.association(:remediations).scope.count }.from(2)
end
it_behaves_like 'bulk insertable task'
end
end
......@@ -28,5 +28,7 @@ RSpec.describe Security::Ingestion::Tasks::IngestVulnerabilityFlags do
it 'deletes the old records' do
expect { ingest_vulnerability_flags }.to change { Vulnerabilities::Flag.find_by_id(existing_vulnerability_flag_1.id) }.to(nil)
end
it_behaves_like 'bulk insertable task'
end
end
# frozen_string_literal: true
RSpec.shared_examples 'bulk insertable task' do
context 'when the validation fails' do
let(:proxy_class_instance) { described_class.klass.new }
before do
proxy_class_instance.errors.add(:attribute, 'is invalid')
end
it 'can generate error messages correctly' do
expect(proxy_class_instance.errors.full_messages).to contain_exactly 'Attribute is invalid'
end
end
end
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