From bad82b0cfcd2d45935071fd17be1bff8b58647f0 Mon Sep 17 00:00:00 2001
From: pabois <pierreandre.boissinot@noesya.coop>
Date: Fri, 10 Dec 2021 14:48:12 +0100
Subject: [PATCH] fixes

---
 app/models/communication/website/author.rb      |  2 +-
 app/models/communication/website/category.rb    |  2 +-
 app/models/communication/website/github_file.rb | 10 +++++-----
 app/models/concerns/with_github_files.rb        |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/app/models/communication/website/author.rb b/app/models/communication/website/author.rb
index 25480be7f..65b8783fb 100644
--- a/app/models/communication/website/author.rb
+++ b/app/models/communication/website/author.rb
@@ -58,7 +58,7 @@ class Communication::Website::Author < ApplicationRecord
   def github_manifest
     super << {
       identifier: "collection_item",
-      generated_path: "_data/authors/#{slug}.yml",
+      generated_path: -> { "_data/authors/#{slug}.yml" },
       data: -> (github_file) { ApplicationController.render(
         template: "admin/communication/website/authors/jekyll_collection",
         formats: [:yml],
diff --git a/app/models/communication/website/category.rb b/app/models/communication/website/category.rb
index 0211ad172..11a09fe23 100644
--- a/app/models/communication/website/category.rb
+++ b/app/models/communication/website/category.rb
@@ -84,7 +84,7 @@ class Communication::Website::Category < ApplicationRecord
   def github_manifest
     super << {
       identifier: "collection_item",
-      generated_path: "_data/categories/#{slug}.yml",
+      generated_path: -> { "_data/categories/#{slug}.yml" },
       data: -> (github_file) { ApplicationController.render(
         template: "admin/communication/website/categories/jekyll_collection",
         formats: [:yml],
diff --git a/app/models/communication/website/github_file.rb b/app/models/communication/website/github_file.rb
index 11b428692..2abf6433c 100644
--- a/app/models/communication/website/github_file.rb
+++ b/app/models/communication/website/github_file.rb
@@ -27,16 +27,16 @@ class Communication::Website::GithubFile < ApplicationRecord
   after_destroy :remove_from_github
 
   def publish
-    return unless valid? && github.valid?
+    return unless valid_for_publication? && github.valid?
     add_to_batch(github)
     if github.commit_batch(github_commit_message)
-      update_column :github_path, manifest_data[:generated_path]
+      update_column :github_path, manifest_data[:generated_path].call
     end
   end
   handle_asynchronously :publish, queue: 'default'
 
   def add_to_batch(github)
-    return unless valid?
+    return unless valid_for_publication?
     github.add_to_batch github_params
     add_media_to_batch(github)
   end
@@ -82,7 +82,7 @@ class Communication::Website::GithubFile < ApplicationRecord
 
   def github_params
     {
-      path: manifest_data[:generated_path],
+      path: manifest_data[:generated_path].call,
       previous_path: github_path,
       data: manifest_data[:data].call(self)
     }
@@ -122,7 +122,7 @@ class Communication::Website::GithubFile < ApplicationRecord
     }
   end
 
-  def valid?
+  def valid_for_publication?
     return about.published? if about_type == 'Communication::Website::Post'
     true
   end
diff --git a/app/models/concerns/with_github_files.rb b/app/models/concerns/with_github_files.rb
index 5a6aea780..e42292cca 100644
--- a/app/models/concerns/with_github_files.rb
+++ b/app/models/concerns/with_github_files.rb
@@ -28,7 +28,7 @@ module WithGithubFiles
     [
       {
         identifier: "primary",
-        generated_path: github_path_generated,
+        generated_path: -> { github_path_generated },
         data: -> (github_file) { to_jekyll(github_file) },
         has_media: true
       }
-- 
GitLab