pg_rails 7.6.16 → 7.6.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/pg_associable/app/javascript/modal_controller.js +17 -1
  3. data/pg_engine/app/assets/stylesheets/pg_rails_b5.scss +8 -1
  4. data/pg_engine/app/components/inline_edit/inline_show_component.html.slim +2 -1
  5. data/pg_engine/app/components/search_bar_toggler_component.html.slim +5 -3
  6. data/pg_engine/app/controllers/admin/accounts_controller.rb +0 -4
  7. data/pg_engine/app/controllers/admin/email_logs_controller.rb +0 -4
  8. data/pg_engine/app/controllers/admin/emails_controller.rb +0 -4
  9. data/pg_engine/app/controllers/admin/simple_user_notifiers_controller.rb +8 -9
  10. data/pg_engine/app/controllers/admin/user_accounts_controller.rb +0 -4
  11. data/pg_engine/app/controllers/admin/users_controller.rb +0 -4
  12. data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +121 -41
  13. data/pg_engine/app/controllers/public/mensaje_contactos_controller.rb +0 -4
  14. data/pg_engine/app/controllers/users/accounts_controller.rb +0 -4
  15. data/pg_engine/app/decorators/pg_engine/base_record_decorator.rb +39 -13
  16. data/pg_engine/app/helpers/pg_engine/index_helper.rb +17 -3
  17. data/pg_engine/app/helpers/pg_engine/route_helper.rb +4 -0
  18. data/pg_engine/app/lib/pg_engine/filtros_builder.rb +7 -9
  19. data/pg_engine/app/models/account.rb +2 -0
  20. data/pg_engine/app/models/concerns/pg_engine/naming.rb +55 -0
  21. data/pg_engine/app/models/pg_engine/base_record.rb +2 -46
  22. data/pg_engine/app/models/user.rb +1 -1
  23. data/pg_engine/app/notifiers/simple_user_notifier.rb +4 -0
  24. data/pg_engine/app/policies/account_policy.rb +9 -9
  25. data/pg_engine/app/policies/pg_engine/base_policy.rb +15 -3
  26. data/pg_engine/app/views/admin/accounts/show.html.slim +0 -7
  27. data/pg_engine/app/views/admin/email_logs/show.html.slim +0 -7
  28. data/pg_engine/app/views/admin/emails/show.html.slim +0 -7
  29. data/pg_engine/app/views/admin/simple_user_notifiers/_form.html.slim +1 -1
  30. data/pg_engine/app/views/admin/simple_user_notifiers/show.html.slim +0 -5
  31. data/pg_engine/app/views/admin/user_accounts/show.html.slim +0 -7
  32. data/pg_engine/app/views/admin/users/show.html.slim +1 -5
  33. data/pg_engine/app/views/pg_engine/base/index.html.slim +39 -14
  34. data/pg_engine/config/locales/es.rb +42 -0
  35. data/pg_engine/config/locales/es.yml +1 -6
  36. data/pg_engine/lib/pg_engine/engine.rb +4 -0
  37. data/pg_engine/lib/pg_engine/route_helpers.rb +5 -0
  38. data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +4 -9
  39. data/pg_engine/spec/controllers/admin/email_logs_controller_spec.rb +4 -4
  40. data/pg_engine/spec/controllers/admin/emails_controller_spec.rb +4 -4
  41. data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +4 -4
  42. data/pg_engine/spec/controllers/admin/users_controller_spec.rb +4 -9
  43. data/pg_engine/spec/models/pg_engine/base_record_spec.rb +12 -0
  44. data/pg_engine/spec/requests/admin/eventos_spec.rb +9 -15
  45. data/pg_engine/spec/requests/resource_spec.rb +84 -0
  46. data/pg_engine/spec/requests/users/switcher_spec.rb +2 -2
  47. data/pg_engine/spec/system/breadcrumbs_spec.rb +9 -21
  48. data/pg_engine/spec/system/destroy_spec.rb +3 -3
  49. data/pg_engine/spec/system/login_spec.rb +1 -1
  50. data/pg_engine/spec/system/modal_windows_spec.rb +5 -5
  51. data/pg_engine/spec/system/tenants_spec.rb +2 -2
  52. data/pg_layout/app/javascript/application.js +4 -2
  53. data/pg_layout/app/javascript/controllers/embedded_frame_controller.js +4 -0
  54. data/pg_layout/app/views/layouts/pg_layout/base.html.slim +1 -0
  55. data/pg_layout/app/views/layouts/pg_layout/show.html.slim +10 -0
  56. data/pg_rails/lib/version.rb +1 -1
  57. data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +4 -11
  58. data/pg_scaffold/lib/generators/pg_scaffold/templates/controller.rb +1 -5
  59. data/pg_scaffold/lib/generators/pg_slim/templates/show.html.slim +0 -7
  60. metadata +6 -3
  61. data/pg_engine/app/components/actions_component.rb +0 -14
