Skip to content

Commit 2ac8653

Browse files
committed
fix: don't break the page rendering of a published page with no sections
1 parent 31a54c8 commit 2ac8653

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

app/services/maglev/get_published_page_sections_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class GetPublishedPageSectionsService
1515
argument :locale, default: nil
1616

1717
def call
18-
fetch_container_store(page).sections.map do |section|
18+
(fetch_container_store(page).sections || []).map do |section|
1919
transform_section(section.dup)
2020
end.compact
2121
end

spec/services/maglev/get_published_page_sections_service_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
it 'returns an empty array' do
2929
expect(subject).to eq([])
3030
end
31+
32+
context 'the page had an empty sections_translations' do
33+
let(:page) { build(:page, sections_translations: {}) }
34+
35+
it 'returns an empty array' do
36+
expect(subject).to eq([])
37+
end
38+
end
3139
end
3240

3341
# rubocop:disable Style/StringHashKeys

0 commit comments

Comments
 (0)