From 0ab0b143f39ebe324a7369b923aea02531455a0c Mon Sep 17 00:00:00 2001 From: jazzari Date: Tue, 17 Oct 2023 15:30:37 -0300 Subject: [PATCH] fix: corregida llamada a auto_publish! #13244 --- app/services/concerns/autopublish.rb | 6 ++++-- app/services/post_service.rb | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/services/concerns/autopublish.rb b/app/services/concerns/autopublish.rb index 6b5a8cd3..81f81aad 100644 --- a/app/services/concerns/autopublish.rb +++ b/app/services/concerns/autopublish.rb @@ -4,7 +4,9 @@ module AutoPublishConcern extend ActiveSupport::Concern - def auto_publish! - DeployJob.perform_later(site.id) if site.auto_publish? + included do + def auto_publish! + DeployJob.perform_later(site.id) if site.auto_publish? + end end end diff --git a/app/services/post_service.rb b/app/services/post_service.rb index 5f7167ea..e9305c34 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -3,6 +3,7 @@ # Este servicio se encarga de crear artículos y guardarlos en git, # asignándoselos a une usuarie PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do + include AutoPublishConcern # Crea un artículo nuevo # @@ -24,7 +25,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do # Devolver el post aunque no se haya salvado para poder rescatar los # errores post - include AutoPublishConcern + auto_publish! end # Crear un post anónimo, con opciones más limitadas. No usamos post. @@ -38,7 +39,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do commit(action: :created, add: [post.path.absolute]) if post.update(anon_post_params) post - include AutoPublishConcern + auto_publish! end def update @@ -60,7 +61,7 @@ PostService = Struct.new(:site, :usuarie, :post, :params, keyword_init: true) do # Devolver el post aunque no se haya salvado para poder rescatar los # errores post - include AutoPublishConcern + auto_publish! end def destroy