@@ -63,5 +63,9 @@ module PgEngine
63
63
 
64
64
  polymorphic_url(target.flatten.compact, options.merge(only_path: true))
65
65
  end
66
+
67
+ def path_for(array)
68
+ url_for(array.push({ only_path: true }))
69
+ end
66
70
  end
67
71
  end
@@ -5,6 +5,7 @@ module PgEngine
5
5
  include ActionView::Helpers
6
6
  include ActionView::Context
7
7
  include PostgresHelper
8
+ include IndexHelper
8
9
  attr_accessor :controller
9
10
 
10
11
  # El orden de los sufijos es importante
@@ -140,16 +141,13 @@ module PgEngine
140
141
 
141
142
  def placeholder_campo(campo)
142
143
  suf = extraer_sufijo(campo)
143
- key = [controller_name, action_name, 'filter', sin_sufijo(campo)].join('.')
144
- dflt = :"activerecord.attributes.#{@clase_modelo.model_name.i18n_key}.#{sin_sufijo(campo)}"
145
- human_name = @clase_modelo.human_attribute_name(key, default: dflt)
144
+ human_name = scoped_human_attr_name(@clase_modelo, sin_sufijo(campo), 'filter')
146
145
 
147
- ret =
148
- if suf.present?
149
- "#{human_name} #{I18n.t(suf, scope: 'ransack.predicates')}"
150
- else
151
- human_name
152
- end
146
+ ret = if suf.present?
147
+ "#{human_name} #{I18n.t(suf, scope: 'ransack.predicates')}"
148
+ else
149
+ human_name
150
+ end
153
151
 
154
152
  ret.strip.downcase.tap { _1[0] = _1[0].capitalize }
155
153
  end
@@ -34,6 +34,8 @@ class Account < ApplicationRecord
34
34
 
35
35
  validates :plan, :nombre, presence: true
36
36
 
37
+ has_many :audits, dependent: :nullify, class_name: 'Audited::Audit'
38
+
37
39
  ransacker :search do |parent|
38
40
  parent.table[:nombre]
39
41
  end
