From 969a366472697e20c296e1cef0831fcb3ae28849 Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 30 Jun 2023 15:07:37 +0200 Subject: [PATCH 1/2] Sort Alchemy::Element::FORBIDDEN_DEFINITION_ATTRIBUTES --- app/models/alchemy/element.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/alchemy/element.rb b/app/models/alchemy/element.rb index f71d2d1e0c..cd1926ffb0 100644 --- a/app/models/alchemy/element.rb +++ b/app/models/alchemy/element.rb @@ -35,13 +35,13 @@ class Element < BaseRecord FORBIDDEN_DEFINITION_ATTRIBUTES = [ "amount", "autogenerate", - "nestable_elements", + "compact", + "deprecated", "hint", "ingredients", - "taggable", - "compact", "message", - "deprecated" + "nestable_elements", + "taggable", ].freeze # All Elements that share the same page version and parent element and are fixed or not are considered a list. From 2673e8e7fcda64d10bee32dd3a40f768551e882f Mon Sep 17 00:00:00 2001 From: Thomas von Deyen Date: Fri, 30 Jun 2023 15:16:41 +0200 Subject: [PATCH 2/2] Allow to create element with warning in definition Closes #2460 --- app/models/alchemy/element.rb | 1 + spec/dummy/config/alchemy/elements.yml | 3 +++ spec/models/alchemy/element_spec.rb | 10 ++++++++++ 3 files changed, 14 insertions(+) diff --git a/app/models/alchemy/element.rb b/app/models/alchemy/element.rb index cd1926ffb0..a0a349df62 100644 --- a/app/models/alchemy/element.rb +++ b/app/models/alchemy/element.rb @@ -42,6 +42,7 @@ class Element < BaseRecord "message", "nestable_elements", "taggable", + "warning" ].freeze # All Elements that share the same page version and parent element and are fixed or not are considered a list. diff --git a/spec/dummy/config/alchemy/elements.yml b/spec/dummy/config/alchemy/elements.yml index 9b5d2eaab2..e17fc01680 100644 --- a/spec/dummy/config/alchemy/elements.yml +++ b/spec/dummy/config/alchemy/elements.yml @@ -226,3 +226,6 @@ - role: key_words type: Text group: details + +- name: element_with_warning + warning: "Do not use this element!" diff --git a/spec/models/alchemy/element_spec.rb b/spec/models/alchemy/element_spec.rb index dd2dc6ede8..f536fb274d 100644 --- a/spec/models/alchemy/element_spec.rb +++ b/spec/models/alchemy/element_spec.rb @@ -114,6 +114,16 @@ module Alchemy end end end + + context "with warning in definition" do + let(:element) do + Alchemy::Element.new(name: "element_with_warning") + end + + it "creates element" do + expect { element.save }.to_not raise_error + end + end end describe ".dom_id_class" do