Commit f2fff5ac authored by Luke Duncalfe's avatar Luke Duncalfe

Merge branch 'use_to_h' into 'master'

Use to_h instead of to_hash for vulnerability_flag

See merge request gitlab-org/gitlab!70530
parents 91f255b4 06dcfe84
......@@ -15,7 +15,7 @@ module Vulnerabilities
}
def initialize(attributes)
attributes = attributes.to_hash if attributes.instance_of?(Gitlab::Ci::Reports::Security::Flag)
attributes = attributes.to_h if attributes.respond_to?(:to_h)
super(attributes)
end
end
......
......@@ -269,7 +269,7 @@ module Security
vulnerability_finding_to_finding_map.each_slice(BATCH_SIZE) do |vf_to_findings|
records = vf_to_findings.flat_map do |vulnerability_finding, finding|
finding.flags.map { |flag| timestamps.merge(**flag.to_hash, vulnerability_occurrence_id: vulnerability_finding.id) }
finding.flags.map { |flag| timestamps.merge(**flag.to_h, vulnerability_occurrence_id: vulnerability_finding.id) }
end
records.uniq!
......
......@@ -20,7 +20,7 @@ module Gitlab
@description = description
end
def to_hash
def to_h
{
flag_type: flag_type,
origin: origin,
......
......@@ -18,9 +18,9 @@ RSpec.describe Gitlab::Ci::Reports::Security::Flag do
end
end
describe '#to_hash' do
describe '#to_h' do
it 'returns expected hash' do
expect(security_flag.to_hash).to eq(
expect(security_flag.to_h).to eq(
{
flag_type: :false_positive,
origin: 'post analyzer X',
......
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