@@ -0,0 +1,55 @@
1
+ module PgEngine
2
+ module Naming
3
+ deprecate :gender, deprecator: PgEngine.deprecator
4
+ def gender
5
+ self.class.model_name.human.downcase.ends_with?('a') ? 'f' : 'm'
6
+ end
7
+
8
+ def self.included(base)
9
+ base.extend(ClassMethods)
10
+ end
11
+
12
+ module ClassMethods
13
+ # This is a per class variable, all subclasses of BaseRecord inherit it
14
+ # BUT **the values are independent between all of them**
15
+ attr_accessor :default_modal, :inline_editable_fields
16
+
17
+ def gender
18
+ model_name.human.downcase.ends_with?('a') ? 'f' : 'm'
19
+ end
20
+
21
+ def inline_editable?(attribute)
22
+ inline_editable_fields.present? && inline_editable_fields.include?(attribute.to_sym)
23
+ end
24
+
25
+ def ransackable_associations(_auth_object = nil)
26
+ authorizable_ransackable_associations
27
+ end
28
+
29
+ def ransackable_attributes(_auth_object = nil)
30
+ authorizable_ransackable_attributes
31
+ end
32
+
33
+ def nombre_plural
34
+ model_name.human(count: 2)
35
+ end
36
+
37
+ def nombre_singular
38
+ model_name.human(count: 1)
39
+ end
40
+
41
+ def human_attribute_name(attribute, options = {})
42
+ # Remove suffixes
43
+ if attribute.to_s.ends_with?('_text')
44
+ # Si es un enumerized
45
+ super(attribute[0..-6], options)
46
+ elsif attribute.to_s.ends_with?('_f')
47
+ # Si es un decorated method
48
+ super(attribute[0..-3], options)
49
+ else
50
+ super
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -7,62 +7,18 @@ module PgEngine
7
7
  extend Enumerize
8
8
  include PrintHelper
9
9
  include PostgresHelper
10
+ include Naming
10
11
 
11
12
  self.abstract_class = true
12
13
 
13
14
  before_create :setear_creado_y_actualizado_por
14
15
  before_update :setear_actualizado_por
15
16
 
16
- class << self
17
- # This is a per class variable, all subclasses of BaseRecord inherit it
18
- # BUT **the values are independent between all of them**
19
- attr_accessor :default_modal, :inline_editable_fields
20
-
21
- def inline_editable?(attribute)
22
- inline_editable_fields.present? && inline_editable_fields.include?(attribute.to_sym)
23
- end
24
- end
25
-
17
+ scope :unkept, -> { discarded }
26
18
  # ransacker :search do |parent|
27
19
  # parent.table[:nombre]
28
20
  # end
29
21
 
30
- def self.ransackable_associations(_auth_object = nil)
31
- authorizable_ransackable_associations
32
- end
33
-
34
- def self.ransackable_attributes(_auth_object = nil)
35
- authorizable_ransackable_attributes
36
- end
37
-
38
- def gender
39
- self.class.model_name.human.downcase.ends_with?('a') ? 'f' : 'm'
40
- end
41
-
42
- def self.nombre_plural
43
- model_name.human(count: 2)
44
- end
45
-
46
- def self.nombre_singular
47
- model_name.human(count: 1)
48
- end
49
-
50
- def self.human_attribute_name(attribute, options = {})
51
- if attribute.to_s.ends_with?('_text')
52
- # Si es un enumerized
53
- super(attribute[0..-6], options)
54
- elsif attribute.to_s.ends_with?('_f')
55
- # Si es un decorated method
56
- super(attribute[0..-3], options)
57
- else
58
- super
59
- end
60
- end
61
-
62
- def actions_component
63
- ActionsComponent.new(self)
64
- end
65
-
66
22
  # Para el dom_id (index.html)
67
23
  def to_key
68
24
  if respond_to? :hashid
@@ -36,7 +36,7 @@ class User < ApplicationRecord
36
36
  audited
37
37
  include Discard::Model
38
38
 
39
- has_many :user_accounts
39
+ has_many :user_accounts, dependent: :destroy
40
40
 
41
41
  # Hace falta?
42
42
  has_many :accounts, through: :user_accounts
@@ -46,4 +46,8 @@ class SimpleUserNotifier < ApplicationNotifier
46
46
  def self.policy_class
47
47
  ApplicationPolicy
48
48
  end
49
+
50
+ def self.decorator_class
51
+ PgEngine::BaseRecordDecorator
52
+ end
49
53
  end
@@ -13,17 +13,17 @@ class AccountPolicy < ApplicationPolicy
13
13
  # end
14
14
  end
15
15
 
16
- # def puede_editar?
17
- # acceso_total? && !record.readonly?
18
- # end
16
+ def puede_editar?
17
+ user.developer?
18
+ end
19
19
 
