Skip to content

Commit 1221cce

Browse files
authored
Fix problem of stack horizontal without image (#48)
1 parent 92db8dd commit 1221cce

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

app/cells/decidim/alternative_landing/content_blocks/stack_horizontal/show.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<% 1.upto(3) do |item_number| %>
99
<div class="stack-item">
1010
<div class="stack-image">
11-
<%= image_tag image(item_number) %>
11+
<%= image_tag image(item_number) if image(item_number).present? %>
1212
</div>
1313
<div class="stack-body">
1414
<div>

spec/shared/system_homepage_examples.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# /rails/active_storage/representation/redirect/same-hash--different-token/same-file-name
2020
# That's why we are splitting by "--" and comparing the first
2121
img_path = content_block.images_container.attached_uploader("image_#{item_number}".to_sym).path(variant: :landscape)
22-
[img_path.split("--").first, img_path.split("/").last].each do |regex|
22+
img_path && [img_path.split("--").first, img_path.split("/").last].each do |regex|
2323
expect(page.find("img")[:src]).to match(/#{regex}/)
2424
end
2525
end

spec/system/homepage_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@
5151
describe "stack blocks" do
5252
it_behaves_like "render all stack block elements", "stack-horizontal"
5353
it_behaves_like "render all stack block elements", "stack-vertical"
54+
55+
context "without images" do
56+
before do
57+
stack_horizontal_block.attachments.destroy_all
58+
stack_vertical_block.attachments.destroy_all
59+
end
60+
61+
it_behaves_like "render all stack block elements", "stack-horizontal"
62+
it_behaves_like "render all stack block elements", "stack-vertical"
63+
end
5464
end
5565

5666
describe "tiles block" do

0 commit comments

Comments
 (0)