From d4d63090d11668ff14dfa4dd805fbf48e3607a7d Mon Sep 17 00:00:00 2001 From: Arnaud Levy Date: Fri, 6 Feb 2026 20:12:14 +0100 Subject: [PATCH] tests --- app/models/communication/block/template/contact/element.rb | 6 ++++++ app/models/communication/block/template/gallery/element.rb | 3 +++ app/models/communication/block/template/link/element.rb | 3 +++ .../communication/block/template/testimonial/element.rb | 3 +++ app/models/communication/block/template/timeline/element.rb | 3 +++ .../blocks/templates/call_to_action/_static.html.erb | 3 +-- .../communication/blocks/templates/contact/_static.html.erb | 4 +++- .../blocks/templates/definitions/_static.html.erb | 3 +-- .../communication/blocks/templates/gallery/_static.html.erb | 2 +- .../blocks/templates/key_figures/_static.html.erb | 4 +++- .../communication/blocks/templates/links/_static.html.erb | 4 +++- .../blocks/templates/testimonials/_static.html.erb | 4 +++- .../blocks/templates/timeline/_static.html.erb | 4 +++- 13 files changed, 36 insertions(+), 10 deletions(-) diff --git a/app/models/communication/block/template/contact/element.rb b/app/models/communication/block/template/contact/element.rb index 5129866e0d..c0a30e9984 100644 --- a/app/models/communication/block/template/contact/element.rb +++ b/app/models/communication/block/template/contact/element.rb @@ -2,4 +2,10 @@ class Communication::Block::Template::Contact::Element < Communication::Block::T has_component :title, :string has_component :time_slot_morning, :time_slot has_component :time_slot_afternoon, :time_slot + + def empty? + title.blank? && + time_slot_morning['from'].blank? && + time_slot_afternoon['from'].blank? + end end diff --git a/app/models/communication/block/template/gallery/element.rb b/app/models/communication/block/template/gallery/element.rb index cd1ee68f98..aa25e0b850 100644 --- a/app/models/communication/block/template/gallery/element.rb +++ b/app/models/communication/block/template/gallery/element.rb @@ -22,4 +22,7 @@ def check_accessibility accessibility_warning 'accessibility.commons.alt.empty' if image_component.blob && alt.blank? end + def empty? + blob.blank? + end end diff --git a/app/models/communication/block/template/link/element.rb b/app/models/communication/block/template/link/element.rb index e2f8cfd399..a8962445ca 100644 --- a/app/models/communication/block/template/link/element.rb +++ b/app/models/communication/block/template/link/element.rb @@ -11,4 +11,7 @@ def url_external?(website) !url.start_with?(website.url) end + def empty? + title.blank? && description.blank? && url.blank? + end end diff --git a/app/models/communication/block/template/testimonial/element.rb b/app/models/communication/block/template/testimonial/element.rb index bb7fdc8f7c..b7dd29ffa1 100644 --- a/app/models/communication/block/template/testimonial/element.rb +++ b/app/models/communication/block/template/testimonial/element.rb @@ -5,4 +5,7 @@ class Communication::Block::Template::Testimonial::Element < Communication::Bloc has_component :job, :string has_component :photo, :image + def empty? + text.blank? + end end diff --git a/app/models/communication/block/template/timeline/element.rb b/app/models/communication/block/template/timeline/element.rb index ba2894c2bc..c4e215a6e2 100644 --- a/app/models/communication/block/template/timeline/element.rb +++ b/app/models/communication/block/template/timeline/element.rb @@ -3,4 +3,7 @@ class Communication::Block::Template::Timeline::Element < Communication::Block:: has_component :title, :string has_component :text, :rich_text + def empty? + title.blank? && text.blank? + end end diff --git a/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb b/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb index 8b4f3988d3..c9b968b500 100644 --- a/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/call_to_action/_static.html.erb @@ -8,8 +8,7 @@ buttons: <% block.template.elements.each do |element| - next if element.title.blank? - %> + next if element.title.blank? %> - <%= block_component_static block, :title, template: element, depth: 5 %> <%= block_component_static block, :url, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/contact/_static.html.erb b/app/views/admin/communication/blocks/templates/contact/_static.html.erb index 8115596a87..727ab3234e 100644 --- a/app/views/admin/communication/blocks/templates/contact/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/contact/_static.html.erb @@ -3,7 +3,9 @@ <%= block_component_static block, :information %> <%= render 'admin/application/contact_details/static', about: block.template, l10n: block.template, depth: 3 %> timetable: -<% block.template.elements.each do |element| %> +<% +block.template.elements.each do |element| + next if element.empty? %> - <%= block_component_static block, :title, template: element, depth: 5 %> <%= block_component_static block, :time_slot_morning, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/definitions/_static.html.erb b/app/views/admin/communication/blocks/templates/definitions/_static.html.erb index cfe14788cf..dea3f6c55c 100644 --- a/app/views/admin/communication/blocks/templates/definitions/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/definitions/_static.html.erb @@ -2,8 +2,7 @@ elements: <% block.template.elements.each do |element| - next if element.empty? - %> + next if element.empty? %> - <%= block_component_static block, :title, template: element, depth: 5 %> <%= block_component_static block, :description, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/gallery/_static.html.erb b/app/views/admin/communication/blocks/templates/gallery/_static.html.erb index 97e9855c8b..73988d9d2a 100644 --- a/app/views/admin/communication/blocks/templates/gallery/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/gallery/_static.html.erb @@ -3,7 +3,7 @@ images: <% block.template.elements.each do |element| - next unless element.blob %> + next if element.empty? %> - <%= block_component_static block, :image, template: element, depth: 5 %> <%= block_component_static block, :alt, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb b/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb index 310e566cba..f9595fa27a 100644 --- a/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/key_figures/_static.html.erb @@ -1,6 +1,8 @@ <%= block_component_static block, :description %> figures: -<% block.template.elements.each do |element| %> +<% +block.template.elements.each do |element| + next if element.empty? %> - <%= block_component_static block, :number, template: element, depth: 0 %> <%= block_component_static block, :unit, template: element, depth: 5 %> <%= block_component_static block, :description, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/links/_static.html.erb b/app/views/admin/communication/blocks/templates/links/_static.html.erb index bb818afa3c..210a23c512 100644 --- a/app/views/admin/communication/blocks/templates/links/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/links/_static.html.erb @@ -2,7 +2,9 @@ layout: <%= block.template.layout %> <%= block_options_static block %> links: -<% block.template.elements.each do |element| %> +<% +block.template.elements.each do |element| + next if element.empty? %> - <%= block_component_static block, :title, template: element, depth: 5 %> <%= block_component_static block, :description, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/testimonials/_static.html.erb b/app/views/admin/communication/blocks/templates/testimonials/_static.html.erb index babfb9b188..bf99b2abc8 100644 --- a/app/views/admin/communication/blocks/templates/testimonials/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/testimonials/_static.html.erb @@ -1,6 +1,8 @@ <%= block_component_static block, :layout %> testimonials: -<% block.template.elements.each do |element| %> +<% +block.template.elements.each do |element| + next if element.empty? %> - <%= block_component_static block, :text, template: element, depth: 5 %> <%= block_component_static block, :author, template: element, depth: 5 %> diff --git a/app/views/admin/communication/blocks/templates/timeline/_static.html.erb b/app/views/admin/communication/blocks/templates/timeline/_static.html.erb index f8cde1269f..12b5c236b7 100644 --- a/app/views/admin/communication/blocks/templates/timeline/_static.html.erb +++ b/app/views/admin/communication/blocks/templates/timeline/_static.html.erb @@ -1,6 +1,8 @@ <%= block_component_static block, :layout %> events: -<% block.template.elements.each do |element| %> +<% +block.template.elements.each do |element| + next if element.empty? %> - <%= block_component_static block, :title, template: element, depth: 5 %> <%= block_component_static block, :text, template: element, depth: 5 %>