From 81a444908b5578eb8cf48b47b9b5367aaa9ce6d0 Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Wed, 3 Apr 2024 19:02:32 +0200 Subject: [PATCH 01/42] refactor fields to 0.28 --- .../_registration_form.html.erb | 87 +++++++++---------- .../admin/extra_user_fields/_form.html.erb | 49 ++++++----- .../fields/_country.html.erb | 3 +- .../fields/_date_of_birth.html.erb | 3 +- .../extra_user_fields/fields/_gender.html.erb | 3 +- .../fields/_location.html.erb | 3 +- .../fields/_phone_number.html.erb | 3 +- .../fields/_postal_code.html.erb | 3 +- .../admin/extra_user_fields/index.html.erb | 27 +++--- lib/decidim/extra_user_fields/version.rb | 2 +- ...ges_organization_extra_user_fields_spec.rb | 5 +- spec/system/registration_spec.rb | 2 +- 12 files changed, 92 insertions(+), 98 deletions(-) diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 0bfa9d5..1a7f90c 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -1,49 +1,44 @@ <% if current_organization.extra_user_fields_enabled? %> -
-
-
-

<%= t(".signup.legend") %>

-
- - <% if current_organization.activated_extra_field?(:date_of_birth) %> -
- <%= f.date_field :date_of_birth %> -
- <% end %> - - <% if current_organization.activated_extra_field?(:gender) %> -
- <%= f.collection_select :gender, f.object.gender_options_for_select, :first, :last %> -
- <% end %> - - <% if current_organization.activated_extra_field?(:country) %> -
- <%= f.custom_country_select :country %> -
- <% end %> - - <% if current_organization.activated_extra_field?(:postal_code) %> -
- <%= f.text_field :postal_code %> -
- <% end %> - - <% if current_organization.activated_extra_field?(:phone_number) %> -
- <%= f.text_field :phone_number %> -
- <% end %> - - <% if current_organization.activated_extra_field?(:location) %> -
- <%= f.text_field :location %> -
- <% end %> - - <%# Block ExtraUserFields SignUpFormFields %> - - <%# EndBlock %> -
+
+

<%= t(".signup.legend") %>

+ + <% if current_organization.activated_extra_field?(:date_of_birth) %> + <%= f.date_field :date_of_birth %> + <% end %> + + <% if current_organization.activated_extra_field?(:gender) %> + <%= f.collection_select :gender, f.object.gender_options_for_select, :first, :last %> + <% end %> + + <% if current_organization.activated_extra_field?(:country) %> + <%= f.custom_country_select :country %> + <% end %> + + <% if current_organization.activated_extra_field?(:postal_code) %> + <%= f.text_field :postal_code %> + <% end %> + + <% + # TODO: move wherever it takes + def telephone_pattern + "^(\\+34)?[0-9]{9}$" + end + + def telephone_placeholder + "+34987654321" + end + %> + <% if current_organization.activated_extra_field?(:phone_number) %> + <%= f.telephone_field :phone_number, placeholder: telephone_placeholder, pattern: telephone_pattern %> + <% end %> + + <% if current_organization.activated_extra_field?(:location) %> + <%= f.text_field :location %> + <% end %> + + <%# Block ExtraUserFields SignUpFormFields %> + + <%# EndBlock %> +
<% end %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb index b3d17f1..cd3c6c8 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb @@ -1,29 +1,36 @@ -

<%== t(".callout.help") %>

-
-
-
-

<%= t(".global.title") %>

+<%= cell("decidim/announcement", t(".callout.help"), callout_class: "success" ) %> + +
+
+
+
-
- <%= form.check_box :enabled, label: t(".extra_user_fields.extra_user_fields_enabled") %> + +
+
+ <%= form.check_box :enabled, label: t(".extra_user_fields.extra_user_fields_enabled") %> +
-
-
-
-
-

<%= t(".extra_user_fields.section") %>

+
+
+
- <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/date_of_birth", locals: { form: form } %> - <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/country", locals: { form: form } %> - <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/postal_code", locals: { form: form } %> - <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/gender", locals: { form: form } %> - <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/phone_number", locals: { form: form } %> - <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/location", locals: { form: form } %> - <%# Block ExtraUserFields ExtraFields %> - - <%# EndBlock %> +
+ <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/date_of_birth", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/country", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/postal_code", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/gender", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/phone_number", locals: { form: form } %> + <%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/location", locals: { form: form } %> +
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_country.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_country.html.erb index 93adc59..1a2763d 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_country.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_country.html.erb @@ -1,6 +1,5 @@
-

<%= t(".description") %>

- <%= form.check_box :country, label: t(".label") %> + <%= form.check_box :country, label: t(".label"), help_text: t(".description") %>
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_date_of_birth.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_date_of_birth.html.erb index 0bbab64..3e34bf2 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_date_of_birth.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_date_of_birth.html.erb @@ -1,6 +1,5 @@
-

<%= t(".description") %>

- <%= form.check_box :date_of_birth, label: t(".label") %> + <%= form.check_box :date_of_birth, label: t(".label"), help_text: t(".description") %>
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_gender.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_gender.html.erb index 37cfecd..7405bb8 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_gender.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_gender.html.erb @@ -1,6 +1,5 @@
-

<%= t(".description") %>

- <%= form.check_box :gender, label: t(".label") %> + <%= form.check_box :gender, label: t(".label"), help_text: t(".description") %>
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_location.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_location.html.erb index 899fa02..8f47117 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_location.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_location.html.erb @@ -1,6 +1,5 @@
-

<%= t(".description") %>

- <%= form.check_box :location, label: t(".label") %> + <%= form.check_box :location, label: t(".label"), help_text: t(".description") %>
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb index e789c0a..99d9e65 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb @@ -1,6 +1,5 @@
-

<%= t(".description") %>

- <%= form.check_box :phone_number, label: t(".label") %> + <%= form.check_box :phone_number, label: t(".label"), help_text: t(".description") %>
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_postal_code.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_postal_code.html.erb index bfa91a7..059ccc6 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_postal_code.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_postal_code.html.erb @@ -1,6 +1,5 @@
-

<%= t(".description") %>

- <%= form.check_box :postal_code, label: t(".label") %> + <%= form.check_box :postal_code, label: t(".label"), help_text: t(".description") %>
diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/index.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/index.html.erb index 68ce0b0..0e9bef8 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/index.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/index.html.erb @@ -1,16 +1,17 @@ -
-
-

- <%= t ".title" %> -

-
-
- <%= decidim_form_for(@form, url: "/admin/extra_user_fields/extra_user_fields", html: { class: "form edit_extra_user_fields" }, method: :patch) do |f| %> - <%= render partial: "form", object: f %> +<% add_decidim_page_title(t(".title")) %> +
+

+ <%= t ".title" %> +