20
- # def puede_crear?
21
- # acceso_total? || user.asesor?
22
- # end
20
+ def puede_crear?
21
+ user.developer?
22
+ end
23
23
 
24
- # def puede_borrar?
25
- # acceso_total? && !record.readonly?
26
- # end
24
+ def puede_borrar?
25
+ user.developer?
26
+ end
27
27
 
28
28
  # def acceso_total?
29
29
  # user.developer?
@@ -13,6 +13,10 @@ module PgEngine
13
13
  base_access_to_collection?
14
14
  end
15
15
 
16
+ def archived?
17
+ base_access_to_collection?
18
+ end
19
+
16
20
  def show?
17
21
  base_access_to_record?
18
22
  end
@@ -30,7 +34,7 @@ module PgEngine
30
34
  end
31
35
 
32
36
  def update?
33
- puede_editar? && !objeto_borrado?
37
+ puede_editar? && !record_discarded?
34
38
  end
35
39
 
36
40
  def edit?
@@ -38,7 +42,15 @@ module PgEngine
38
42
  end
39
43
 
40
44
  def destroy?
41
- puede_borrar? && !objeto_borrado?
45
+ puede_borrar?
46
+ end
47
+
48
+ def archive?
49
+ puede_borrar? && !record_discarded?
50
+ end
51
+
52
+ def restore?
53
+ puede_borrar? && record.respond_to?(:discarded?) && record.discarded?
42
54
  end
43
55
 
44
56
  def scope
@@ -92,7 +104,7 @@ module PgEngine
92
104
  user&.developer?
93
105
  end
94
106
 
95
- def objeto_borrado?
107
+ def record_discarded?
96
108
  if record.respond_to?(:kept?)
97
109
  !record.kept?
98
110
  else
@@ -1,10 +1,3 @@
1
- - content_for :title do
2
- = @account.to_s
3
- - content_for :actions do
4
- = @account.destroy_link_redirect
5
- .ms-1
6
- = @account.edit_link
7
-
8
1
  table.table.table-borderless.table-sm.w-auto.mb-0.m-3
9
2
  - atributos_para_mostrar.each do |att|
10
3
  tr
@@ -1,10 +1,3 @@
1
- - content_for :title do
2
- = @email_log.to_s
3
- - content_for :actions do
4
- = @email_log.destroy_link_redirect
5
- .ms-1
6
- = @email_log.edit_link
7
-
8
1
  table.table.table-borderless.table-sm.w-auto.mb-0.m-3
9
2
  - atributos_para_mostrar.each do |att|
10
3
  tr
@@ -1,10 +1,3 @@
1
- - content_for :title do
2
- = @email.to_s
3
- - content_for :actions do
4
- = @email.destroy_link_redirect
5
- .ms-1
6
- = @email.edit_link
7
-
8
1
  table.table.table-borderless.table-sm.w-auto.mb-0
9
2
  - atributos_para_mostrar.each do |att|
10
3
  tr
@@ -1,4 +1,4 @@
1
- = pg_form_for @simple_user_notifier do |f|
1
+ = pg_form_for @simple_user_notifier.decorate do |f|
2
2
  - if params[:plain_text]
3
3
  = link_to 'Change to rich text', url_for
4
4
  = f.input :message, as: :text
@@ -1,8 +1,3 @@
1
- - content_for :actions do
2
- = @simple_user_notifier.destroy_link_redirect
3
- .ms-1
4
- = @simple_user_notifier.edit_link
5
-
6
1
  table.table.table-borderless.table-sm.w-auto.mb-0.m-3
7
2
  - atributos_para_mostrar.each do |att|
8
3
  tr
@@ -1,10 +1,3 @@
1
- - content_for :title do
2
- = @user_account.to_s
3
- - content_for :actions do
4
- = @user_account.destroy_link_redirect
5
- .ms-1
6
- = @user_account.edit_link
7
-
8
1
  table.table.table-borderless.table-sm.w-auto.mb-0.m-3
