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.
- checksums.yaml +4 -4
- data/pg_associable/app/javascript/modal_controller.js +17 -1
- data/pg_engine/app/assets/stylesheets/pg_rails_b5.scss +8 -1
- data/pg_engine/app/components/inline_edit/inline_show_component.html.slim +2 -1
- data/pg_engine/app/components/search_bar_toggler_component.html.slim +5 -3
- data/pg_engine/app/controllers/admin/accounts_controller.rb +0 -4
- data/pg_engine/app/controllers/admin/email_logs_controller.rb +0 -4
- data/pg_engine/app/controllers/admin/emails_controller.rb +0 -4
- data/pg_engine/app/controllers/admin/simple_user_notifiers_controller.rb +8 -9
- data/pg_engine/app/controllers/admin/user_accounts_controller.rb +0 -4
- data/pg_engine/app/controllers/admin/users_controller.rb +0 -4
- data/pg_engine/app/controllers/concerns/pg_engine/resource.rb +121 -41
- data/pg_engine/app/controllers/public/mensaje_contactos_controller.rb +0 -4
- data/pg_engine/app/controllers/users/accounts_controller.rb +0 -4
- data/pg_engine/app/decorators/pg_engine/base_record_decorator.rb +39 -13
- data/pg_engine/app/helpers/pg_engine/index_helper.rb +17 -3
- data/pg_engine/app/helpers/pg_engine/route_helper.rb +4 -0
- data/pg_engine/app/lib/pg_engine/filtros_builder.rb +7 -9
- data/pg_engine/app/models/account.rb +2 -0
- data/pg_engine/app/models/concerns/pg_engine/naming.rb +55 -0
- data/pg_engine/app/models/pg_engine/base_record.rb +2 -46
- data/pg_engine/app/models/user.rb +1 -1
- data/pg_engine/app/notifiers/simple_user_notifier.rb +4 -0
- data/pg_engine/app/policies/account_policy.rb +9 -9
- data/pg_engine/app/policies/pg_engine/base_policy.rb +15 -3
- data/pg_engine/app/views/admin/accounts/show.html.slim +0 -7
- data/pg_engine/app/views/admin/email_logs/show.html.slim +0 -7
- data/pg_engine/app/views/admin/emails/show.html.slim +0 -7
- data/pg_engine/app/views/admin/simple_user_notifiers/_form.html.slim +1 -1
- data/pg_engine/app/views/admin/simple_user_notifiers/show.html.slim +0 -5
- data/pg_engine/app/views/admin/user_accounts/show.html.slim +0 -7
- data/pg_engine/app/views/admin/users/show.html.slim +1 -5
- data/pg_engine/app/views/pg_engine/base/index.html.slim +39 -14
- data/pg_engine/config/locales/es.rb +42 -0
- data/pg_engine/config/locales/es.yml +1 -6
- data/pg_engine/lib/pg_engine/engine.rb +4 -0
- data/pg_engine/lib/pg_engine/route_helpers.rb +5 -0
- data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +4 -9
- data/pg_engine/spec/controllers/admin/email_logs_controller_spec.rb +4 -4
- data/pg_engine/spec/controllers/admin/emails_controller_spec.rb +4 -4
- data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +4 -4
- data/pg_engine/spec/controllers/admin/users_controller_spec.rb +4 -9
- data/pg_engine/spec/models/pg_engine/base_record_spec.rb +12 -0
- data/pg_engine/spec/requests/admin/eventos_spec.rb +9 -15
- data/pg_engine/spec/requests/resource_spec.rb +84 -0
- data/pg_engine/spec/requests/users/switcher_spec.rb +2 -2
- data/pg_engine/spec/system/breadcrumbs_spec.rb +9 -21
- data/pg_engine/spec/system/destroy_spec.rb +3 -3
- data/pg_engine/spec/system/login_spec.rb +1 -1
- data/pg_engine/spec/system/modal_windows_spec.rb +5 -5
- data/pg_engine/spec/system/tenants_spec.rb +2 -2
- data/pg_layout/app/javascript/application.js +4 -2
- data/pg_layout/app/javascript/controllers/embedded_frame_controller.js +4 -0
- data/pg_layout/app/views/layouts/pg_layout/base.html.slim +1 -0
- data/pg_layout/app/views/layouts/pg_layout/show.html.slim +10 -0
- data/pg_rails/lib/version.rb +1 -1
- data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +4 -11
- data/pg_scaffold/lib/generators/pg_scaffold/templates/controller.rb +1 -5
- data/pg_scaffold/lib/generators/pg_slim/templates/show.html.slim +0 -7
- metadata +6 -3
- data/pg_engine/app/components/actions_component.rb +0 -14
@@ -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
|
-
|
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
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
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
|
@@ -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
|
-
|
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
|
@@ -13,17 +13,17 @@ class AccountPolicy < ApplicationPolicy
|
|
13
13
|
# end
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
def puede_editar?
|
17
|
+
user.developer?
|
18
|
+
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
def puede_crear?
|
21
|
+
user.developer?
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
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? && !
|
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?
|
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
|
107
|
+
def record_discarded?
|
96
108
|
if record.respond_to?(:kept?)
|
97
109
|
!record.kept?
|
98
110
|
else
|
@@ -1,10 +1,6 @@
|
|
1
1
|
- content_for :title do
|
2
2
|
= @user.to_s
|
3
|
-
- content_for :
|
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
|
10
|
-
=
|
9
|
+
- if action_name == 'index' && (nested_record.blank? || nested_record.kept?)
|
10
|
+
= @clase_modelo.new.decorate.new_link
|
11
11
|
.ms-1
|
12
|
-
=
|
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
|
-
|
27
|
-
-
|
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
|
-
-
|
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: :
|
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: :
|
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
|
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
|
@@ -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,
|
188
|
+
delete :destroy, params: { id: account.to_param, land_on: }
|
189
189
|
end
|
190
190
|
|
191
191
|
let!(:account) { create :account }
|
192
|
-
let(:
|
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
|
209
|
-
let(:
|
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,
|
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(:
|
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
|
173
|
-
let(:
|
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,
|
146
|
+
delete :destroy, params: { id: email.to_param, land_on: }
|
147
147
|
end
|
148
148
|
|
149
149
|
let!(:email) { create :email }
|
150
|
-
let(:
|
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
|
162
|
-
let(:
|
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,
|
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(:
|
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
|
193
|
-
let(:
|
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,
|
172
|
+
delete :destroy, params: { id: user.to_param, land_on: }
|
173
173
|
end
|
174
174
|
|
175
175
|
let!(:user) { create :user }
|
176
|
-
let(:
|
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
|
193
|
-
let(:
|
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
|