+
+
+ <%= decidim_form_for(@form, url: "/admin/extra_user_fields/extra_user_fields", html: { class: "form-defaults form edit_extra_user_fields" }, method: :patch) do |f| %> + <%= render partial: "form", object: f %> -
- <%= f.submit t(".save") %> +
+
+ <%= f.submit t(".save"), class: "button button__sm button__secondary" %>
- <% end %> -
+
+ <% end %>
diff --git a/lib/decidim/extra_user_fields/version.rb b/lib/decidim/extra_user_fields/version.rb index e6bada4..8daf38f 100644 --- a/lib/decidim/extra_user_fields/version.rb +++ b/lib/decidim/extra_user_fields/version.rb @@ -8,7 +8,7 @@ def self.version end def self.decidim_version - [">= 0.27.0", "< 0.28"].freeze + [">= 0.28"].freeze end end end diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index dde7091..f9f8193 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -31,11 +31,8 @@ end it "allows to enable extra user fields functionality" do - within ".extra_user_fields" do + within "#extra_user_fields" do expect(page).to have_content("Enable extra user fields") - end - - within ".extra_fields_setup" do expect(page).to have_content("Available extra fields for signup form") end end diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index 250aff3..c267288 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -85,7 +85,7 @@ def fill_extra_user_fields end it "contains extra user fields" do - within ".card__extra_user_fields" do + within "#card__extra_user_fields" do expect(page).to have_content("Date of birth") expect(page).to have_content("Gender") expect(page).to have_content("Country") From 03ec242d2bf146f8391024f2c9717cda22ed0951 Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Thu, 4 Apr 2024 10:57:44 +0200 Subject: [PATCH 02/42] update field in profile form --- .../decidim/extra_user_fields/_profile_form.html.erb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index 1971701..9239dbe 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -14,8 +14,18 @@ <%= f.text_field :postal_code %> <% end %> +<% +# TODO: move wherever it takes +def telephone_pattern + "^(\\+34)?[0-9]{9}$" +end + +def telephone_placeholder + "+34987654321" +end +%> <% if current_organization.activated_extra_field?(:phone_number) %> - <%= f.text_field :phone_number %> + <%= f.telephone_field :phone_number, placeholder: telephone_placeholder, pattern: telephone_pattern %> <% end %> <% if current_organization.activated_extra_field?(:location) %> From ce8695a891277ae1c3d67425e0718231da0836bd Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Thu, 4 Apr 2024 11:39:18 +0200 Subject: [PATCH 03/42] include admin fields and translations --- .../fields/_phone_number.html.erb | 17 +++++++++++++++++ config/locales/en.yml | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb index 99d9e65..8dd7cff 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb @@ -2,4 +2,21 @@
<%= form.check_box :phone_number, label: t(".label"), help_text: t(".description") %>
+
+ <% + # TODO: move wherever it takes + def telephone_pattern + "^(\\+34)?[0-9]{9}$" + end + + def telephone_placeholder + "+34987654321" + end + %> + <%# TODO: replace with the proper rails helpers fields %> + + + <%#= form.text_field :phone_number_pattern, label: t(".pattern"), placeholder: telephone_pattern %> + <%#= form.text_field :phone_number_placeholder, label: t(".placeholder"), placeholder: telephone_placeholder %> +
diff --git a/config/locales/en.yml b/config/locales/en.yml index 69912b0..8ae0d88 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -44,9 +44,11 @@ en: in a location label: Enable location field phone_number: - description: This field is a String field. User will be able to fill + description: This field is a telephone field. User will be able to fill in a phone number label: Enable phone number field + pattern: Phone number pattern + placeholder: Phone number placeholder postal_code: description: This field is a String field. User will be able to fill in a postal code From 36e44efa5d9a7503f6dacbc0f345f60a0456feed Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Thu, 4 Apr 2024 14:52:48 +0200 Subject: [PATCH 04/42] translations --- .../admin/extra_user_fields/_form.html.erb | 2 +- config/locales/ca.yml | 47 +++++++++++++++++++ config/locales/en.yml | 24 ++++------ config/locales/es.yml | 47 +++++++++++++++++++ config/locales/fr.yml | 2 + 5 files changed, 106 insertions(+), 16 deletions(-) diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb index cd3c6c8..73af544 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/_form.html.erb @@ -1,4 +1,4 @@ -<%= cell("decidim/announcement", t(".callout.help"), callout_class: "success" ) %> +<%= cell("decidim/announcement", t(".callout.help")) %>
diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 28aa37a..8366be0 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -10,6 +10,14 @@ ca: phone_number: Telèfon postal_code: Codi postal decidim: + admin: + actions: + export: Exporta + exports: + export_as: Exporta com a %{export_format} + extra_user_fields: + menu: + title: Gestiona camps d'usuari addicionals components: extra_user_fields: name: ExtraUserFields @@ -17,7 +25,46 @@ ca: admin: exports: users: Participants + extra_user_fields: + fields: + country: + description: Aquest camp és una llista de països. Si está activat, l'usuari haurà de triar un país. + label: Habilitar camp de país + date_of_birth: + description: Aquest camp és un camp de data. Si está activat, l'usuari haurà de registrar una data de naixement mitjançant un selector de data. + label: Habilitar camp de data de naixement + gender: + description: Aquest camp és una llista de gèneres. Si está activat, l'usuari haurà de triar un gènere. + label: Habilitar camp de gènere + location: + description: Aquest camp és un camp de text. Si está activat, l'usuari haurà de completar una ubicació. + label: Habilita camp d'ubicació + phone_number: + description: Aquest camp és un camp telefònic. Si está activat, l'usuari haurà d'introduir un número de telèfon. + label: Habilitar camp de número de telèfon + pattern: Patró de validació de números de telèfon (regex) + placeholder: Placeholder pel número de telèfon + postal_code: + description: Aquest camp és un camp de text. Si está activat, l'usuari haurà d'introduir un codi postal. + label: Habilitar camp de codi postal + form: + callout: + help: Activa la funcionalitat de camps d'usuari addicionals personalitzats per poder gestionar-los al vostre formulari de registre. Fins i tot si l'opció està marcada, el formulari de registre només s'actualitzarà si hi ha almenys un camp activat + extra_user_fields: + extra_user_fields_enabled: Activa els camps d'usuari addicionals + section: Camps addicionals disponibles per al formulari d'inscripció + global: + title: Activar / desactivar la funcionalitat + index: + save: Desa la configuració + title: Gestiona camps d'usuari addicionals + update: + failure: S'ha produït un error en l'actualització + success: Camps d'usuari addicionals actualitzats correctament a l'organització genders: female: Dona male: Home other: Altre + registration_form: + signup: + legend: Més informació diff --git a/config/locales/en.yml b/config/locales/en.yml index 8ae0d88..7526288 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,37 +28,31 @@ en: extra_user_fields: fields: country: - description: This field is a list of countries. User will be able to - choose a country + description: This field is a list of countries. If checked, user will have to choose a country label: Enable country field date_of_birth: - description: This field is a Date field. User will be able to register - a birth date by using a Date picker + description: This field is a Date field. If checked, user will have to register a birth date by using a Date picker label: Enable date of birth field gender: - description: This field is a list of genders. User will be able to choose - a gender + description: This field is a list of genders. If checked, user will have to choose a gender label: Enable gender field location: - description: This field is a String field. User will be able to fill - in a location + description: This field is a String field. If checked, user will have to fill in a location label: Enable location field phone_number: - description: This field is a telephone field. User will be able to fill - in a phone number + description: This field is a telephone field. If checked, user will have to fill in a phone number label: Enable phone number field - pattern: Phone number pattern + pattern: Phone numbers validation pattern (regex) placeholder: Phone number placeholder postal_code: - description: This field is a String field. User will be able to fill - in a postal code + description: This field is a String field. If checked, user will have to fill in a postal code label: Enable postal code field form: callout: help: Enable custom extra user fields functionality to be able to manage extra fields in your signup form. Even if option is checked, signup - form will be updated only if there is at least one extra field - enabled + form will be updated only if there is at least one extra field + enabled extra_user_fields: extra_user_fields_enabled: Enable extra user fields section: Available extra fields for signup form diff --git a/config/locales/es.yml b/config/locales/es.yml index 355383f..0f6b6a5 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -10,6 +10,14 @@ es: phone_number: Teléfono postal_code: Código postal decidim: + admin: + actions: + export: Exportar + exports: + export_as: Exportar como %{export_format} + extra_user_fields: + menu: + title: Administrar campos de usuario adicionales components: extra_user_fields: name: ExtraUserFields @@ -17,7 +25,46 @@ es: admin: exports: users: Participantes + extra_user_fields: + fields: + country: + description: Este campo es una lista de países. Si está marcado, el usuario tendrá que elegir un país. + label: Habilitar campo de país + date_of_birth: + description: Este campo es un campo de fecha. Si está marcado, el usuario deberá registrar una fecha de nacimiento mediante un selector de fecha. + label: Habilitar campo de fecha de nacimiento + gender: + description: Este campo es una lista de géneros. Si está marcado, el usuario tendrá que elegir un género. + label: Habilitar campo de género + location: + description: Este campo es un campo de texto. Si está marcado, el usuario deberá completar una ubicación. + label: Habilitar campo de ubicación + phone_number: + description: Este campo es un campo telefónico. Si está marcado, el usuario deberá ingresar un número de teléfono. + label: Habilitar campo de número de teléfono + pattern: Patrón de validación de números de teléfono (regex) + placeholder: Placeholder para el número de teléfono + postal_code: + description: este campo es un campo de texto. Si está marcado, el usuario deberá ingresar un código postal. + label: Habilitar campo de código postal + form: + callout: + help: Activa la funcionalidad de campos de usuario adicionales personalizados para poder gestionarlos en su formulario de registro. Incluso si la opción está marcada, el formulario de registro sólo se actualizará si hay al menos un campo activado + extra_user_fields: + extra_user_fields_enabled: Activa los campos de usuario adicionales + section: Campos adicionales disponibles para el formulario de inscripción + global: + title: Activar / desactivar la funcionalidad + index: + save: Guarda la configuración + title: Gestiona campos de usuario adicionales + update: + failure: Se ha producido un error en la actualización + success: Campos de usuario adicionales actualizados correctamente en la organización genders: female: Mujer male: Hombre other: Otro + registration_form: + signup: + legend: Más información diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 1c50ade..1a15b25 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -47,6 +47,8 @@ fr: description: Ce champ est un champ de numéro de téléphone. L'utilisateur pourra choisir un numéro. label: Activer le champ numéro de téléphone + pattern: Motif de validation des numéros de téléphone (regex) + placeholder: Placeholder pour le numéro de téléphone postal_code: description: Ce champ est un champ code postal. L'utilisateur pourra choisir un code postal. From 13c822a658bd8caab36a92e81d4769d1c004bc3f Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Thu, 4 Apr 2024 15:38:36 +0200 Subject: [PATCH 05/42] better regex --- app/views/decidim/extra_user_fields/_profile_form.html.erb | 2 +- app/views/decidim/extra_user_fields/_registration_form.html.erb | 2 +- .../admin/extra_user_fields/fields/_phone_number.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index 9239dbe..fb33188 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -17,7 +17,7 @@ <% # TODO: move wherever it takes def telephone_pattern - "^(\\+34)?[0-9]{9}$" + "^(\\+34)?[0-9 ]{9,12}$" end def telephone_placeholder diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 1a7f90c..8020125 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -21,7 +21,7 @@ <% # TODO: move wherever it takes def telephone_pattern - "^(\\+34)?[0-9]{9}$" + "^(\\+34)?[0-9 ]{9,12}$" end def telephone_placeholder diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb index 8dd7cff..35cf4ca 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb @@ -6,7 +6,7 @@ <% # TODO: move wherever it takes def telephone_pattern - "^(\\+34)?[0-9]{9}$" + "^(\\+34)?[0-9 ]{9,12}$" end def telephone_placeholder From 1142fa60846a2bc09a38d35b993d84ef6d17cdca Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Thu, 4 Apr 2024 16:32:39 +0200 Subject: [PATCH 06/42] refactor country selector --- app/views/decidim/extra_user_fields/_profile_form.html.erb | 6 +++++- .../decidim/extra_user_fields/_registration_form.html.erb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index fb33188..ca68184 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -7,7 +7,11 @@ <% end %> <% if current_organization.activated_extra_field?(:country) %> - <%= f.custom_country_select :country %> + <%= f.label :country do %> + <%# TODO: include the required attribute properly %> + <%= t("activemodel.attributes.user.country") %> + <%= f.country_select :country %> + <% end %> <% end %> <% if current_organization.activated_extra_field?(:postal_code) %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 8020125..e6eb234 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -11,7 +11,11 @@ <% end %> <% if current_organization.activated_extra_field?(:country) %> - <%= f.custom_country_select :country %> + <%= f.label :country do %> + <%# TODO: include the required attribute properly %> + <%= t("activemodel.attributes.user.country") %> + <%= f.country_select :country %> + <% end %> <% end %> <% if current_organization.activated_extra_field?(:postal_code) %> From ba0c29aff9a99ab4e233d7cf294536781876ead7 Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Thu, 4 Apr 2024 17:23:35 +0200 Subject: [PATCH 07/42] bump ruby version --- .github/workflows/ci_tests.yml | 4 ++-- .ruby-version | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index d4f1b27..5a16bc4 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -3,8 +3,8 @@ on: "push" env: CI: "true" - RUBY_VERSION: 3.0.2 - NODE_VERSION: 16.9.1 + RUBY_VERSION: 3.1.1 + NODE_VERSION: 18.17.1 jobs: lint: diff --git a/.ruby-version b/.ruby-version index b502146..94ff29c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.0.2 +3.1.1 From d403705e799fa82b13f530f6884802a194ec919a Mon Sep 17 00:00:00 2001 From: Hugoren Martinako Date: Mon, 8 Apr 2024 11:05:06 +0200 Subject: [PATCH 08/42] bump gemfile --- Gemfile | 4 +- Gemfile.lock | 747 ++++++++++++++++++++++++--------------------------- 2 files changed, 360 insertions(+), 391 deletions(-) diff --git a/Gemfile b/Gemfile index b1f023b..c73393d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ # frozen_string_literal: true -DECIDIM_VERSION = "~> 0.27.4" +DECIDIM_VERSION = "~> 0.28" source "https://rubygems.org" @@ -20,7 +20,7 @@ group :development, :test do end group :development do - gem "faker", "~> 2.14" + gem "faker", "~> 3.3.1" gem "letter_opener_web", "~> 1.3" gem "listen", "~> 3.1" gem "rubocop-faker" diff --git a/Gemfile.lock b/Gemfile.lock index c08f320..bb70af6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,46 +3,46 @@ PATH specs: decidim-extra_user_fields (0.27.2) country_select (~> 4.0) - decidim-core (>= 0.27.0, < 0.28) + decidim-core (>= 0.28) deface (~> 1.5) GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + actioncable (6.1.7.7) + actionpack (= 6.1.7.7) + activesupport (= 6.1.7.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailbox (6.1.7.7) + actionpack (= 6.1.7.7) + activejob (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) mail (>= 2.7.1) - actionmailer (6.1.7.6) - actionpack (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionmailer (6.1.7.7) + actionpack (= 6.1.7.7) + actionview (= 6.1.7.7) + activejob (= 6.1.7.7) + activesupport (= 6.1.7.7) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.7.6) - actionview (= 6.1.7.6) - activesupport (= 6.1.7.6) + actionpack (6.1.7.7) + actionview (= 6.1.7.7) + activesupport (= 6.1.7.7) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.6) - actionpack (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + actiontext (6.1.7.7) + actionpack (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) + actionview (6.1.7.7) + activesupport (= 6.1.7.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -50,69 +50,62 @@ GEM active_link_to (1.0.5) actionpack addressable - activejob (6.1.7.6) - activesupport (= 6.1.7.6) + activejob (6.1.7.7) + activesupport (= 6.1.7.7) globalid (>= 0.3.6) - activemodel (6.1.7.6) - activesupport (= 6.1.7.6) - activerecord (6.1.7.6) - activemodel (= 6.1.7.6) - activesupport (= 6.1.7.6) - activestorage (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activesupport (= 6.1.7.6) + activemodel (6.1.7.7) + activesupport (= 6.1.7.7) + activerecord (6.1.7.7) + activemodel (= 6.1.7.7) + activesupport (= 6.1.7.7) + activestorage (6.1.7.7) + actionpack (= 6.1.7.7) + activejob (= 6.1.7.7) + activerecord (= 6.1.7.7) + activesupport (= 6.1.7.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7.6) + activesupport (6.1.7.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - acts_as_list (0.9.19) - activerecord (>= 3.0) - addressable (2.8.5) + acts_as_list (1.1.0) + activerecord (>= 4.2) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - axe-core-api (4.7.0) - dumb_delegator - virtus - axe-core-rspec (4.1.0) - axe-core-api - dumb_delegator - virtus - axiom-types (0.1.1) - descendants_tracker (~> 0.0.4) - ice_nine (~> 0.11.0) - thread_safe (~> 0.3, >= 0.3.1) + base64 (0.2.0) batch-loader (1.5.0) - bcrypt (3.1.19) - better_html (1.0.16) - actionview (>= 4.0) - activesupport (>= 4.0) + bcrypt (3.1.20) + better_html (2.1.1) + actionview (>= 6.0) + activesupport (>= 6.0) ast (~> 2.0) erubi (~> 1.4) - html_tokenizer (~> 0.0.6) parser (>= 2.4) smart_properties + bigdecimal (3.1.7) bindex (0.8.1) - bootsnap (1.16.0) + bootsnap (1.18.3) msgpack (~> 1.2) browser (2.7.1) builder (3.2.4) + bullet (7.1.6) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.11) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.4) + carrierwave (2.2.6) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) @@ -132,20 +125,9 @@ GEM actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.7) - chef-utils (18.2.7) - concurrent-ruby - childprocess (4.1.0) - coercible (1.0.0) - descendants_tracker (~> 0.0.1) - coffee-rails (5.0.0) - coffee-script (>= 2.2.0) - railties (>= 5.2.0) - coffee-script (2.4.1) - coffee-script-source - execjs - coffee-script-source (1.12.2) + childprocess (5.0.0) commonmarker (0.23.10) - concurrent-ruby (1.2.2) + concurrent-ruby (1.2.3) countries (3.1.0) i18n_data (~> 0.11.0) sixarm_ruby_unaccent (~> 1.1) @@ -153,79 +135,78 @@ GEM country_select (4.0.0) countries (~> 3.0) sort_alphabetical (~> 1.0) - crack (0.4.5) + crack (1.0.0) + bigdecimal rexml crass (1.0.6) - css_parser (1.14.0) + css_parser (1.17.1) addressable - date (3.3.3) + date (3.3.4) date_validator (0.12.0) activemodel (>= 3) activesupport (>= 3) - db-query-matchers (0.10.0) - activesupport (>= 4.0, < 7) - rspec (~> 3.0) - decidim (0.27.4) - decidim-accountability (= 0.27.4) - decidim-admin (= 0.27.4) - decidim-api (= 0.27.4) - decidim-assemblies (= 0.27.4) - decidim-blogs (= 0.27.4) - decidim-budgets (= 0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - decidim-debates (= 0.27.4) - decidim-forms (= 0.27.4) - decidim-generators (= 0.27.4) - decidim-meetings (= 0.27.4) - decidim-pages (= 0.27.4) - decidim-participatory_processes (= 0.27.4) - decidim-proposals (= 0.27.4) - decidim-sortitions (= 0.27.4) - decidim-surveys (= 0.27.4) - decidim-system (= 0.27.4) - decidim-templates (= 0.27.4) - decidim-verifications (= 0.27.4) - decidim-accountability (0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - decidim-admin (0.27.4) + decidim (0.28.0) + decidim-accountability (= 0.28.0) + decidim-admin (= 0.28.0) + decidim-api (= 0.28.0) + decidim-assemblies (= 0.28.0) + decidim-blogs (= 0.28.0) + decidim-budgets (= 0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + decidim-debates (= 0.28.0) + decidim-forms (= 0.28.0) + decidim-generators (= 0.28.0) + decidim-meetings (= 0.28.0) + decidim-pages (= 0.28.0) + decidim-participatory_processes (= 0.28.0) + decidim-proposals (= 0.28.0) + decidim-sortitions (= 0.28.0) + decidim-surveys (= 0.28.0) + decidim-system (= 0.28.0) + decidim-templates (= 0.28.0) + decidim-verifications (= 0.28.0) + decidim-accountability (0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + decidim-admin (0.28.0) active_link_to (~> 1.0) - decidim-core (= 0.27.4) + decidim-core (= 0.28.0) devise (~> 4.7) devise-i18n (~> 1.2) - devise_invitable (~> 2.0) - decidim-api (0.27.4) - graphql (~> 1.12, < 1.13) - graphql-docs (~> 2.1.0) + devise_invitable (~> 2.0, >= 2.0.9) + decidim-api (0.28.0) + commonmarker (~> 0.23.0, >= 0.23.9) + graphql (~> 2.0.0) + graphql-docs (~> 3.0.1) rack-cors (~> 1.0) - decidim-assemblies (0.27.4) - decidim-core (= 0.27.4) - decidim-blogs (0.27.4) - decidim-admin (= 0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - decidim-budgets (0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - decidim-comments (0.27.4) - decidim-core (= 0.27.4) + decidim-assemblies (0.28.0) + decidim-core (= 0.28.0) + decidim-blogs (0.28.0) + decidim-admin (= 0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + decidim-budgets (0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + decidim-comments (0.28.0) + decidim-core (= 0.28.0) redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.27.4) + decidim-core (0.28.0) active_link_to (~> 1.0) - acts_as_list (~> 0.9) + acts_as_list (~> 1.0) batch-loader (~> 1.2) browser (~> 2.7) - carrierwave (~> 2.2.1) + carrierwave (~> 2.2.5, >= 2.2.5) cells-erb (~> 0.1.0) cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) date_validator (~> 0.12.0) - decidim-api (= 0.27.4) + decidim-api (= 0.28.0) devise (~> 4.7) - devise-i18n (~> 1.2) + devise-i18n (~> 1.2, < 1.11.1) diffy (~> 3.3) - doorkeeper (~> 5.1) + doorkeeper (~> 5.6, >= 5.6.6) doorkeeper-i18n (~> 4.0) file_validators (~> 3.0) fog-local (~> 0.6) @@ -234,104 +215,106 @@ GEM hashdiff (>= 0.4.0, < 2.0.0) invisible_captcha (~> 0.12) kaminari (~> 1.2, >= 1.2.1) - loofah (~> 2.19.0) + loofah (~> 2.19, >= 2.19.1) mime-types (>= 1.16, < 4.0) mini_magick (~> 4.9) mustache (~> 1.1.0) + net-smtp (~> 0.3.1) omniauth (~> 2.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 1.0) omniauth-rails_csrf_protection (~> 1.0) omniauth-twitter (~> 1.4) paper_trail (~> 12.0) - pg (~> 1.1.4, < 2) + pg (~> 1.4.0, < 2) pg_search (~> 2.2) premailer-rails (~> 1.10) - rack (~> 2.2, >= 2.2.3) + psych (~> 4.0) + rack (~> 2.2, >= 2.2.6.4) rack-attack (~> 6.0) - rails (~> 6.1.0) + rails (~> 6.1.7, >= 6.1.7.4) rails-i18n (~> 6.0) - ransack (~> 2.4.1) + ransack (~> 3.2.1) redis (~> 4.1) request_store (~> 1.5.0) rubyXL (~> 3.4) rubyzip (~> 2.0) seven_zip_ruby (~> 1.3) - social-share-button (~> 1.2, >= 1.2.1) - valid_email2 (~> 2.1) - webpacker (= 6.0.0.rc.5) - webpush (~> 1.1) + shakapacker (~> 7.1.0) + valid_email2 (~> 4.0) + web-push (~> 3.0) wisper (~> 2.0) - decidim-debates (0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - decidim-dev (0.27.4) - axe-core-rspec (~> 4.1.0) + decidim-debates (0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + decidim-dev (0.28.0) + bullet (~> 7.0) byebug (~> 11.0) - capybara (~> 3.24) - db-query-matchers (~> 0.10.0) - decidim (= 0.27.4) - erb_lint (~> 0.0.35) - factory_bot_rails (~> 4.8) - i18n-tasks (~> 0.9.18) - mdl (~> 0.5) - nokogiri (~> 1.13) - parallel_tests (~> 3.7) - puma (~> 5.0) + capybara (~> 3.39) + decidim (= 0.28.0) + erb_lint (~> 0.4.0) + factory_bot_rails (~> 6.2) + faker (~> 3.2) + i18n-tasks (~> 1.0) + nokogiri (~> 1.14, >= 1.14.3) + parallel_tests (~> 4.2) + puma (~> 6.2, >= 6.3.1) rails-controller-testing (~> 1.0) + rspec (~> 3.12) rspec-cells (~> 0.3.7) - rspec-html-matchers (~> 0.9.1) - rspec-rails (~> 4.0) + rspec-html-matchers (~> 0.10) + rspec-rails (~> 6.0) rspec-retry (~> 0.6.2) - rspec_junit_formatter (~> 0.3.0) - rubocop (~> 1.28.0) - rubocop-rails (~> 2.14) - rubocop-rspec (~> 2.10) - selenium-webdriver (~> 4.1.0) - simplecov (~> 0.21.0) + rspec_junit_formatter (~> 0.6.0) + rubocop (~> 1.50.0) + rubocop-faker (~> 1.1) + rubocop-rails (~> 2.19) + rubocop-rspec (~> 2.20) + selenium-webdriver (~> 4.9) + simplecov (~> 0.22.0) simplecov-cobertura (~> 2.1.0) w3c_rspec_validators (~> 0.3.0) - webmock (~> 3.6) + webmock (~> 3.18) wisper-rspec (~> 1.0) - decidim-forms (0.27.4) - decidim-core (= 0.27.4) + decidim-forms (0.28.0) + decidim-core (= 0.28.0) wicked_pdf (~> 2.1) wkhtmltopdf-binary (~> 0.12) - decidim-generators (0.27.4) - decidim-core (= 0.27.4) - decidim-meetings (0.27.4) - decidim-core (= 0.27.4) - decidim-forms (= 0.27.4) + decidim-generators (0.28.0) + decidim-core (= 0.28.0) + decidim-meetings (0.28.0) + decidim-core (= 0.28.0) + decidim-forms (= 0.28.0) icalendar (~> 2.5) - decidim-pages (0.27.4) - decidim-core (= 0.27.4) - decidim-participatory_processes (0.27.4) - decidim-core (= 0.27.4) - decidim-proposals (0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - doc2text (~> 0.4.5) + decidim-pages (0.28.0) + decidim-core (= 0.28.0) + decidim-participatory_processes (0.28.0) + decidim-core (= 0.28.0) + decidim-proposals (0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + doc2text (~> 0.4.6) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.27.4) - decidim-admin (= 0.27.4) - decidim-comments (= 0.27.4) - decidim-core (= 0.27.4) - decidim-proposals (= 0.27.4) - decidim-surveys (0.27.4) - decidim-core (= 0.27.4) - decidim-forms (= 0.27.4) - decidim-templates (= 0.27.4) - decidim-system (0.27.4) + decidim-sortitions (0.28.0) + decidim-admin (= 0.28.0) + decidim-comments (= 0.28.0) + decidim-core (= 0.28.0) + decidim-proposals (= 0.28.0) + decidim-surveys (0.28.0) + decidim-core (= 0.28.0) + decidim-forms (= 0.28.0) + decidim-templates (= 0.28.0) + decidim-system (0.28.0) active_link_to (~> 1.0) - decidim-core (= 0.27.4) + decidim-core (= 0.28.0) devise (~> 4.7) devise-i18n (~> 1.2) - devise_invitable (~> 2.0) - decidim-templates (0.27.4) - decidim-core (= 0.27.4) - decidim-forms (= 0.27.4) - decidim-verifications (0.27.4) - decidim-core (= 0.27.4) + devise_invitable (~> 2.0, >= 2.0.9) + decidim-templates (0.28.0) + decidim-core (= 0.28.0) + decidim-forms (= 0.28.0) + decidim-verifications (0.28.0) + decidim-core (= 0.28.0) declarative-builder (0.1.0) declarative-option (< 0.2.0) declarative-option (0.1.0) @@ -341,9 +324,7 @@ GEM polyglot railties (>= 5.2) rainbow (>= 2.1.0) - descendants_tracker (0.0.4) - thread_safe (~> 0.3, >= 0.3.1) - devise (4.9.2) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) @@ -351,24 +332,21 @@ GEM warden (~> 1.2.3) devise-i18n (1.11.0) devise (>= 4.9.0) - devise_invitable (2.0.8) + devise_invitable (2.0.9) actionmailer (>= 5.0) devise (>= 4.6) - diff-lcs (1.5.0) + diff-lcs (1.5.1) diffy (3.4.2) - doc2text (0.4.6) - nokogiri (>= 1.13.2, < 1.15.0) + doc2text (0.4.7) + nokogiri (>= 1.13.2, < 1.17.0) rubyzip (~> 2.3.0) docile (1.4.0) - doorkeeper (5.6.6) + doorkeeper (5.6.9) railties (>= 5) doorkeeper-i18n (4.0.1) - dumb_delegator (1.0.0) - equalizer (0.0.11) - erb_lint (0.0.37) + erb_lint (0.4.0) activesupport - better_html (~> 1.0.7) - html_tokenizer + better_html (>= 2.0.1) parser (>= 2.7.1.4) rainbow rubocop @@ -376,27 +354,26 @@ GEM erbse (0.1.4) temple erubi (1.12.0) - escape_utils (1.3.0) - excon (0.102.0) - execjs (2.8.1) + escape_utils (1.2.2) + excon (0.110.0) extended-markdown-filter (0.7.0) html-pipeline (~> 2.9) - factory_bot (4.11.1) - activesupport (>= 3.0.0) - factory_bot_rails (4.11.1) - factory_bot (~> 4.11.1) - railties (>= 3.0.0) - faker (2.23.0) + factory_bot (6.4.6) + activesupport (>= 5.0.0) + factory_bot_rails (6.4.3) + factory_bot (~> 6.4) + railties (>= 5.0.0) + faker (3.3.1) i18n (>= 1.8.11, < 2) - faraday (2.7.10) - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.2) - ffi (1.15.5) + faraday (2.9.0) + faraday-net_http (>= 2.0, < 3.2) + faraday-net_http (3.1.0) + net-http + ffi (1.16.3) file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) - fog-core (2.3.0) + fog-core (2.4.0) builder excon (~> 0.71) formatador (>= 0.2, < 2.0) @@ -411,50 +388,50 @@ GEM railties (>= 4.1, < 7.1) gemoji (3.0.1) geocoder (1.8.2) - globalid (1.1.0) - activesupport (>= 5.0) - graphql (1.12.24) - graphql-docs (2.1.0) + globalid (1.2.1) + activesupport (>= 6.1) + graphql (2.0.29) + base64 + graphql-docs (3.0.1) commonmarker (~> 0.16) - escape_utils (~> 1.2) + escape_utils (~> 1.2.2) extended-markdown-filter (~> 0.4) gemoji (~> 3.0) - graphql (~> 1.12) + graphql (~> 2.0) html-pipeline (~> 2.9) sass (~> 3.4) - hashdiff (1.0.1) + hashdiff (1.1.0) hashie (5.0.0) - highline (2.1.0) - hkdf (0.3.0) + highline (3.0.1) html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) - html_tokenizer (0.0.7) htmlentities (4.3.4) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) - i18n-tasks (0.9.37) + i18n-tasks (1.0.13) activesupport (>= 4.0.2) ast (>= 2.1.0) + better_html (>= 1.0, < 3.0) erubi highline (>= 2.0.0) i18n - parser (>= 2.2.3.0) + parser (>= 3.2.2.1) rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) i18n_data (0.11.0) - icalendar (2.9.0) + icalendar (2.10.1) ice_cube (~> 0.16) ice_cube (0.16.4) - ice_nine (0.11.2) image_processing (1.12.2) mini_magick (>= 4.9.5, < 5) ruby-vips (>= 2.0.17, < 3) invisible_captcha (0.13.0) rails (>= 3.2.0) - json (2.6.3) - jwt (2.7.1) + json (2.7.2) + jwt (2.8.1) + base64 kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -467,67 +444,51 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - kramdown (2.4.0) - rexml - kramdown-parser-gfm (1.1.0) - kramdown (~> 2.0) - launchy (2.5.2) + launchy (3.0.0) addressable (~> 2.8) - letter_opener (1.8.1) - launchy (>= 2.2, < 3) + childprocess (~> 5.0) + letter_opener (1.10.0) + launchy (>= 2.2, < 4) letter_opener_web (1.4.1) actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) - listen (3.8.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.19.1) + loofah (2.22.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - mdl (0.12.0) - kramdown (~> 2.3) - kramdown-parser-gfm (~> 1.1) - mixlib-cli (~> 2.1, >= 2.1.1) - mixlib-config (>= 2.2.1, < 4) - mixlib-shellout method_source (1.0.0) - mime-types (3.5.1) + mime-types (3.5.2) mime-types-data (~> 3.2015) - mime-types-data (3.2023.0808) + mime-types-data (3.2024.0305) mini_magick (4.12.0) mini_mime (1.1.5) - minitest (5.19.0) - mixlib-cli (2.1.8) - mixlib-config (3.0.27) - tomlrb - mixlib-shellout (3.2.7) - chef-utils + minitest (5.22.3) msgpack (1.7.2) multi_xml (0.6.0) mustache (1.1.1) - net-imap (0.3.7) + net-http (0.4.1) + uri + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.3.3) + net-smtp (0.3.4) net-protocol - nio4r (2.5.9) - nokogiri (1.14.5-arm64-darwin) - racc (~> 1.4) - nokogiri (1.14.5-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.14.5-x86_64-linux) + nio4r (2.7.1) + nokogiri (1.16.3-x86_64-linux) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) @@ -542,17 +503,17 @@ GEM rack (>= 1.2, < 4) snaky_hash (~> 2.0) version_gem (~> 1.1) - omniauth (2.1.1) + omniauth (2.1.2) hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (1.1.1) + omniauth-google-oauth2 (1.1.2) jwt (>= 2.0) - oauth2 (~> 2.0.6) + oauth2 (~> 2.0) omniauth (~> 2.0) - omniauth-oauth2 (~> 1.8.0) + omniauth-oauth2 (~> 1.8) omniauth-oauth (1.2.0) oauth omniauth (>= 1.0, < 3) @@ -565,22 +526,23 @@ GEM omniauth-twitter (1.4.0) omniauth-oauth (~> 1.1) rack + openssl (3.2.0) orm_adapter (0.5.0) paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) - parallel (1.23.0) - parallel_tests (3.13.0) + parallel (1.24.0) + parallel_tests (4.6.1) parallel - parser (3.2.2.3) + parser (3.3.0.5) ast (~> 2.4.1) racc - pg (1.1.4) + pg (1.4.6) pg_search (2.3.6) activerecord (>= 5.2) activesupport (>= 5.2) polyglot (0.3.5) - premailer (1.21.0) + premailer (1.23.0) addressable css_parser (>= 1.12.0) htmlentities (>= 4.0.0) @@ -588,35 +550,38 @@ GEM actionmailer (>= 3) net-smtp premailer (~> 1.7, >= 1.7.9) - public_suffix (5.0.3) - puma (5.6.7) + psych (4.0.6) + stringio + public_suffix (5.0.5) + puma (6.4.2) nio4r (~> 2.0) - racc (1.7.1) - rack (2.2.8) + racc (1.7.3) + rack (2.2.9) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-cors (1.1.1) rack (>= 2.0.0) - rack-protection (3.1.0) + rack-protection (3.2.0) + base64 (>= 0.1.0) rack (~> 2.2, >= 2.2.4) - rack-proxy (0.7.6) + rack-proxy (0.7.7) rack rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.6) - actioncable (= 6.1.7.6) - actionmailbox (= 6.1.7.6) - actionmailer (= 6.1.7.6) - actionpack (= 6.1.7.6) - actiontext (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activemodel (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + rails (6.1.7.7) + actioncable (= 6.1.7.7) + actionmailbox (= 6.1.7.7) + actionmailer (= 6.1.7.7) + actionpack (= 6.1.7.7) + actiontext (= 6.1.7.7) + actionview (= 6.1.7.7) + activejob (= 6.1.7.7) + activemodel (= 6.1.7.7) + activerecord (= 6.1.7.7) + activestorage (= 6.1.7.7) + activesupport (= 6.1.7.7) bundler (>= 1.15.0) - railties (= 6.1.7.6) + railties (= 6.1.7.7) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -626,91 +591,102 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + railties (6.1.7.7) + actionpack (= 6.1.7.7) + activesupport (= 6.1.7.7) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) - rake (13.0.6) - ransack (2.4.2) - activerecord (>= 5.2.4) - activesupport (>= 5.2.4) + rake (13.2.1) + ransack (3.2.1) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) i18n rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) redcarpet (3.6.0) redis (4.8.1) - regexp_parser (2.8.1) + regexp_parser (2.9.0) request_store (1.5.1) rack (>= 1.4) - responders (3.1.0) + responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rexml (3.2.6) - rspec (3.12.0) - rspec-core (~> 3.12.0) - rspec-expectations (~> 3.12.0) - rspec-mocks (~> 3.12.0) - rspec-cells (0.3.8) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-cells (0.3.9) cells (>= 4.0.0, < 6.0.0) - rspec-rails (>= 3.0.0, < 6.1.0) - rspec-core (3.12.2) - rspec-support (~> 3.12.0) - rspec-expectations (3.12.3) + rspec-rails (>= 3.0.0, < 6.2.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-html-matchers (0.9.4) + rspec-support (~> 3.13.0) + rspec-html-matchers (0.10.0) nokogiri (~> 1) - rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.12.6) + rspec (>= 3.0.0.a) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (4.1.2) - actionpack (>= 4.2) - activesupport (>= 4.2) - railties (>= 4.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) rspec-retry (0.6.2) rspec-core (> 3.3) - rspec-support (3.12.1) - rspec_junit_formatter (0.3.0) + rspec-support (3.13.1) + rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.28.2) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) - rexml - rubocop-ast (>= 1.17.0, < 2.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.29.0) - parser (>= 3.2.1.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.31.2) + parser (>= 3.3.0.4) + rubocop-capybara (2.20.0) + rubocop (~> 1.41) + rubocop-factory_bot (2.25.1) + rubocop (~> 1.41) rubocop-faker (1.1.0) faker (>= 2.12.0) rubocop (>= 0.82.0) - rubocop-rails (2.15.2) + rubocop-rails (2.24.1) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (2.11.1) - rubocop (~> 1.19) + rubocop (>= 1.33.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (2.29.1) + rubocop (~> 1.40) + rubocop-capybara (~> 2.17) + rubocop-factory_bot (~> 2.22) + rubocop-rspec_rails (~> 2.28) + rubocop-rspec_rails (2.28.2) + rubocop (~> 1.40) ruby-progressbar (1.13.0) - ruby-vips (2.1.4) + ruby-vips (2.2.1) ffi (~> 1.12) - ruby2_keywords (0.0.5) - rubyXL (3.4.25) + rubyXL (3.4.26) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) @@ -719,13 +695,19 @@ GEM sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - selenium-webdriver (4.1.0) - childprocess (>= 0.5, < 5.0) + selenium-webdriver (4.19.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) semantic_range (3.0.0) seven_zip_ruby (1.3.0) - simplecov (0.21.2) + shakapacker (7.1.0) + activesupport (>= 5.2) + rack-proxy (>= 0.6.1) + railties (>= 5.2) + semantic_range (>= 2.3.0) + simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) @@ -739,44 +721,38 @@ GEM snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - social-share-button (1.2.4) - coffee-rails sort_alphabetical (1.1.0) unicode_utils (>= 1.2.2) spring (2.1.1) spring-watcher-listen (2.0.1) listen (>= 2.7, < 4.0) spring (>= 1.2, < 3.0) - sprockets (4.2.0) + sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.4.2) actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - ssrf_filter (1.1.1) - temple (0.10.2) + ssrf_filter (1.1.2) + stringio (3.1.0) + temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thor (1.2.2) - thread_safe (0.3.6) - tilt (2.2.0) - timeout (0.4.0) - tomlrb (2.0.3) + thor (1.3.1) + tilt (2.3.0) + timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unicode-display_width (2.4.2) + unicode-display_width (2.5.0) unicode_utils (1.4.0) - valid_email2 (2.3.1) + uniform_notifier (1.16.0) + uri (0.13.0) + valid_email2 (4.0.6) activemodel (>= 3.2) mail (~> 2.5) - version_gem (1.1.3) - virtus (1.0.5) - axiom-types (~> 0.1) - coercible (~> 1.0) - descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) + version_gem (1.1.4) w3c_rspec_validators (0.3.0) rails rspec @@ -792,44 +768,37 @@ GEM activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webmock (3.19.0) + web-push (3.0.1) + jwt (~> 2.0) + openssl (~> 3.0) + webmock (3.23.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webpacker (6.0.0.rc.5) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) - webpush (1.1.0) - hkdf (~> 0.2) - jwt (~> 2.0) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - wicked_pdf (2.7.0) + wicked_pdf (2.8.0) activesupport wisper (2.0.1) wisper-rspec (1.1.0) wkhtmltopdf-binary (0.12.6.6) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.11) + zeitwerk (2.6.13) PLATFORMS - arm64-darwin-21 - arm64-darwin-22 - x86_64-darwin-20 x86_64-linux DEPENDENCIES bootsnap (~> 1.4) byebug (~> 11.0) country_select (~> 4.0) - decidim (~> 0.27.4) - decidim-dev (~> 0.27.4) + decidim (~> 0.28) + decidim-dev (~> 0.28) decidim-extra_user_fields! - faker (~> 2.14) + faker (~> 3.3.1) letter_opener_web (~> 1.3) listen (~> 3.1) puma (>= 4.3) @@ -839,7 +808,7 @@ DEPENDENCIES web-console (~> 3.5) RUBY VERSION - ruby 3.0.2p107 + ruby 3.1.1p18 BUNDLED WITH - 2.3.19 + 2.4.10 From 77ecb24a9d480d10b767f32e9dac87e16ce70dd7 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 17:50:44 +0200 Subject: [PATCH 09/42] Add admin icon of module --- lib/decidim/extra_user_fields/admin_engine.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/decidim/extra_user_fields/admin_engine.rb b/lib/decidim/extra_user_fields/admin_engine.rb index 60d8516..8920c58 100644 --- a/lib/decidim/extra_user_fields/admin_engine.rb +++ b/lib/decidim/extra_user_fields/admin_engine.rb @@ -36,12 +36,17 @@ class AdminEngine < ::Rails::Engine end end + initializer "decidim_extra_user_fields.icons" do + Decidim.icons.register(name: "input-field", icon: "input-field", category: "system", description: "", engine: :extra_user_fields) + end + initializer "decidim_extra_user_fields.admin_settings_menu" do Decidim.menu :admin_settings_menu do |menu| menu.add_item :extra_user_fields, t("decidim.admin.extra_user_fields.menu.title"), decidim_extra_user_fields.root_path, - position: 11 + position: 11, + icon_name: "input-field" end end From 1405c861a4ae59ca33608f6292c5ca4617c9b7e1 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 17:52:09 +0200 Subject: [PATCH 10/42] Use custom_country_select on front form --- app/views/decidim/extra_user_fields/_profile_form.html.erb | 4 +--- .../decidim/extra_user_fields/_registration_form.html.erb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index ca68184..d3d7117 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -8,9 +8,7 @@ <% if current_organization.activated_extra_field?(:country) %> <%= f.label :country do %> - <%# TODO: include the required attribute properly %> - <%= t("activemodel.attributes.user.country") %> - <%= f.country_select :country %> + <%= f.custom_country_select :country %> <% end %> <% end %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index e6eb234..0fb2b21 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -12,9 +12,7 @@ <% if current_organization.activated_extra_field?(:country) %> <%= f.label :country do %> - <%# TODO: include the required attribute properly %> - <%= t("activemodel.attributes.user.country") %> - <%= f.country_select :country %> + <%= f.custom_country_select :country %> <% end %> <% end %> From 14474a6c06b026d601a943bc10ba1deebfa38cfc Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 17:54:31 +0200 Subject: [PATCH 11/42] Allow admins to edit placeholder and pattern fields of phone_number and use it in front --- .../admin/update_extra_user_fields.rb | 6 +++++- .../admin/extra_user_fields_form.rb | 5 +++++ .../extra_user_fields/application_helper.rb | 8 ++++++++ .../extra_user_fields/organization_overrides.rb | 6 ++++++ .../extra_user_fields/_profile_form.html.erb | 12 +----------- .../_registration_form.html.erb | 12 +----------- .../fields/_phone_number.html.erb | 17 ++--------------- 7 files changed, 28 insertions(+), 38 deletions(-) diff --git a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb index 6e1a057..1e1198a 100644 --- a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb +++ b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb @@ -46,7 +46,11 @@ def extra_user_fields "country" => { "enabled" => form.country.presence || false }, "postal_code" => { "enabled" => form.postal_code.presence || false }, "gender" => { "enabled" => form.gender.presence || false }, - "phone_number" => { "enabled" => form.phone_number.presence || false }, + "phone_number" => { + "enabled" => form.phone_number.presence || false, + "pattern" => form.phone_number_pattern.presence, + "placeholder" => form.phone_number_placeholder.presence + }, "location" => { "enabled" => form.location.presence || false }, # Block ExtraUserFields SaveFieldInConfig diff --git a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb index 05b15cf..3b2e364 100644 --- a/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb +++ b/app/forms/decidim/extra_user_fields/admin/extra_user_fields_form.rb @@ -13,6 +13,9 @@ class ExtraUserFieldsForm < Decidim::Form attribute :gender, Boolean attribute :phone_number, Boolean attribute :location, Boolean + + attribute :phone_number_pattern, String + attribute :phone_number_placeholder, String # Block ExtraUserFields Attributes # EndBlock @@ -25,6 +28,8 @@ def map_model(model) self.gender = model.extra_user_fields.dig("gender", "enabled") self.phone_number = model.extra_user_fields.dig("phone_number", "enabled") self.location = model.extra_user_fields.dig("location", "enabled") + self.phone_number_pattern = model.extra_user_fields.dig("phone_number", "pattern") + self.phone_number_placeholder = model.extra_user_fields.dig("phone_number", "placeholder") # Block ExtraUserFields MapModel # EndBlock diff --git a/app/helpers/decidim/extra_user_fields/application_helper.rb b/app/helpers/decidim/extra_user_fields/application_helper.rb index 432485e..edad20d 100644 --- a/app/helpers/decidim/extra_user_fields/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/application_helper.rb @@ -10,6 +10,14 @@ def gender_options_for_select [gender, I18n.t(gender, scope: "decidim.extra_user_fields.genders")] end end + + def phone_number_extra_user_field_pattern + current_organization.extra_user_field_configuration(:phone_number)["pattern"] + end + + def phone_number_extra_user_field_placeholder + current_organization.extra_user_field_configuration(:phone_number)["placeholder"] + end end end end diff --git a/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb b/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb index 6ff4fec..7784ca6 100644 --- a/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb +++ b/app/models/concerns/decidim/extra_user_fields/organization_overrides.rb @@ -22,6 +22,12 @@ def at_least_one_extra_field? def activated_extra_field?(sym) extra_user_fields.dig(sym.to_s, "enabled") == true end + + def extra_user_field_configuration(sym) + return {} unless activated_extra_field?(sym) + + extra_user_fields[sym.to_s].except("enabled") + end end end end diff --git a/app/views/decidim/extra_user_fields/_profile_form.html.erb b/app/views/decidim/extra_user_fields/_profile_form.html.erb index d3d7117..81eeff3 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -16,18 +16,8 @@ <%= f.text_field :postal_code %> <% end %> -<% -# TODO: move wherever it takes -def telephone_pattern - "^(\\+34)?[0-9 ]{9,12}$" -end - -def telephone_placeholder - "+34987654321" -end -%> <% if current_organization.activated_extra_field?(:phone_number) %> - <%= f.telephone_field :phone_number, placeholder: telephone_placeholder, pattern: telephone_pattern %> + <%= f.telephone_field :phone_number, placeholder: f.object.phone_number_extra_user_field_placeholder, pattern: f.object.phone_number_extra_user_field_pattern %> <% end %> <% if current_organization.activated_extra_field?(:location) %> diff --git a/app/views/decidim/extra_user_fields/_registration_form.html.erb b/app/views/decidim/extra_user_fields/_registration_form.html.erb index 0fb2b21..06317b1 100644 --- a/app/views/decidim/extra_user_fields/_registration_form.html.erb +++ b/app/views/decidim/extra_user_fields/_registration_form.html.erb @@ -20,18 +20,8 @@ <%= f.text_field :postal_code %> <% end %> - <% - # TODO: move wherever it takes - def telephone_pattern - "^(\\+34)?[0-9 ]{9,12}$" - end - - def telephone_placeholder - "+34987654321" - end - %> <% if current_organization.activated_extra_field?(:phone_number) %> - <%= f.telephone_field :phone_number, placeholder: telephone_placeholder, pattern: telephone_pattern %> + <%= f.telephone_field :phone_number, placeholder: f.object.phone_number_extra_user_field_placeholder, pattern: f.object.phone_number_extra_user_field_pattern %> <% end %> <% if current_organization.activated_extra_field?(:location) %> diff --git a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb index 35cf4ca..f65d9f8 100644 --- a/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb +++ b/app/views/decidim/extra_user_fields/admin/extra_user_fields/fields/_phone_number.html.erb @@ -3,20 +3,7 @@ <%= form.check_box :phone_number, label: t(".label"), help_text: t(".description") %>
- <% - # TODO: move wherever it takes - def telephone_pattern - "^(\\+34)?[0-9 ]{9,12}$" - end - - def telephone_placeholder - "+34987654321" - end - %> - <%# TODO: replace with the proper rails helpers fields %> - - - <%#= form.text_field :phone_number_pattern, label: t(".pattern"), placeholder: telephone_pattern %> - <%#= form.text_field :phone_number_placeholder, label: t(".placeholder"), placeholder: telephone_placeholder %> + <%= form.text_field :phone_number_pattern, label: t(".pattern"), placeholder: "^(\\+34)?[0-9 ]{9,12}$" %> + <%= form.text_field :phone_number_placeholder, label: t(".placeholder"), placeholder: "+34987654321" %>
From 7d94ee54b96d356cca9c778dfac0743c0a483088 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 18:44:19 +0200 Subject: [PATCH 12/42] Validate phone number format in the form if required --- .../decidim/extra_user_fields/forms_definitions.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb index a67f71c..0466545 100644 --- a/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb +++ b/app/forms/concerns/decidim/extra_user_fields/forms_definitions.rb @@ -29,6 +29,12 @@ module FormsDefinitions validates :date_of_birth, presence: true, if: :date_of_birth? validates :gender, presence: true, inclusion: { in: Decidim::ExtraUserFields::Engine::DEFAULT_GENDER_OPTIONS.map(&:to_s) }, if: :gender? validates :phone_number, presence: true, if: :phone_number? + validates( + :phone_number, + format: { with: ->(form) { Regexp.new(form.current_organization.extra_user_field_configuration(:phone_number)["pattern"]) } }, + if: :phone_number_format? + ) + validates :location, presence: true, if: :location? # EndBlock @@ -72,6 +78,12 @@ def phone_number? extra_user_fields_enabled && current_organization.activated_extra_field?(:phone_number) end + def phone_number_format? + return unless phone_number? + + current_organization.extra_user_field_configuration(:phone_number)["pattern"].present? + end + def location? extra_user_fields_enabled && current_organization.activated_extra_field?(:location) end From e1046dca2e5879c85c8a9a9116dbf8f2155c076d Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 19:11:37 +0200 Subject: [PATCH 13/42] Update module version --- Gemfile.lock | 2 +- lib/decidim/extra_user_fields/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bb70af6..1569874 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - decidim-extra_user_fields (0.27.2) + decidim-extra_user_fields (0.28.0) country_select (~> 4.0) decidim-core (>= 0.28) deface (~> 1.5) diff --git a/lib/decidim/extra_user_fields/version.rb b/lib/decidim/extra_user_fields/version.rb index 8daf38f..f28f7fe 100644 --- a/lib/decidim/extra_user_fields/version.rb +++ b/lib/decidim/extra_user_fields/version.rb @@ -4,7 +4,7 @@ module Decidim # This holds the decidim-extra_user_fields version. module ExtraUserFields def self.version - "0.27.2" + "0.28.0" end def self.decidim_version From 94d5e359636a964b3a6a3f80343f40591de1a8ce Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 19:48:42 +0200 Subject: [PATCH 14/42] Inherit rubocop config from 0.28 --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3929dc9..b901a13 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,4 +1,4 @@ -inherit_from: https://raw.githubusercontent.com/decidim/decidim/release/0.27-stable/.rubocop.yml +inherit_from: https://raw.githubusercontent.com/decidim/decidim/release/0.28-stable/.rubocop.yml AllCops: Include: From 35aa4aa043210536f7aefe385025afd6a7587320 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 19:49:17 +0200 Subject: [PATCH 15/42] Update organization factory --- spec/factories.rb | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index 37b735f..3fda653 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -5,6 +5,7 @@ FactoryBot.modify do factory :organization, class: "Decidim::Organization" do transient do + skip_injection { false } create_static_pages { true } end @@ -22,7 +23,6 @@ default_locale { Decidim.default_locale } available_locales { Decidim.available_locales } users_registration_mode { :enabled } - official_img_header { Decidim::Dev.test_file("avatar.jpg", "image/jpeg") } official_img_footer { Decidim::Dev.test_file("avatar.jpg", "image/jpeg") } official_url { Faker::Internet.url } highlighted_content_banner_enabled { false } @@ -31,7 +31,7 @@ user_groups_enabled { true } send_welcome_notification { true } comments_max_length { 1000 } - admin_terms_of_use_body { Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title } } + admin_terms_of_service_body { Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title } } force_users_to_authenticate_before_access_organization { false } machine_translation_display_priority { "original" } external_domain_whitelist { ["example.org", "twitter.com", "facebook.com", "youtube.com", "github.com", "mytesturl.me"] } @@ -51,6 +51,25 @@ "enabled" => true } end + content_security_policy do + { + "default-src" => "localhost:* #{host}:*", + "script-src" => "localhost:* #{host}:*", + "style-src" => "localhost:* #{host}:*", + "img-src" => "localhost:* #{host}:*", + "font-src" => "localhost:* #{host}:*", + "connect-src" => "localhost:* #{host}:*", + "frame-src" => "localhost:* #{host}:* www.example.org", + "media-src" => "localhost:* #{host}:*" + } + end + colors do + { + primary: "#e02d2d", + secondary: "#155abf", + tertiary: "#ebc34b" + } + end trait :extra_user_fields_disabled do extra_user_fields do @@ -66,8 +85,8 @@ after(:create) do |organization, evaluator| if evaluator.create_static_pages - tos_page = Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization: organization) - create(:static_page, :tos, organization: organization) if tos_page.nil? + tos_page = Decidim::StaticPage.find_by(slug: "terms-of-service", organization:) + create(:static_page, :tos, organization:, skip_injection: evaluator.skip_injection) if tos_page.nil? end end end From 47a29b2180ba071d54decfb2eb5e69edaec1307f Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 21:04:23 +0200 Subject: [PATCH 16/42] Fix rubocop offenses --- ...create_registrations_commands_overrides.rb | 2 +- .../omniauth_commands_overrides.rb | 4 +- .../admin/update_extra_user_fields.rb | 2 +- .../admin/extra_user_fields_controller.rb | 2 +- .../admin/application_helper.rb | 2 +- .../create_omniauth_registration_spec.rb | 40 +++++++++--------- .../decidim/create_registration_spec.rb | 28 ++++++------- .../admin/update_extra_user_fields_spec.rb | 2 +- spec/forms/decidim/account_form_spec.rb | 42 +++++++++---------- .../admin/extra_user_fields_form_spec.rb | 2 +- .../omniauth_registration_form_spec.rb | 22 +++++----- spec/forms/decidim/registration_form_spec.rb | 36 ++++++++-------- spec/models/decidim/organization_spec.rb | 12 +++--- spec/permissions/admin/permissions_spec.rb | 6 +-- .../user_export_serializer_spec.rb | 12 +++--- spec/system/account_spec.rb | 6 +-- .../admin_manages_officializations_spec.rb | 2 +- ...ges_organization_extra_user_fields_spec.rb | 2 +- spec/system/registration_spec.rb | 16 +++---- 19 files changed, 120 insertions(+), 120 deletions(-) diff --git a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb index 78f4ca5..a6d43d9 100644 --- a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb @@ -23,7 +23,7 @@ def create_user newsletter_notifications_at: form.newsletter_at, accepted_tos_version: form.current_organization.tos_version, locale: form.current_locale, - extended_data: extended_data + extended_data: ) end diff --git a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb index 565cb66..a56d481 100644 --- a/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/omniauth_commands_overrides.rb @@ -13,7 +13,7 @@ module OmniauthCommandsOverrides def create_or_find_user @user = User.find_or_initialize_by( email: verified_email, - organization: organization + organization: ) if @user.persisted? @@ -34,7 +34,7 @@ def create_or_find_user url = URI.parse(form.avatar_url) filename = File.basename(url.path) file = url.open - @user.avatar.attach(io: file, filename: filename) + @user.avatar.attach(io: file, filename:) end @user.skip_confirmation! if verified_email end diff --git a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb index 1e1198a..f3d01c2 100644 --- a/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb +++ b/app/commands/decidim/extra_user_fields/admin/update_extra_user_fields.rb @@ -34,7 +34,7 @@ def update_extra_user_fields! Decidim.traceability.update!( form.current_organization, form.current_user, - extra_user_fields: extra_user_fields + extra_user_fields: ) end diff --git a/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb b/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb index 3969f43..fbec1ca 100644 --- a/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb +++ b/app/controllers/decidim/extra_user_fields/admin/extra_user_fields_controller.rb @@ -19,7 +19,7 @@ def update @form = form(ExtraUserFieldsForm).from_params( params, - current_organization: current_organization + current_organization: ) UpdateExtraUserFields.call(@form) do diff --git a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb index fd4566c..2d47155 100644 --- a/app/helpers/decidim/extra_user_fields/admin/application_helper.rb +++ b/app/helpers/decidim/extra_user_fields/admin/application_helper.rb @@ -12,7 +12,7 @@ def extra_user_fields_export_users_dropdown content_tag(:li, class: "exports--format--#{format.downcase} export--users") do link_to( t("decidim.admin.exports.export_as", name: t("decidim.extra_user_fields.admin.exports.users"), export_format: format.upcase), - AdminEngine.routes.url_helpers.extra_user_fields_export_users_path(format: format) + AdminEngine.routes.url_helpers.extra_user_fields_export_users_path(format:) ) end end.join.html_safe diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index 201c670..b26b214 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -20,12 +20,12 @@ module Comments let(:postal_code) { "75001" } let(:extended_data) do { - country: country, - date_of_birth: date_of_birth, - gender: gender, - location: location, - phone_number: phone_number, - postal_code: postal_code + country:, + date_of_birth:, + gender:, + location:, + phone_number:, + postal_code: } end @@ -119,7 +119,7 @@ module Comments end it "notifies about registration with oauth data" do - user = create(:user, email: email, organization: organization) + user = create(:user, email:, organization:) identity = Decidim::Identity.new(id: 1234) allow(command).to receive(:create_identity).and_return(identity) @@ -129,9 +129,9 @@ module Comments "decidim.user.omniauth_registration", user_id: user.id, identity_id: 1234, - provider: provider, - uid: uid, - email: email, + provider:, + uid:, + email:, name: "Facebook User", nickname: "facebook_user", avatar_url: "http://www.example.com/foo.jpg", @@ -145,17 +145,17 @@ module Comments let(:verified_email) { email } it "links a previously existing user" do - user = create(:user, email: email, organization: organization) + user = create(:user, email:, organization:) expect { command.call }.not_to change(User, :count) expect(user.identities.length).to eq(1) end it "confirms a previously existing user" do - create(:user, email: email, organization: organization) + create(:user, email:, organization:) expect { command.call }.not_to change(User, :count) - user = User.find_by(email: email) + user = User.find_by(email:) expect(user).to be_confirmed end end @@ -164,17 +164,17 @@ module Comments let(:verified_email) { nil } it "doesn't link a previously existing user" do - user = create(:user, email: email, organization: organization) + user = create(:user, email:, organization:) expect { command.call }.to broadcast(:error) expect(user.identities.length).to eq(0) end it "doesn't confirm a previously existing user" do - create(:user, email: email, organization: organization) + create(:user, email:, organization:) expect { command.call }.to broadcast(:error) - user = User.find_by(email: email) + user = User.find_by(email:) expect(user).not_to be_confirmed end end @@ -200,8 +200,8 @@ module Comments context "when a user exists with that identity" do before do - user = create(:user, email: email, organization: organization) - create(:identity, user: user, provider: provider, uid: uid) + user = create(:user, email:, organization:) + create(:identity, user:, provider:, uid:) end it "broadcasts ok" do @@ -212,7 +212,7 @@ module Comments it "confirms the user" do command.call - user = User.find_by(email: email) + user = User.find_by(email:) expect(user).to be_confirmed end end @@ -223,7 +223,7 @@ module Comments it "doesn't confirm the user" do command.call - user = User.find_by(email: email) + user = User.find_by(email:) expect(user).not_to be_confirmed end end diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index cb2f4a3..296e71f 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -24,12 +24,12 @@ module Comments let(:postal_code) { "75001" } let(:extended_data) do { - country: country, - date_of_birth: date_of_birth, - gender: gender, - location: location, - phone_number: phone_number, - postal_code: postal_code + country:, + date_of_birth:, + gender:, + location:, + phone_number:, + postal_code: } end @@ -55,7 +55,7 @@ module Comments let(:form) do RegistrationForm.from_params( form_params, - current_locale: current_locale + current_locale: ).with_context( current_organization: organization ) @@ -78,7 +78,7 @@ module Comments end context "when the user was already invited" do - let(:user) { build(:user, email: email, organization: organization) } + let(:user) { build(:user, email:, organization:) } before do user.invite! @@ -112,16 +112,16 @@ module Comments password_updated_at: an_instance_of(ActiveSupport::TimeWithZone), tos_agreement: form.tos_agreement, newsletter_notifications_at: form.newsletter_at, - organization: organization, + organization:, accepted_tos_version: organization.tos_version, locale: form.current_locale, extended_data: { - country: country, + country:, date_of_birth: Date.parse(date_of_birth), - gender: gender, - location: location, - phone_number: phone_number, - postal_code: postal_code + gender:, + location:, + phone_number:, + postal_code: } ).and_call_original diff --git a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb index 639a183..5766b4e 100644 --- a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb +++ b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb @@ -7,7 +7,7 @@ module ExtraUserFields module Admin describe UpdateExtraUserFields do let(:organization) { create(:organization, extra_user_fields: {}) } - let(:user) { create :user, :admin, :confirmed, organization: organization } + let(:user) { create(:user, :admin, :confirmed, organization:) } let(:extra_user_fields_enabled) { true } let(:postal_code) { true } diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 542a185..50bfdc5 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -6,22 +6,22 @@ module Decidim describe AccountForm do subject do described_class.new( - name: name, - email: email, - nickname: nickname, - password: password, - password_confirmation: password_confirmation, - avatar: avatar, - remove_avatar: remove_avatar, - personal_url: personal_url, - about: about, + name:, + email:, + nickname:, + password:, + password_confirmation:, + avatar:, + remove_avatar:, + personal_url:, + about:, locale: "es", - country: country, - postal_code: postal_code, - date_of_birth: date_of_birth, - gender: gender, - phone_number: phone_number, - location: location + country:, + postal_code:, + date_of_birth:, + gender:, + phone_number:, + location: ).with_context( current_organization: organization, current_user: user @@ -90,7 +90,7 @@ module Decidim context "when it's already in use in the same organization" do context "and belongs to a user" do - let!(:existing_user) { create(:user, email: email, organization: organization) } + let!(:existing_user) { create(:user, email:, organization:) } it "is invalid" do expect(subject).not_to be_valid @@ -98,7 +98,7 @@ module Decidim end context "and belongs to a group" do - let!(:existing_group) { create(:user_group, email: email, organization: organization) } + let!(:existing_group) { create(:user_group, email:, organization:) } it "is invalid" do expect(subject).not_to be_valid @@ -107,7 +107,7 @@ module Decidim end context "when it's already in use in another organization" do - let!(:existing_user) { create(:user, email: email) } + let!(:existing_user) { create(:user, email:) } it "is valid" do expect(subject).to be_valid @@ -126,7 +126,7 @@ module Decidim context "when it's already in use in the same organization" do context "and belongs to a user" do - let!(:existing_user) { create(:user, nickname: nickname, organization: organization) } + let!(:existing_user) { create(:user, nickname:, organization:) } it "is invalid" do expect(subject).not_to be_valid @@ -134,7 +134,7 @@ module Decidim end context "and belongs to a group" do - let!(:existing_group) { create(:user_group, nickname: nickname, organization: organization) } + let!(:existing_group) { create(:user_group, nickname:, organization:) } it "is invalid" do expect(subject).not_to be_valid @@ -143,7 +143,7 @@ module Decidim end context "when it's already in use in another organization" do - let!(:existing_user) { create(:user, nickname: nickname) } + let!(:existing_user) { create(:user, nickname:) } it "is valid" do expect(subject).to be_valid diff --git a/spec/forms/decidim/admin/extra_user_fields_form_spec.rb b/spec/forms/decidim/admin/extra_user_fields_form_spec.rb index 688dd4f..21890cb 100644 --- a/spec/forms/decidim/admin/extra_user_fields_form_spec.rb +++ b/spec/forms/decidim/admin/extra_user_fields_form_spec.rb @@ -19,7 +19,7 @@ module Admin let(:attributes) do { - extra_user_fields: extra_user_fields + extra_user_fields: } end diff --git a/spec/forms/decidim/omniauth_registration_form_spec.rb b/spec/forms/decidim/omniauth_registration_form_spec.rb index dd2dce9..8ead111 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -27,19 +27,19 @@ module Decidim let(:attributes) do { - email: email, + email:, email_verified: true, - name: name, - provider: provider, - uid: uid, - oauth_signature: oauth_signature, + name:, + provider:, + uid:, + oauth_signature:, avatar_url: "http://www.example.org/foo.jpg", - country: country, - postal_code: postal_code, - date_of_birth: date_of_birth, - gender: gender, - phone_number: phone_number, - location: location + country:, + postal_code:, + date_of_birth:, + gender:, + phone_number:, + location: } end diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index a1f79b6..d10cb3a 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -28,18 +28,18 @@ module Decidim let(:attributes) do { - name: name, - nickname: nickname, - email: email, - password: password, - password_confirmation: password_confirmation, - tos_agreement: tos_agreement, - country: country, - postal_code: postal_code, - date_of_birth: date_of_birth, - gender: gender, - phone_number: phone_number, - location: location + name:, + nickname:, + email:, + password:, + password_confirmation:, + tos_agreement:, + country:, + postal_code:, + date_of_birth:, + gender:, + phone_number:, + location: } end @@ -79,19 +79,19 @@ module Decidim context "when the email already exists" do context "and a user has the email" do - let!(:user) { create(:user, organization: organization, email: email) } + let!(:user) { create(:user, organization:, email:) } it { is_expected.to be_invalid } context "and is pending to accept the invitation" do - let!(:user) { create(:user, organization: organization, email: email, invitation_token: "foo", invitation_accepted_at: nil) } + let!(:user) { create(:user, organization:, email:, invitation_token: "foo", invitation_accepted_at: nil) } it { is_expected.to be_invalid } end end context "and a user_group has the email" do - let!(:user_group) { create(:user_group, organization: organization, email: email) } + let!(:user_group) { create(:user_group, organization:, email:) } it { is_expected.to be_invalid } end @@ -99,19 +99,19 @@ module Decidim context "when the nickname already exists" do context "and a user has the nickname" do - let!(:user) { create(:user, organization: organization, nickname: nickname.upcase) } + let!(:user) { create(:user, organization:, nickname: nickname.upcase) } it { is_expected.to be_invalid } context "and is pending to accept the invitation" do - let!(:user) { create(:user, organization: organization, nickname: nickname, invitation_token: "foo", invitation_accepted_at: nil) } + let!(:user) { create(:user, organization:, nickname:, invitation_token: "foo", invitation_accepted_at: nil) } it { is_expected.to be_valid } end end context "and a user_group has the nickname" do - let!(:user_group) { create(:user_group, organization: organization, nickname: nickname) } + let!(:user_group) { create(:user_group, organization:, nickname:) } it { is_expected.to be_invalid } end diff --git a/spec/models/decidim/organization_spec.rb b/spec/models/decidim/organization_spec.rb index 181da15..4760cfc 100644 --- a/spec/models/decidim/organization_spec.rb +++ b/spec/models/decidim/organization_spec.rb @@ -4,7 +4,7 @@ module Decidim describe Organization do - subject(:organization) { build(:organization, extra_user_fields: extra_user_fields) } + subject(:organization) { build(:organization, extra_user_fields:) } let(:extra_user_fields) do { @@ -47,17 +47,17 @@ module Decidim describe "has an association for scopes" do subject(:organization_scopes) { organization.scopes } - let(:scopes) { create_list(:scope, 2, organization: organization) } + let(:scopes) { create_list(:scope, 2, organization:) } - it { is_expected.to contain_exactly(*scopes) } + it { is_expected.to match_array(scopes) } end describe "has an association for scope types" do subject(:organization_scopes_types) { organization.scope_types } - let(:scope_types) { create_list(:scope_type, 2, organization: organization) } + let(:scope_types) { create_list(:scope_type, 2, organization:) } - it { is_expected.to contain_exactly(*scope_types) } + it { is_expected.to match_array(scope_types) } end describe "validations" do @@ -109,7 +109,7 @@ module Decidim } end - before { organization.update!(omniauth_settings: omniauth_settings) } + before { organization.update!(omniauth_settings:) } it "returns only the enabled settings" do expect(subject[:facebook][:app_id]).to eq("overriden-app-id") diff --git a/spec/permissions/admin/permissions_spec.rb b/spec/permissions/admin/permissions_spec.rb index 2eb0285..6e29702 100644 --- a/spec/permissions/admin/permissions_spec.rb +++ b/spec/permissions/admin/permissions_spec.rb @@ -6,7 +6,7 @@ module Decidim::ExtraUserFields::Admin describe Permissions do subject { described_class.new(user, permission_action, context).permissions.allowed? } - let(:organization) { create :organization } + let(:organization) { create(:organization) } let(:context) do { current_organization: organization @@ -18,7 +18,7 @@ module Decidim::ExtraUserFields::Admin let(:permission_action) { Decidim::PermissionAction.new(**action) } context "when user is admin" do - let(:user) { create :user, :admin, organization: organization } + let(:user) { create(:user, :admin, organization:) } it { is_expected.to be_truthy } @@ -32,7 +32,7 @@ module Decidim::ExtraUserFields::Admin end context "when user is not admin" do - let(:user) { create :user, organization: organization } + let(:user) { create(:user, organization:) } context "and tries to read extra user fields" do let(:action) do diff --git a/spec/serializers/user_export_serializer_spec.rb b/spec/serializers/user_export_serializer_spec.rb index e60c024..bfd279a 100644 --- a/spec/serializers/user_export_serializer_spec.rb +++ b/spec/serializers/user_export_serializer_spec.rb @@ -9,12 +9,12 @@ # rubocop:disable Style/TrailingCommaInHashLiteral let(:registration_metadata) do { - gender: gender, - postal_code: postal_code, - date_of_birth: date_of_birth, - country: country, - phone_number: phone_number, - location: location, + gender:, + postal_code:, + date_of_birth:, + country:, + phone_number:, + location:, # Block ExtraUserFields ExtraUserFields # EndBlock diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index 44ca322..b602c27 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -5,12 +5,12 @@ describe "Account", type: :system do shared_examples_for "does not display extra user field" do |field, label| it "does not display field '#{field}'" do - expect(page).not_to have_content(label) + expect(page).to have_no_content(label) end end - let(:organization) { create(:organization, extra_user_fields: extra_user_fields) } - let(:user) { create(:user, :confirmed, organization: organization, password: password, password_confirmation: password) } + let(:organization) { create(:organization, extra_user_fields:) } + let(:user) { create(:user, :confirmed, organization:, password:, password_confirmation: password) } let(:password) { "dqCFgjfDbC7dPbrv" } # rubocop:disable Style/TrailingCommaInHashLiteral let(:extra_user_fields) do diff --git a/spec/system/admin_manages_officializations_spec.rb b/spec/system/admin_manages_officializations_spec.rb index fefb60d..77b4820 100644 --- a/spec/system/admin_manages_officializations_spec.rb +++ b/spec/system/admin_manages_officializations_spec.rb @@ -10,7 +10,7 @@ let(:organization) { create(:organization) } - let!(:admin) { create(:user, :admin, :confirmed, organization: organization) } + let!(:admin) { create(:user, :admin, :confirmed, organization:) } before do switch_to_host(organization.host) diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index f9f8193..e323210 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -4,7 +4,7 @@ describe "Admin manages organization extra user fields", type: :system do let(:organization) { create(:organization) } - let(:user) { create(:user, :admin, :confirmed, organization: organization) } + let(:user) { create(:user, :admin, :confirmed, organization:) } before do switch_to_host(organization.host) diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index c267288..dd1122f 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -33,8 +33,8 @@ def fill_extra_user_fields end end - let(:organization) { create(:organization, extra_user_fields: extra_user_fields) } - let!(:terms_and_conditions_page) { Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization: organization) } + let(:organization) { create(:organization, extra_user_fields:) } + let!(:terms_and_conditions_page) { Decidim::StaticPage.find_by(slug: "terms-and-conditions", organization:) } # rubocop:disable Style/TrailingCommaInHashLiteral let(:extra_user_fields) do { @@ -123,12 +123,12 @@ def fill_extra_user_fields let(:organization) { create(:organization, :extra_user_fields_disabled) } it "does not contain extra user fields" do - expect(page).not_to have_content("Date of birth") - expect(page).not_to have_content("Gender") - expect(page).not_to have_content("Country") - expect(page).not_to have_content("Postal code") - expect(page).not_to have_content("Phone Number") - expect(page).not_to have_content("Location") + expect(page).to have_no_content("Date of birth") + expect(page).to have_no_content("Gender") + expect(page).to have_no_content("Country") + expect(page).to have_no_content("Postal code") + expect(page).to have_no_content("Phone Number") + expect(page).to have_no_content("Location") # Block ExtraUserFields DoesNotContainFieldSpec # EndBlock From b530742c7ae41007bd9426987746f5ea54bd1829 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 21:06:49 +0200 Subject: [PATCH 17/42] Normalize locales --- config/locales/en.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/config/locales/en.yml b/config/locales/en.yml index 7526288..cd2a772 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -28,31 +28,36 @@ en: extra_user_fields: fields: country: - description: This field is a list of countries. If checked, user will have to choose a country + description: This field is a list of countries. If checked, user will + have to choose a country label: Enable country field date_of_birth: - description: This field is a Date field. If checked, user will have to register a birth date by using a Date picker + description: This field is a Date field. If checked, user will have + to register a birth date by using a Date picker label: Enable date of birth field gender: - description: This field is a list of genders. If checked, user will have to choose a gender + description: This field is a list of genders. If checked, user will + have to choose a gender label: Enable gender field location: - description: This field is a String field. If checked, user will have to fill in a location + description: This field is a String field. If checked, user will have + to fill in a location label: Enable location field phone_number: - description: This field is a telephone field. If checked, user will have to fill in a phone number + description: This field is a telephone field. If checked, user will + have to fill in a phone number label: Enable phone number field pattern: Phone numbers validation pattern (regex) placeholder: Phone number placeholder postal_code: - description: This field is a String field. If checked, user will have to fill in a postal code + description: This field is a String field. If checked, user will have + to fill in a postal code label: Enable postal code field form: callout: help: Enable custom extra user fields functionality to be able to manage extra fields in your signup form. Even if option is checked, signup - form will be updated only if there is at least one extra field - enabled + form will be updated only if there is at least one extra field enabled extra_user_fields: extra_user_fields_enabled: Enable extra user fields section: Available extra fields for signup form From 157bef3acfea54f445c488d148d8b367859590ed Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 21:28:19 +0200 Subject: [PATCH 18/42] Remove references to password confirmation in user creation --- .../create_registrations_commands_overrides.rb | 1 - spec/commands/decidim/create_registration_spec.rb | 3 --- spec/forms/decidim/registration_form_spec.rb | 14 -------------- 3 files changed, 18 deletions(-) diff --git a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb index a6d43d9..6a9d4d5 100644 --- a/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb +++ b/app/commands/concerns/decidim/extra_user_fields/create_registrations_commands_overrides.rb @@ -16,7 +16,6 @@ def create_user name: form.name, nickname: form.nickname, password: form.password, - password_confirmation: form.password_confirmation, password_updated_at: Time.current, organization: form.current_organization, tos_agreement: form.tos_agreement, diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index 296e71f..c84e5b2 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -12,7 +12,6 @@ module Comments let(:nickname) { "nickname" } let(:email) { "user@example.org" } let(:password) { "Y1fERVzL2F" } - let(:password_confirmation) { password } let(:tos_agreement) { "1" } let(:newsletter) { "1" } let(:current_locale) { "es" } @@ -40,7 +39,6 @@ module Comments "nickname" => nickname, "email" => email, "password" => password, - "password_confirmation" => password_confirmation, "tos_agreement" => tos_agreement, "newsletter_at" => newsletter, "country" => country, @@ -108,7 +106,6 @@ module Comments nickname: form.nickname, email: form.email, password: form.password, - password_confirmation: form.password_confirmation, password_updated_at: an_instance_of(ActiveSupport::TimeWithZone), tos_agreement: form.tos_agreement, newsletter_notifications_at: form.newsletter_at, diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index d10cb3a..533f847 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -17,7 +17,6 @@ module Decidim let(:nickname) { "justme" } let(:email) { "user@example.org" } let(:password) { "S4CGQ9AM4ttJdPKS" } - let(:password_confirmation) { password } let(:tos_agreement) { "1" } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } @@ -32,7 +31,6 @@ module Decidim nickname:, email:, password:, - password_confirmation:, tos_agreement:, country:, postal_code:, @@ -147,18 +145,6 @@ module Decidim it { is_expected.to be_invalid } end - context "when the password confirmation is not present" do - let(:password_confirmation) { nil } - - it { is_expected.to be_invalid } - end - - context "when the password confirmation is different from password" do - let(:password_confirmation) { "invalid" } - - it { is_expected.to be_invalid } - end - context "when the tos_agreement is not accepted" do let(:tos_agreement) { "0" } From ba49dd11fc13f844dfd135a6dfd8cc68558a3c47 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 21:28:56 +0200 Subject: [PATCH 19/42] Fix rubocop offenses --- spec/forms/decidim/account_form_spec.rb | 2 +- spec/forms/decidim/registration_form_spec.rb | 30 +++++++++---------- spec/system/account_spec.rb | 2 +- .../admin_manages_officializations_spec.rb | 6 ++-- ...ges_organization_extra_user_fields_spec.rb | 2 +- spec/system/registration_spec.rb | 2 +- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 50bfdc5..17de1d0 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -163,7 +163,7 @@ module Decidim context "when the password is weak" do let(:password) { "aaaabbbbcccc" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end end diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index 533f847..cc35039 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -54,44 +54,44 @@ module Decidim context "when the email is a disposable account" do let(:email) { "user@mailbox92.biz" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the name is not present" do let(:name) { nil } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the nickname is not present" do let(:nickname) { nil } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the email is not present" do let(:email) { nil } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the email already exists" do context "and a user has the email" do let!(:user) { create(:user, organization:, email:) } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } context "and is pending to accept the invitation" do let!(:user) { create(:user, organization:, email:, invitation_token: "foo", invitation_accepted_at: nil) } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end end context "and a user_group has the email" do let!(:user_group) { create(:user_group, organization:, email:) } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end end @@ -99,7 +99,7 @@ module Decidim context "and a user has the nickname" do let!(:user) { create(:user, organization:, nickname: nickname.upcase) } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } context "and is pending to accept the invitation" do let!(:user) { create(:user, organization:, nickname:, invitation_token: "foo", invitation_accepted_at: nil) } @@ -111,44 +111,44 @@ module Decidim context "and a user_group has the nickname" do let!(:user_group) { create(:user_group, organization:, nickname:) } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end end context "when the nickname is too long" do let(:nickname) { "verylongnicknamethatcreatesanerror" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the name is an email" do let(:name) { "test@example.org" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the nickname has spaces" do let(:nickname) { "test example" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the password is not present" do let(:password) { nil } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the password is weak" do let(:password) { "aaaabbbbcccc" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end context "when the tos_agreement is not accepted" do let(:tos_agreement) { "0" } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end end end diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index b602c27..d4693b0 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe "Account", type: :system do +describe "Account" do shared_examples_for "does not display extra user field" do |field, label| it "does not display field '#{field}'" do expect(page).to have_no_content(label) diff --git a/spec/system/admin_manages_officializations_spec.rb b/spec/system/admin_manages_officializations_spec.rb index 77b4820..e3438aa 100644 --- a/spec/system/admin_manages_officializations_spec.rb +++ b/spec/system/admin_manages_officializations_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe "Admin manages officializations", type: :system do +describe "Admin manages officializations" do include_context "with filterable context" let(:model_name) { Decidim::User.model_name } @@ -16,11 +16,11 @@ switch_to_host(organization.host) login_as admin, scope: :user visit decidim_admin.root_path - click_link "Participants" + click_on "Participants" end it "includes export dropdown button" do - click_link "Participants" + click_on "Participants" expect(page).to have_content("Export") end diff --git a/spec/system/admin_manages_organization_extra_user_fields_spec.rb b/spec/system/admin_manages_organization_extra_user_fields_spec.rb index e323210..6157a12 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" -describe "Admin manages organization extra user fields", type: :system do +describe "Admin manages organization extra user fields" do let(:organization) { create(:organization) } let(:user) { create(:user, :admin, :confirmed, organization:) } diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index dd1122f..3ea3b6a 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -24,7 +24,7 @@ def fill_extra_user_fields # EndBlock end -describe "Extra user fields", type: :system do +describe "Extra user fields" do shared_examples_for "mandatory extra user fields" do |field| it "displays #{field} as mandatory" do within "label[for='registration_user_#{field}']" do From c6b301a71e34027efaccbb002e3e553df2d54168 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 16 Apr 2024 21:29:28 +0200 Subject: [PATCH 20/42] Rename file --- .../extra_user_fields}/user_export_serializer_spec.rb | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spec/serializers/{ => decidim/extra_user_fields}/user_export_serializer_spec.rb (100%) diff --git a/spec/serializers/user_export_serializer_spec.rb b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb similarity index 100% rename from spec/serializers/user_export_serializer_spec.rb rename to spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb From 77f54b3ef7b5a49a40c0fdb7bfd0dca6689ec861 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 09:23:33 +0200 Subject: [PATCH 21/42] Change factory to avoid rubocop offense --- lib/decidim/extra_user_fields/test/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/decidim/extra_user_fields/test/factories.rb b/lib/decidim/extra_user_fields/test/factories.rb index 9657070..5fae274 100644 --- a/lib/decidim/extra_user_fields/test/factories.rb +++ b/lib/decidim/extra_user_fields/test/factories.rb @@ -6,7 +6,7 @@ factory :extra_user_fields_component, parent: :component do name { Decidim::Components::Namer.new(participatory_space.organization.available_locales, :extra_user_fields).i18n_name } manifest_name { :extra_user_fields } - participatory_space { create(:participatory_process, :with_steps) } + participatory_space factory: [:participatory_process, :with_steps] end # Add engine factories here From 55dbbcd4872bc7f015b3c0c8a44cdcd14067d411 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 09:33:27 +0200 Subject: [PATCH 22/42] Include pattern and placeholder settings in update_extra_user_fields admin command specs --- .../admin/update_extra_user_fields_spec.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb index 5766b4e..1acb5ba 100644 --- a/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb +++ b/spec/commands/decidim/extra_user_fields/admin/update_extra_user_fields_spec.rb @@ -15,6 +15,8 @@ module Admin let(:gender) { true } let(:date_of_birth) { true } let(:phone_number) { true } + let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } + let(:phone_number_placeholder) { "+34999888777" } let(:location) { true } # Block ExtraUserFields RspecVar @@ -29,6 +31,8 @@ module Admin "gender" => gender, "date_of_birth" => date_of_birth, "phone_number" => phone_number, + "phone_number_pattern" => phone_number_pattern, + "phone_number_placeholder" => phone_number_placeholder, "location" => location, # Block ExtraUserFields ExtraUserFields @@ -80,7 +84,7 @@ module Admin expect(extra_user_fields).to include("date_of_birth" => { "enabled" => true }) expect(extra_user_fields).to include("gender" => { "enabled" => true }) expect(extra_user_fields).to include("country" => { "enabled" => true }) - expect(extra_user_fields).to include("phone_number" => { "enabled" => true }) + expect(extra_user_fields).to include("phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => phone_number_placeholder }) expect(extra_user_fields).to include("location" => { "enabled" => true }) # Block ExtraUserFields InclusionSpec From d65dc2b9fd332bd7d9ea4754e4b498bfd913c30c Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 10:00:39 +0200 Subject: [PATCH 23/42] Adapt test to 0.28 release --- spec/forms/decidim/account_form_spec.rb | 50 +++++++++++++++++++++---- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 17de1d0..06973c8 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -10,7 +10,7 @@ module Decidim email:, nickname:, password:, - password_confirmation:, + old_password:, avatar:, remove_avatar:, personal_url:, @@ -35,7 +35,6 @@ module Decidim let(:email) { "depths@ofthe.bar" } let(:nickname) { "foo_bar" } let(:password) { "Rf9kWTqQfyqkwseH" } - let(:password_confirmation) { password } let(:avatar) { upload_test_file(Decidim::Dev.test_file("avatar.jpg", "image/jpeg")) } let(:remove_avatar) { false } let(:personal_url) { "http://example.org" } @@ -88,7 +87,7 @@ module Decidim end end - context "when it's already in use in the same organization" do + context "when it is already in use in the same organization" do context "and belongs to a user" do let!(:existing_user) { create(:user, email:, organization:) } @@ -106,7 +105,7 @@ module Decidim end end - context "when it's already in use in another organization" do + context "when it is already in use in another organization" do let!(:existing_user) { create(:user, email:) } it "is valid" do @@ -124,7 +123,7 @@ module Decidim end end - context "when it's already in use in the same organization" do + context "when it is already in use in the same organization" do context "and belongs to a user" do let!(:existing_user) { create(:user, nickname:, organization:) } @@ -142,7 +141,7 @@ module Decidim end end - context "when it's already in use in another organization" do + context "when it is already in use in another organization" do let!(:existing_user) { create(:user, nickname:) } it "is valid" do @@ -167,8 +166,43 @@ module Decidim end end + describe "validate_old_password" do + context "when email changed" do + let(:password) { "" } + let(:email) { "foo@example.org" } + + context "with correct old_password" do + it "is valid" do + expect(subject).to be_valid + end + end + + context "with incorrect old_password" do + let(:old_password) { "foobar1234567890" } + + it { is_expected.not_to be_valid } + end + end + + context "when password present" do + let(:email) { user.email } + + context "with correct old_password" do + it "is valid" do + expect(subject).to be_valid + end + end + + context "with incorrect old_password" do + let(:old_password) { "foobar1234567890" } + + it { is_expected.not_to be_valid } + end + end + end + describe "personal_url" do - context "when it doesn't start with http" do + context "when it does not start with http" do let(:personal_url) { "example.org" } it "adds it" do @@ -176,7 +210,7 @@ module Decidim end end - context "when it's not a valid URL" do + context "when it is not a valid URL" do let(:personal_url) { "foobar, aa" } it "is invalid" do From 9e78edbdcae005d62158637c32a8c7019464b4b9 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 10:02:02 +0200 Subject: [PATCH 24/42] Add test to check phone number pattern validation in account form --- spec/forms/decidim/account_form_spec.rb | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 06973c8..73f50e0 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -28,8 +28,17 @@ module Decidim ) end - let(:user) { create(:user) } - let(:organization) { user.organization } + let(:user) { create(:user, password: user_password, organization:) } + let(:organization) { create(:organization, extra_user_fields:) } + let(:extra_user_fields) do + { + "enabled" => true, + "phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil } + } + end + let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } + let(:user_password) { "decidim1234567890" } + let(:old_password) { user_password } let(:name) { "Lord of the Foo" } let(:email) { "depths@ofthe.bar" } @@ -60,6 +69,14 @@ module Decidim end end + context "with invalid phone number format" do + let(:phone_number_pattern) { "^(\\+34)?[0-1 ]{9,12}$" } + + it "is invalid" do + expect(subject).not_to be_valid + end + end + describe "name" do context "with an empty name" do let(:name) { "" } From dbb9b4fd878da534fc5f031f63e25ae5c1b70334 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 10:57:51 +0200 Subject: [PATCH 25/42] Extend extra_user_fields configuration to all fields in account_form_spec --- spec/forms/decidim/account_form_spec.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 73f50e0..4b5f49e 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -33,7 +33,12 @@ module Decidim let(:extra_user_fields) do { "enabled" => true, - "phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil } + "country" => { "enabled" => true }, + "postal_code" => { "enabled" => true }, + "date_of_birth" => { "enabled" => true }, + "gender" => { "enabled" => true }, + "phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil }, + "location" => { "enabled" => true } } end let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } From 7f3ebd7af76b0627301d229f72b18394a9f26ae2 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 10:58:32 +0200 Subject: [PATCH 26/42] Replace gender option with valid value in tests --- spec/commands/decidim/create_omniauth_registration_spec.rb | 2 +- spec/commands/decidim/create_registration_spec.rb | 2 +- spec/forms/decidim/account_form_spec.rb | 2 +- spec/forms/decidim/omniauth_registration_form_spec.rb | 2 +- spec/forms/decidim/registration_form_spec.rb | 2 +- .../decidim/extra_user_fields/user_export_serializer_spec.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb index b26b214..3a44850 100644 --- a/spec/commands/decidim/create_omniauth_registration_spec.rb +++ b/spec/commands/decidim/create_omniauth_registration_spec.rb @@ -14,7 +14,7 @@ module Comments let(:verified_email) { email } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } - let(:gender) { "Other" } + let(:gender) { "other" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } diff --git a/spec/commands/decidim/create_registration_spec.rb b/spec/commands/decidim/create_registration_spec.rb index c84e5b2..6760b25 100644 --- a/spec/commands/decidim/create_registration_spec.rb +++ b/spec/commands/decidim/create_registration_spec.rb @@ -17,7 +17,7 @@ module Comments let(:current_locale) { "es" } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } - let(:gender) { "Other" } + let(:gender) { "other" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 4b5f49e..1b367c0 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -55,7 +55,7 @@ module Decidim let(:about) { "This is a description about me" } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } - let(:gender) { "Other" } + let(:gender) { "other" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } diff --git a/spec/forms/decidim/omniauth_registration_form_spec.rb b/spec/forms/decidim/omniauth_registration_form_spec.rb index 8ead111..3b25b82 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -20,7 +20,7 @@ module Decidim let(:oauth_signature) { OmniauthRegistrationForm.create_signature(provider, uid) } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } - let(:gender) { "Other" } + let(:gender) { "other" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index cc35039..5ce2173 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -20,7 +20,7 @@ module Decidim let(:tos_agreement) { "1" } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } - let(:gender) { "Other" } + let(:gender) { "other" } let(:location) { "Paris" } let(:phone_number) { "0123456789" } let(:postal_code) { "75001" } diff --git a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb index bfd279a..9eb39bd 100644 --- a/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb +++ b/spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb @@ -22,7 +22,7 @@ end # rubocop:enable Style/TrailingCommaInHashLiteral - let(:gender) { "Other" } + let(:gender) { "other" } let(:postal_code) { "00000" } let(:date_of_birth) { "01/01/2000" } let(:country) { "Argentina" } From 00b6f90968656ad21097768416cebf3f5a8e45b2 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 11:23:18 +0200 Subject: [PATCH 27/42] Adapt test to 0.28 release --- spec/forms/decidim/registration_form_spec.rb | 108 ++++++++++++------- 1 file changed, 67 insertions(+), 41 deletions(-) diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index 5ce2173..7c66fbe 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -4,7 +4,9 @@ module Decidim describe RegistrationForm do - subject do + subject { form } + + let(:form) do described_class.from_params( attributes ).with_context( @@ -14,10 +16,10 @@ module Decidim let(:organization) { create(:organization) } let(:name) { "User" } - let(:nickname) { "justme" } let(:email) { "user@example.org" } let(:password) { "S4CGQ9AM4ttJdPKS" } let(:tos_agreement) { "1" } + let(:newsletter) { "1" } let(:country) { "Argentina" } let(:date_of_birth) { "01/01/2000" } let(:gender) { "other" } @@ -28,10 +30,10 @@ module Decidim let(:attributes) do { name:, - nickname:, email:, password:, tos_agreement:, + newsletter:, country:, postal_code:, date_of_birth:, @@ -63,12 +65,6 @@ module Decidim it { is_expected.not_to be_valid } end - context "when the nickname is not present" do - let(:nickname) { nil } - - it { is_expected.not_to be_valid } - end - context "when the email is not present" do let(:email) { nil } @@ -95,44 +91,12 @@ module Decidim end end - context "when the nickname already exists" do - context "and a user has the nickname" do - let!(:user) { create(:user, organization:, nickname: nickname.upcase) } - - it { is_expected.not_to be_valid } - - context "and is pending to accept the invitation" do - let!(:user) { create(:user, organization:, nickname:, invitation_token: "foo", invitation_accepted_at: nil) } - - it { is_expected.to be_valid } - end - end - - context "and a user_group has the nickname" do - let!(:user_group) { create(:user_group, organization:, nickname:) } - - it { is_expected.not_to be_valid } - end - end - - context "when the nickname is too long" do - let(:nickname) { "verylongnicknamethatcreatesanerror" } - - it { is_expected.not_to be_valid } - end - context "when the name is an email" do let(:name) { "test@example.org" } it { is_expected.not_to be_valid } end - context "when the nickname has spaces" do - let(:nickname) { "test example" } - - it { is_expected.not_to be_valid } - end - context "when the password is not present" do let(:password) { nil } @@ -150,5 +114,67 @@ module Decidim it { is_expected.not_to be_valid } end + + describe "#newsletter_at" do + subject { form.newsletter_at } + + let(:current_time) { Time.current } + + it { is_expected.to be_between(current_time - 1.minute, current_time + 1.minute) } + + context "when newsletter was not ordered" do + let(:newsletter) { "0" } + + it { is_expected.to be_nil } + end + end + + describe "nickname" do + let(:name) { "justme" } + + context "when the nickname already exists" do + context "and a user has the nickname" do + let!(:another_user) { create(:user, organization:, nickname: name.upcase) } + + it { is_expected.to be_valid } + + it "adds a suffix in the nickname" do + expect(subject.nickname).to eq("justme_2") + end + + context "and is pending to accept the invitation" do + let!(:another_user) { create(:user, organization:, nickname: name, invitation_token: "foo", invitation_accepted_at: nil) } + + it { is_expected.to be_valid } + end + end + + context "and a user_group has the nickname" do + let!(:user_group) { create(:user_group, organization:, nickname: name) } + + it { is_expected.to be_valid } + end + end + + context "when the nickname is too long" do + let(:name) { "verylongnicknamethatcreatesanerror" } + + it { is_expected.to be_valid } + + it "truncates the nickname" do + expect(subject.nickname).to eq("verylongnicknamethat") + end + end + + context "when the name has spaces" do + let(:name) { "test example" } + + it { is_expected.to be_valid } + + it "replaces the space in the nickname" do + expect(subject.nickname).to eq("test_example") + end + end + end end end From fe9a36863e12caebad364f68b419178c0c47f049 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 11:25:10 +0200 Subject: [PATCH 28/42] Include example to test phone number pattern validation --- spec/forms/decidim/registration_form_spec.rb | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/spec/forms/decidim/registration_form_spec.rb b/spec/forms/decidim/registration_form_spec.rb index 7c66fbe..7d46383 100644 --- a/spec/forms/decidim/registration_form_spec.rb +++ b/spec/forms/decidim/registration_form_spec.rb @@ -14,7 +14,19 @@ module Decidim ) end - let(:organization) { create(:organization) } + let(:organization) { create(:organization, extra_user_fields:) } + let(:extra_user_fields) do + { + "enabled" => true, + "country" => { "enabled" => true }, + "postal_code" => { "enabled" => true }, + "date_of_birth" => { "enabled" => true }, + "gender" => { "enabled" => true }, + "phone_number" => { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil }, + "location" => { "enabled" => true } + } + end + let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } let(:name) { "User" } let(:email) { "user@example.org" } let(:password) { "S4CGQ9AM4ttJdPKS" } @@ -65,6 +77,14 @@ module Decidim it { is_expected.not_to be_valid } end + context "with invalid phone number format" do + let(:phone_number_pattern) { "^(\\+34)?[0-1 ]{9,12}$" } + + it "is invalid" do + expect(subject).not_to be_valid + end + end + context "when the email is not present" do let(:email) { nil } From a0587e8ec7028ae10045bd61b2c774ee8d18d694 Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Wed, 17 Apr 2024 12:58:16 +0200 Subject: [PATCH 29/42] Redesign export participants dropdown --- .../index/_export_users_dropdown.html.erb.deface | 6 ++---- .../admin/export_users/_dropdown.html.erb | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/overrides/decidim/admin/officializations/index/_export_users_dropdown.html.erb.deface b/app/overrides/decidim/admin/officializations/index/_export_users_dropdown.html.erb.deface index f1fadc6..fbc8047 100644 --- a/app/overrides/decidim/admin/officializations/index/_export_users_dropdown.html.erb.deface +++ b/app/overrides/decidim/admin/officializations/index/_export_users_dropdown.html.erb.deface @@ -1,5 +1,3 @@ - + -
- <%= render partial: "decidim/extra_user_fields/admin/export_users/dropdown" %> -
+<%= render partial: "decidim/extra_user_fields/admin/export_users/dropdown" %> diff --git a/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb b/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb index 6472ef0..032a1fb 100644 --- a/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb +++ b/app/views/decidim/extra_user_fields/admin/export_users/_dropdown.html.erb @@ -1,4 +1,7 @@ -<%= t "actions.export", scope: "decidim.admin" %> - -
+
>
> <%= form.text_field :phone_number_pattern, help_text: t(".pattern_help_html"), label: t(".pattern"), placeholder: "^(\\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$", data: { type: :phone_number } %> - <%= form.text_field :phone_number_placeholder, label: t(".placeholder"), placeholder: "+34987654321" %> + <%= form.translated :text_field, :phone_number_placeholder, label: t(".placeholder"), placeholder: "+34987654321" %>
From b669e62862f875d5203b02aa085d78168ca8701e Mon Sep 17 00:00:00 2001 From: Eduardo Martinez Echevarria Date: Tue, 23 Apr 2024 20:22:53 +0200 Subject: [PATCH 42/42] Update help text --- config/locales/ca.yml | 3 ++- config/locales/en.yml | 3 ++- config/locales/es.yml | 3 ++- config/locales/fr.yml | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 5b46d67..46cb65b 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -51,7 +51,8 @@ ca: pattern: Patró de validació de números de telèfon (regexp) pattern_help_html: Copia aquesta expressió regular ^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$ per validar aquest format de - telèfono +34999111222 + telèfono +34999111222. Podeu revisar i comprovar l'expressió regular + aquí. placeholder: Placeholder pel número de telèfon postal_code: description: Aquest camp és un camp de text. Si está activat, l'usuari diff --git a/config/locales/en.yml b/config/locales/en.yml index 187b595..d592c05 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -50,7 +50,8 @@ en: pattern: Phone numbers validation pattern (regexp) pattern_help_html: Copy this regular expression ^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$ to validate this phone format - +34999111222 + +34999111222. You can review and check the regular expression here. placeholder: Phone number placeholder postal_code: description: This field is a String field. If checked, user will have diff --git a/config/locales/es.yml b/config/locales/es.yml index 98c351a..889530b 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -50,7 +50,8 @@ es: pattern: Patrón de validación de números de teléfono (regexp) pattern_help_html: Copia esta expresión regular ^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$ para validar este formato de - teléfono +34999111222 + teléfono +34999111222. Puedes revisar y editar la expresión regular + aquí. placeholder: Placeholder para el número de teléfono postal_code: description: este campo es un campo de texto. Si está marcado, el usuario diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 44a8cb9..a82b997 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -50,7 +50,8 @@ fr: pattern: Motif de validation des numéros de téléphone (regex) pattern_help_html: Copiez cette expression régulière ^(\+34|0034|34)?[ -]*[6-9][ -]*([0-9][ -]*){8}$ pour valider ce format de téléphone - +34999111222 + +34999111222. Vous pouvez consulter et vérifier l'expression régulière + ici. placeholder: Placeholder pour le numéro de téléphone postal_code: description: Ce champ est un champ code postal. L'utilisateur pourra