9
2
  - atributos_para_mostrar.each do |att|
10
3
  tr
@@ -1,10 +1,6 @@
1
1
  - content_for :title do
2
2
  = @user.to_s
3
- - content_for :actions do
4
- = @user.destroy_link_redirect
5
- .ms-1
6
- = @user.edit_link
7
- .ms-1
3
+ - content_for :extra_actions do
8
4
  = link_to login_as_path(id: @user.id), class: 'btn btn-light btn-sm' do
9
5
  span.bi.bi-arrow-right
10
6
  | Login as
@@ -6,10 +6,31 @@
6
6
  data: { controller: :tooltip, 'bs-title': 'Actualizar' } do
7
7
  i.bi.bi-arrow-clockwise
8
8
  .ms-1
9
- - if @filtros.present?
10
- = render SearchBarTogglerComponent.new
9
+ - if action_name == 'index' && (nested_record.blank? || nested_record.kept?)
10
+ = @clase_modelo.new.decorate.new_link
11
11
  .ms-1
12
- = @clase_modelo.new.decorate.new_link
12
+ .dropdown data-controller="tooltip" data-bs-title="Más opciones"
13
+ button.btn.btn-outline-secondary.btn-sm.xdropdown-toggle[
14
+ type="button" data-bs-toggle="dropdown" aria-expanded="false"]
15
+ i.bi.bi-list
16
+ ul.dropdown-menu
17
+ - unless action_name == 'archived'
18
+ li = link_to [:archived, pg_namespace, nested_record, @clase_modelo].compact,
19
+ class: 'icon-link dropdown-item' do
20
+ i.bi.bi-archive-fill.lh-1
21
+ = t('pg_engine.base.index.see_archived', model: clase_modelo)
22
+ - if @filtros.present?
23
+ li = render SearchBarTogglerComponent.new
24
+ - unless @export_link == false
25
+ li = @clase_modelo.new.decorate.export_link(request.url, text: 'Exportar en excel')
26
+
27
+ - if action_name == 'archived'
28
+ .text-center.p-3.text-warning-emphasis.border-bottom
29
+ div
30
+ i.bi.bi-archive-fill
31
+ div
32
+ => t('pg_engine.base.index.youre_in_archived_index', model: clase_modelo)
33
+ = link_to t('.back_to_index'), @index_url
13
34
 
14
35
  - if @filtros.present?
15
36
  = render SearchBarComponent.new(@q, @filtros)
@@ -21,24 +42,27 @@
21
42
  caption.ps-3 = page_entries_info @collection
22
43
  thead.table-light
23
44
  tr
45
+ th
24
46
  - atributos_para_listar.each do |att|
25
47
  th.text-nowrap style="font-size: 0.8em" = encabezado att, ordenable: true
26
- th.text-end
27
- - unless @export_link == false
28
- .actions-wrapper
29
- = @clase_modelo.new.decorate.export_link(request.url)
48
+ - if action_name == 'archived'
49
+ th.text-nowrap style="font-size: 0.8em" = encabezado :discarded_at, ordenable: true
30
50
  tbody
31
51
  - @collection.each do |object|
32
52
  - object = object.decorate
33
53
  tr id="#{dom_id(object)}"
34
- - atributos_para_listar.each do |att, _sort_field|
35
- = column_for object, att
36
- td.text-nowrap.text-end.ps-5
54
+ td.text-nowrap.xtext-end.xps-5
37
55
  .actions-wrapper
38
56
  = object.extra_actions(size: :sm) if object.respond_to? :extra_actions
39
- = object.show_link
57
+ = object.show_link(text: '')
40
58
  = object.edit_link(text: '', klass: 'btn-light')
59
+ = object.archive_link
60
+ = object.restore_link
41
61
  = object.destroy_link
