diff --git a/ee/lib/gitlab/alert_management/alert_payload_field_extractor.rb b/ee/lib/gitlab/alert_management/alert_payload_field_extractor.rb index fe223d2c2a8b7ea49a3aaf5035345af10343b94e..cdaec82c70d9698785fd6c4177570429dcf265be 100644 --- a/ee/lib/gitlab/alert_management/alert_payload_field_extractor.rb +++ b/ee/lib/gitlab/alert_management/alert_payload_field_extractor.rb @@ -31,7 +31,8 @@ module Gitlab ) end - # TODO: Code duplication with Gitlab::InlineHash#merge_keys ahead! + # Code duplication with Gitlab::InlineHash#merge_keys ahead! + # See https://gitlab.com/gitlab-org/gitlab/-/issues/299856 def deep_traverse(hash) return to_enum(__method__, hash) unless block_given? @@ -54,8 +55,6 @@ module Gitlab 'datetime' when String 'string' - when Numeric - 'numeric' when Array 'array' end diff --git a/ee/spec/lib/gitlab/alert_management/alert_payload_field_extractor_spec.rb b/ee/spec/lib/gitlab/alert_management/alert_payload_field_extractor_spec.rb index 83c038da03254b714df0a6e19dc453cf2779a0aa..674101e0a78dc81f78c490b414c7874a6e1c5278 100644 --- a/ee/spec/lib/gitlab/alert_management/alert_payload_field_extractor_spec.rb +++ b/ee/spec/lib/gitlab/alert_management/alert_payload_field_extractor_spec.rb @@ -12,12 +12,10 @@ RSpec.describe Gitlab::AlertManagement::AlertPayloadFieldExtractor do subject(:fields) { extractor.extract(json) } - context 'plain' do + describe '#extract' do before do payload.merge!( str: 'value', - int: 23, - float: 23.5, nested: { key: 'level1', deep: { @@ -32,11 +30,9 @@ RSpec.describe Gitlab::AlertManagement::AlertPayloadFieldExtractor do ) end - it 'works' do + it 'returns all the possible field combination and types suggestions' do expect(fields).to contain_exactly( a_field(['str'], 'Str', 'string'), - a_field(['int'], 'Int', 'numeric'), - a_field(['float'], 'Float', 'numeric'), a_field(%w(nested key), 'Key', 'string'), a_field(%w(nested deep key), 'Key', 'string'), a_field(['time'], 'Time', 'datetime'),