From b1752cb0a1adf88978808e4b340d61ca5fe779b3 Mon Sep 17 00:00:00 2001
From: Arnaud Levy <contact@arnaudlevy.com>
Date: Wed, 20 Apr 2022 18:06:07 +0200
Subject: [PATCH] fix

---
 app/models/communication/block/template/post.rb | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/app/models/communication/block/template/post.rb b/app/models/communication/block/template/post.rb
index d474d433b..7f5c803c0 100644
--- a/app/models/communication/block/template/post.rb
+++ b/app/models/communication/block/template/post.rb
@@ -16,13 +16,7 @@ class Communication::Block::Template::Post < Communication::Block::Template
   end
 
   def selected_posts
-    if kind == 'all'
-      @selected_posts ||= all_posts
-    elsif kind == 'selection'
-      @selected_posts ||= free_posts
-    elsif kind == 'category'
-      @selected_posts ||= category_posts
-    end
+    @selected_posts ||= send "selected_posts_#{kind}"
   end
 
   protected
@@ -31,17 +25,17 @@ class Communication::Block::Template::Post < Communication::Block::Template
     @kind ||= data['kind'] || 'all'
   end
 
-  def all_posts
+  def selected_posts_all
     quantity = data['posts_quantity'] || 3
     block.about&.website.posts.ordered.limit(quantity)
   end
 
-  def category_posts
+  def selected_posts_category
     quantity = data['posts_quantity'] || 3
     category.posts.ordered.limit(quantity)
   end
 
-  def free_posts
+  def selected_posts_free
     elements.map { |element| post(element['id']) }
             .compact
   end
-- 
GitLab