Skip to content

Commit 525baf6

Browse files
authored
Merge pull request #3031 from tvdeyen/fix-picture-ingredient-update
fix(Ingredient::Picture): Do not try to localize CSS class if empty
2 parents dbed496 + 881014f commit 525baf6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

app/views/alchemy/admin/ingredients/update.turbo_stream.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<% if @ingredient.settings[:anchor] %>
44
<alchemy-action name="updateAnchorIcon" params="<%= [@ingredient.id, @ingredient.dom_id.present?].to_json %>"></alchemy-action>
55
<% end %>
6-
<% if @ingredient.type == "Alchemy::Ingredients::Picture" %>
6+
<% if @ingredient.type == "Alchemy::Ingredients::Picture" && @ingredient.css_class.present? %>
77
<%= turbo_stream.replace_all "[data-ingredient-id='#{@ingredient.id}'] .picture_ingredient_css_class",
88
partial: "alchemy/ingredients/shared/picture_css_class",
99
locals: {

spec/controllers/alchemy/admin/ingredients_controller_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@
8484
expect(ingredient.size).to eq "3"
8585
expect(ingredient.dom_id).to eq "se-id"
8686
end
87+
88+
context "with a picture ingredient having empty css class" do
89+
let(:ingredient) do
90+
stub_model(
91+
Alchemy::Ingredients::Picture,
92+
type: "Alchemy::Ingredients::Picture",
93+
element: element,
94+
role: "picture",
95+
data: {
96+
css_class: ""
97+
}
98+
)
99+
end
100+
101+
render_views
102+
103+
it "does not raise I18n ArgumentError" do
104+
expect {
105+
patch :update, params: params, format: :turbo_stream
106+
}.to_not raise_error
107+
end
108+
end
87109
end
88110

89111
context "with unpermitted attributes" do

0 commit comments

Comments
 (0)