Skip to content

Commit

Permalink
Merge pull request #3031 from tvdeyen/fix-picture-ingredient-update
Browse files Browse the repository at this point in the history
fix(Ingredient::Picture): Do not try to localize CSS class if empty
  • Loading branch information
tvdeyen authored Sep 8, 2024
2 parents dbed496 + 881014f commit 525baf6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<% if @ingredient.settings[:anchor] %>
<alchemy-action name="updateAnchorIcon" params="<%= [@ingredient.id, @ingredient.dom_id.present?].to_json %>"></alchemy-action>
<% end %>
<% if @ingredient.type == "Alchemy::Ingredients::Picture" %>
<% if @ingredient.type == "Alchemy::Ingredients::Picture" && @ingredient.css_class.present? %>
<%= turbo_stream.replace_all "[data-ingredient-id='#{@ingredient.id}'] .picture_ingredient_css_class",
partial: "alchemy/ingredients/shared/picture_css_class",
locals: {
Expand Down
22 changes: 22 additions & 0 deletions spec/controllers/alchemy/admin/ingredients_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@
expect(ingredient.size).to eq "3"
expect(ingredient.dom_id).to eq "se-id"
end

context "with a picture ingredient having empty css class" do
let(:ingredient) do
stub_model(
Alchemy::Ingredients::Picture,
type: "Alchemy::Ingredients::Picture",
element: element,
role: "picture",
data: {
css_class: ""
}
)
end

render_views

it "does not raise I18n ArgumentError" do
expect {
patch :update, params: params, format: :turbo_stream
}.to_not raise_error
end
end
end

context "with unpermitted attributes" do
Expand Down

0 comments on commit 525baf6

Please sign in to comment.