diff --git a/app/components/alchemy/admin/ingredient_editor.rb b/app/components/alchemy/admin/ingredient_editor.rb index 1e4a670924..539c39045c 100644 --- a/app/components/alchemy/admin/ingredient_editor.rb +++ b/app/components/alchemy/admin/ingredient_editor.rb @@ -30,10 +30,15 @@ def initialize(ingredient:, element_form: nil) def call if has_editor_partial? - deprecation_notice - render partial: "alchemy/ingredients/#{@ingredient.partial_name}_editor", - locals: {element_form: @element_form}, - object: @ingredient + Alchemy::Deprecation.warn <<~WARN + Ingredient editor partials are deprecated! + Please create a `#{@ingredient.class.name}Editor` class inheriting from `Alchemy::Ingredients::BaseEditor`. + WARN + Alchemy::Deprecation.silence do + render partial: "alchemy/ingredients/#{@ingredient.partial_name}_editor", + locals: {element_form: @element_form}, + object: Alchemy::IngredientEditor.new(@ingredient) + end else render @ingredient.as_editor_component end @@ -44,13 +49,6 @@ def call def has_editor_partial? helpers.lookup_context.template_exists?("alchemy/ingredients/_#{@ingredient.partial_name}_editor") end - - def deprecation_notice - Alchemy::Deprecation.warn <<~WARN - Ingredient editor partials are deprecated! - Please create a `#{@ingredient.class.name}Editor` class inheriting from `Alchemy::Ingredients::BaseEditor`. - WARN - end end end end diff --git a/spec/components/alchemy/admin/ingredient_editor_spec.rb b/spec/components/alchemy/admin/ingredient_editor_spec.rb index b3235feaac..320e30d0b9 100644 --- a/spec/components/alchemy/admin/ingredient_editor_spec.rb +++ b/spec/components/alchemy/admin/ingredient_editor_spec.rb @@ -53,6 +53,11 @@ expect(page).to have_css(".deprecated-editor") end + + it "renders the deprecated partial with an IngredientEditor decorator" do + expect(Alchemy::IngredientEditor).to receive(:new).with(ingredient).and_call_original + render_inline(described_class.new(ingredient: ingredient, element_form: element_form)) + end end end