From 919b015daf355a572d0824bc7132dde1ed1e1536 Mon Sep 17 00:00:00 2001 From: jazzari Date: Thu, 12 Oct 2023 18:23:10 -0300 Subject: [PATCH] fix: modificado base_service a autopublishconcern #13244 --- app/services/base_service.rb | 5 ----- app/services/concerns/autopublish.rb | 10 ++++++++++ app/services/post_service.rb | 8 +++++--- 3 files changed, 15 insertions(+), 8 deletions(-) delete mode 100644 app/services/base_service.rb create mode 100644 app/services/concerns/autopublish.rb diff --git a/app/services/base_service.rb b/app/services/base_service.rb deleted file mode 100644 index a7aed5f4..00000000 --- a/app/services/base_service.rb +++ /dev/null @@ -1,5 +0,0 @@ -module BaseService - def auto_publish! - DeployJob.perform_later(site.id) if site.auto_publish? - end -end diff --git a/app/services/concerns/autopublish.rb b/app/services/concerns/autopublish.rb new file mode 100644 index 00000000..6b5a8cd3 --- /dev/null +++ b/app/services/concerns/autopublish.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + + +module AutoPublishConcern + extend ActiveSupport::Concern + + def auto_publish! + DeployJob.perform_later(site.id) if site.auto_publish? + end +end diff --git a/app/services/post_service.rb b/app/services/post_service.rb index b1863fbe..5f7167ea 100644 --- a/app/services/post_service.rb +++ b/app/services/post_service.rb @@ -3,8 +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 BaseService - + # Crea un artículo nuevo # # @return Post @@ -25,12 +24,13 @@ 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 end # Crear un post anónimo, con opciones más limitadas. No usamos post. def create_anonymous # XXX: Confiamos en el parámetro de idioma porque estamos - # verificándolos en Site#posts + # verificándolos extend ActiveSupport::Concernn Site#posts self.post = site.posts(lang: locale) .build(layout: layout) # Los artículos anónimos siempre son borradores @@ -38,6 +38,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 end def update @@ -59,6 +60,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 end def destroy