diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-20 16:49:51 +0300 |
commit | 71786ddc8e28fbd3cb3fcc4b3ff15e5962a1c82e (patch) | |
tree | 6a2d93ef3fb2d353bb7739e4b57e6541f51cdd71 /lib/release_highlights | |
parent | a7253423e3403b8c08f8a161e5937e1488f5f407 (diff) |
Add latest changes from gitlab-org/gitlab@15-9-stable-eev15.9.0-rc42
Diffstat (limited to 'lib/release_highlights')
-rw-r--r-- | lib/release_highlights/validator/entry.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/release_highlights/validator/entry.rb b/lib/release_highlights/validator/entry.rb index 2b4889e0131..fc9ce3a3fd0 100644 --- a/lib/release_highlights/validator/entry.rb +++ b/lib/release_highlights/validator/entry.rb @@ -6,12 +6,16 @@ module ReleaseHighlights include ActiveModel::Validations::Callbacks AVAILABLE_IN = %w(Free Premium Ultimate).freeze + HYPHENATED_ATTRIBUTES = [:self_managed, :gitlab_com].freeze attr_reader :entry + attr_accessor :available_in, :description, :gitlab_com, :image_url, :name, :published_at, :release, :self_managed, + :stage validates :name, :description, :stage, presence: true - validates :'self-managed', :'gitlab-com', inclusion: { in: [true, false], message: "must be a boolean" } - validates :documentation_link, :image_url, public_url: { dns_rebind_protection: true } + validates :self_managed, :gitlab_com, inclusion: { in: [true, false], message: "must be a boolean" } + validates :documentation_link, public_url: { dns_rebind_protection: true } + validates :image_url, public_url: { dns_rebind_protection: true }, allow_nil: true validates :release, numericality: true validate :validate_published_at validate :validate_available_in @@ -67,11 +71,13 @@ module ReleaseHighlights index = entry.children.find_index(node) next_node = entry.children[index + 1] + next_node&.to_ruby end def find_node(key) - entry.children.find { |node| node.try(:value) == key.to_s } + formatted_key = key.in?(HYPHENATED_ATTRIBUTES) ? key.to_s.dasherize : key.to_s + entry.children.find { |node| node.try(:value) == formatted_key } end end end |