Commit 06dcfe84 authored by Saikat Sarkar's avatar Saikat Sarkar Committed by Luke Duncalfe

Use to_h instead of to_hash for vulnerability_flag

parent 3f97c556
...@@ -15,7 +15,7 @@ module Vulnerabilities ...@@ -15,7 +15,7 @@ module Vulnerabilities
} }
def initialize(attributes) 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) super(attributes)
end end
end end
......
...@@ -269,7 +269,7 @@ module Security ...@@ -269,7 +269,7 @@ module Security
vulnerability_finding_to_finding_map.each_slice(BATCH_SIZE) do |vf_to_findings| vulnerability_finding_to_finding_map.each_slice(BATCH_SIZE) do |vf_to_findings|
records = vf_to_findings.flat_map do |vulnerability_finding, finding| 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 end
records.uniq! records.uniq!
......
...@@ -20,7 +20,7 @@ module Gitlab ...@@ -20,7 +20,7 @@ module Gitlab
@description = description @description = description
end end
def to_hash def to_h
{ {
flag_type: flag_type, flag_type: flag_type,
origin: origin, origin: origin,
......
...@@ -18,9 +18,9 @@ RSpec.describe Gitlab::Ci::Reports::Security::Flag do ...@@ -18,9 +18,9 @@ RSpec.describe Gitlab::Ci::Reports::Security::Flag do
end end
end end
describe '#to_hash' do describe '#to_h' do
it 'returns expected hash' do it 'returns expected hash' do
expect(security_flag.to_hash).to eq( expect(security_flag.to_h).to eq(
{ {
flag_type: :false_positive, flag_type: :false_positive,
origin: 'post analyzer X', 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