From c03285b9aa34de5d69b1715cb1cc4288cc1e87cf Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Thu, 18 Apr 2024 08:59:16 +0200 Subject: [PATCH] Allow to customize Headline Sizes --- app/models/alchemy/ingredients/headline.rb | 9 ++++++++- spec/models/alchemy/ingredients/headline_spec.rb | 12 ++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/models/alchemy/ingredients/headline.rb b/app/models/alchemy/ingredients/headline.rb index 2b4082c591..39458395b3 100644 --- a/app/models/alchemy/ingredients/headline.rb +++ b/app/models/alchemy/ingredients/headline.rb @@ -29,7 +29,14 @@ def level_options end def size_options - sizes.map { |size| [".h#{size}", size] } + sizes.map do |size| + case size + when Array + size + else + [".h#{size}", size] + end + end end private diff --git a/spec/models/alchemy/ingredients/headline_spec.rb b/spec/models/alchemy/ingredients/headline_spec.rb index 312cd4101e..faddb37506 100644 --- a/spec/models/alchemy/ingredients/headline_spec.rb +++ b/spec/models/alchemy/ingredients/headline_spec.rb @@ -49,6 +49,18 @@ it { is_expected.to eq([[".h3", 3], [".h4", 4]]) } end + + context "when two dimensional array" do + before do + expect(ingredient).to receive(:settings) do + { + sizes: [["XL", "text-xl"], ["L", "text-lg"]] + } + end + end + + it { is_expected.to eq([["XL", "text-xl"], ["L", "text-lg"]]) } + end end describe "creating from a settings" do