62
+ - atributos_para_listar.each do |att, _sort_field|
63
+ = column_for object, att
64
+ - if action_name == 'archived'
65
+ = column_for object, :discarded_at
42
66
 
43
67
  .d-flex.justify-content-center
44
68
  = paginate(@collection)
@@ -50,12 +74,13 @@
50
74
  url_for(page_size:),
51
75
  class: "list-group-item py-0 px-1 #{'active' if current_page_size == page_size}"
52
76
  - elsif @records_filtered
53
- - i18n_key = "#{controller_key}.#{action_name}.index.empty_but_filtered"
77
+ / - i18n_key = "#{controller_key}.#{action_name}.index.empty_but_filtered"
78
+ - i18n_key = :".#{action_name}.empty_but_filtered"
54
79
  p.m-3
55
- = t(i18n_key, default: :'.empty_but_filtered', model: @clase_modelo.nombre_plural.downcase)
80
+ = t(i18n_key, default: :".#{action_name}.empty_but_filtered", model: @clase_modelo)
56
81
  | :
57
82
  span.ms-2
58
83
  = link_to 'Limpiar búsqueda', url_for + '?cancel_filter=true'
59
84
  - else
60
85
  - i18n_key = "#{controller_key}.#{action_name}.index.empty"
61
- p.m-3 = t(i18n_key, default: :'.empty', model: @clase_modelo.nombre_plural.downcase)
86
+ p.m-3 = t(i18n_key, default: :".#{action_name}.empty", model: @clase_modelo)
@@ -0,0 +1,42 @@
1
+ module PgEngine
2
+ module I18nRules
3
+ def self.rule(text)
4
+ lambda do |key, options|
5
+ male = options[:model].gender == 'm'
6
+ model_plural = options[:model].nombre_plural
7
+ model_singular = options[:model].nombre_singular
8
+ text.gsub(/^%{plural_model}/, model_plural)
9
+ .gsub(/^%{singular_model}/, model_singular)
10
+ .gsub('%{plural_model}', model_plural.downcase)
11
+ .gsub('%{singular_model}', model_singular.downcase)
12
+ .gsub(/%{genderize\((?<female>(?:(?!%{).)+),(?<male>(?:(?!%{).)+)\)}/, male ? '\k<male>' : '\k<female>' )
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ {
19
+ :es => {
20
+ pg_engine: {
21
+ resource_destroyed: PgEngine::I18nRules.rule("Se eliminó %{genderize(la,el)} %{singular_model}"),
22
+ resource_not_destroyed: PgEngine::I18nRules.rule("Hubo un error al intentar eliminar %{genderize(la,el)} %{singular_model}"),
23
+ resource_not_updated: PgEngine::I18nRules.rule("Hubo un error al intentar actualizar %{genderize(la,el)} %{singular_model}"),
24
+ resource_not_destroyed_because_associated: PgEngine::I18nRules.rule("No se pudo eliminar %{genderize(la,el)} %{singular_model} porque está asociado a otros elementos"),
25
+ base: {
26
+ index: {
27
+ archived: {
28
+ empty_but_filtered: PgEngine::I18nRules.rule("No hay %{genderize(ninguna,ningún)} %{singular_model} %{genderize(archivada,archivado)} para los filtros aplicados"),
29
+ empty: PgEngine::I18nRules.rule("No hay %{genderize(ninguna,ningún)} %{singular_model} %{genderize(archivada,archivado)}"),
30
+ },
31
+ index: {
32
+ empty_but_filtered: PgEngine::I18nRules.rule("No hay %{genderize(ninguna,ningún)} %{singular_model} para los filtros aplicados"),
33
+ empty: PgEngine::I18nRules.rule("No hay %{genderize(ninguna,ningún)} %{singular_model} que mostrar"),
34
+ },
35
+ youre_in_archived_index: PgEngine::I18nRules.rule("Estás viendo el listado de %{plural_model} %{genderize(archivadas,archivados)}"),
36
+ see_archived: PgEngine::I18nRules.rule("%{plural_model} %{genderize(archivadas,archivados)}"),
37
+ back_to_index: 'Volver al listado principal'
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
@@ -11,11 +11,6 @@ es:
11
11
  gt: 'desde'
12
12
  lteq: 'hasta'
13
13
  gteq: 'desde'
14
- pg_engine:
15
- base:
16
- index:
17
- empty: 'No hay %{model} que mostrar'
18
- empty_but_filtered: 'No hay %{model} para los filtros aplicados'
19
14
  gender:
20
15
  reset_password_token: m
21
16
  confirmation_token: m
@@ -27,7 +22,7 @@ es:
27
22
  external_id: ID externo
28
23
  created_at: Fecha de creación
29
24
  updated_at: Fecha de actualización
30
- discarded_at: Fecha de borrado
25
+ discarded_at: Fecha de archivado
31
26
  confirmed_at: Fecha de confirmación
32
27
  actualizado_por: Actualizado por
33
28
  creado_por: Creado por
@@ -27,6 +27,10 @@ module PgEngine
27
27
  ActsAsTenant.without_tenant(&)
28
28
  end
29
29
  end
30
+ Noticed::ApplicationRecord.class_eval do
31
+ extend Enumerize
32
+ include PgEngine::Naming
33
+ end
30
34
  end
31
35
 
32
36
  initializer 'pg_engine.set_exceptions_app' do
@@ -2,7 +2,12 @@ module PgEngine
2
2
  module RouteHelpers
3
3
  def pg_resource(key, options = {})
4
4
  resources(key, options) do
5
+ member do
6
+ post :archive
7
+ post :restore
8
+ end
5
9
  collection do
10
+ get :archived
6
11
  get :abrir_modal
7
12
  post :buscar
8
13
  end
@@ -185,28 +185,23 @@ RSpec.describe Admin::AccountsController do
185
185
  describe 'DELETE #destroy' do
186
186
  subject do
187
187
  request.headers['Accept'] = 'text/vnd.turbo-stream.html,text/html'
188
- delete :destroy, params: { id: account.to_param, redirect_to: redirect_url }
188
+ delete :destroy, params: { id: account.to_param, land_on: }
189
189
  end
190
190
 
191
191
  let!(:account) { create :account }
192
- let(:redirect_url) { nil }
192
+ let(:land_on) { nil }
193
193
 
194
194
  it 'destroys the requested account' do
195
195
  expect { subject }.to change(Account.kept, :count).by(-1)
196
196
  end
197
197
 
198
- it 'setea el discarded_at' do
199
- subject
200
- expect(account.reload.discarded_at).to be_present
201
- end
202
-
203
198
  it 'envía el pg-event' do
204
199
  subject
205
200
  expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
206
201
  end
207
202
 
208
- context 'si hay redirect_to' do
209
- let(:redirect_url) { admin_accounts_url }
203
+ context 'si hay land_on' do
204
+ let(:land_on) { :index }
210
205
 
211
206
  it 'redirects to the accounts list' do
212
207
  subject
@@ -154,11 +154,11 @@ RSpec.describe Admin::EmailLogsController do
154
154
  describe 'DELETE #destroy' do
155
155
  subject do
156
156
  request.headers['Accept'] = 'text/vnd.turbo-stream.html,text/html'
157
- delete :destroy, params: { id: email_log.to_param, redirect_to: redirect_url }
157
+ delete :destroy, params: { id: email_log.to_param, land_on: }
158
158
  end
159
159
 
160
160
  let!(:email_log) { create :email_log }
161
- let(:redirect_url) { nil }
161
+ let(:land_on) { nil }
162
162
 
163
163
  it 'destroys the requested email_log' do
164
164
  expect { subject }.to change(EmailLog, :count).by(-1)
@@ -169,8 +169,8 @@ RSpec.describe Admin::EmailLogsController do
169
169
  expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
170
170
  end
171
171
 
172
- context 'si hay redirect_to' do
173
- let(:redirect_url) { admin_email_logs_url }
172
+ context 'si hay land_on' do
173
+ let(:land_on) { :index }
174
174
 
175
175
  it 'redirects to the email_logs list' do
176
176
  subject
@@ -143,11 +143,11 @@ RSpec.describe Admin::EmailsController do
143
143
  describe 'DELETE #destroy' do
144
144
  subject do
145
145
  request.headers['Accept'] = 'text/vnd.turbo-stream.html,text/html'
146
- delete :destroy, params: { id: email.to_param, redirect_to: redirect_url }
146
+ delete :destroy, params: { id: email.to_param, land_on: }
147
147
  end
148
148
 
149
149
  let!(:email) { create :email }
150
- let(:redirect_url) { nil }
150
+ let(:land_on) { nil }
151
151
 
152
152
  it 'destroys the requested email' do
153
153
  expect { subject }.to change(Email, :count).by(-1)
@@ -158,8 +158,8 @@ RSpec.describe Admin::EmailsController do
158
158
  expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
159
159
  end
160
160
 
161
- context 'si hay redirect_to' do
162
- let(:redirect_url) { admin_emails_url }
161
+ context 'si hay land_on' do
162
+ let(:land_on) { :index }
163
163
 
164
164
  it 'redirects to the emails list' do
165
165
  subject
@@ -174,11 +174,11 @@ RSpec.describe Admin::UserAccountsController do
174
174
  describe 'DELETE #destroy' do
175
175
  subject do
176
176
  request.headers['Accept'] = 'text/vnd.turbo-stream.html,text/html'
177
- delete :destroy, params: { id: user_account.to_param, redirect_to: redirect_url }
177
+ delete :destroy, params: { id: user_account.to_param, land_on: }
178
178
  end
179
179
 
180
180
  let!(:user_account) { create :user_account }
181
- let(:redirect_url) { nil }
181
+ let(:land_on) { nil }
182
182
 
183
183
  it 'destroys the requested user_account' do
184
184
  expect { subject }.to change(UserAccount, :count).by(-1)
@@ -189,8 +189,8 @@ RSpec.describe Admin::UserAccountsController do
189
189
  expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
190
190
  end
191
191
 
192
- context 'si hay redirect_to' do
193
- let(:redirect_url) { admin_user_accounts_url }
192
+ context 'si hay land_on' do
193
+ let(:land_on) { :index }
194
194
 
195
195
  it 'redirects to the user_accounts list' do
196
196
  subject
@@ -169,28 +169,23 @@ RSpec.describe Admin::UsersController do
169
169
  describe 'DELETE #destroy' do
170
170
  subject do
171
171
  request.headers['Accept'] = 'text/vnd.turbo-stream.html,text/html'
172
- delete :destroy, params: { id: user.to_param, redirect_to: redirect_url }
172
+ delete :destroy, params: { id: user.to_param, land_on: }
173
173
  end
174
174
 
175
175
  let!(:user) { create :user }
176
- let(:redirect_url) { nil }
176
+ let(:land_on) { nil }
177
177
 
178
178
  it 'destroys the requested user' do
179
179
  expect { subject }.to change(User.kept, :count).by(-1)
180
180
  end
181
181
 
182
- it 'setea el discarded_at' do
183
- subject
184
- expect(user.reload.discarded_at).to be_present
185
- end
186
-
187
182
  it 'envía el pg-event' do
188
183
  subject
189
184
  expect(response.body).to include('<pg-event data-event-name="pg:record-destroyed"')
190
185
  end
191
186
 
192
- context 'si hay redirect_to' do
193
- let(:redirect_url) { admin_users_url }
187
+ context 'si hay land_on' do
188
+ let(:land_on) { :index }
194
189
 
195
190
  it 'redirects to the users list' do
196
191
  subject