Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions app/components/alchemy/admin/ingredient_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
5 changes: 5 additions & 0 deletions spec/components/alchemy/admin/ingredient_editor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading