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/.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: 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 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..1569874 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,48 +1,48 @@ PATH remote: . specs: - decidim-extra_user_fields (0.27.2) + decidim-extra_user_fields (0.28.0) 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 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..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,14 +16,13 @@ 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, 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 6e1a057..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 @@ -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/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/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 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..185d6f0 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 + translatable_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/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/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/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" %> 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..4d82d2a 100644 --- a/app/views/decidim/extra_user_fields/_profile_form.html.erb +++ b/app/views/decidim/extra_user_fields/_profile_form.html.erb @@ -1,23 +1,27 @@ -<% if current_organization.activated_extra_field?(:date_of_birth) %> - <%= f.date_field :date_of_birth %> -<% end %> +<% if current_organization.extra_user_fields_enabled? %> + <% 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?(: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?(:country) %> + <%= f.label :country do %> + <%= f.custom_country_select :country %> + <% end %> + <% end %> -<% if current_organization.activated_extra_field?(:postal_code) %> - <%= f.text_field :postal_code %> -<% 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?(:phone_number) %> + <%= f.telephone_field :phone_number, placeholder: translated_attribute(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) %> - <%= f.text_field :location %> + <% if current_organization.activated_extra_field?(:location) %> + <%= f.text_field :location %> + <% 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 0bfa9d5..1c1d85e 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,36 @@ <% if current_organization.extra_user_fields_enabled? %> -<%== t(".callout.help") %>
-<%= t(".description") %>
- <%= form.check_box :country, label: t(".label") %> + <%= form.check_box :country, label: t(".label"), help_text: t(".description") %><%= t(".description") %>
- <%= form.check_box :date_of_birth, label: t(".label") %> + <%= form.check_box :date_of_birth, label: t(".label"), help_text: t(".description") %><%= t(".description") %>
- <%= form.check_box :gender, label: t(".label") %> + <%= form.check_box :gender, label: t(".label"), help_text: t(".description") %><%= t(".description") %>
- <%= form.check_box :location, label: t(".label") %> + <%= form.check_box :location, label: t(".label"), help_text: t(".description") %><%= t(".description") %>
- <%= form.check_box :phone_number, label: t(".label") %> + <%= form.check_box :phone_number, label: t(".label"), help_text: t(".description"), data: { toggle: "phone_fields" } %> +<%= t(".description") %>
- <%= form.check_box :postal_code, label: t(".label") %> + <%= form.check_box :postal_code, label: t(".label"), help_text: t(".description") %>^(\+34|0034|34)?[
+ -]*[6-9][ -]*([0-9][ -]*){8}$
per validar aquest format de
+ 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
+ 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 69912b0..d592c05 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -28,35 +28,40 @@ 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 String 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 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. You can review and check the regular expression here.
+ 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..889530b 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,60 @@ 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 (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. 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
+ 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..a82b997 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -47,6 +47,12 @@ 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)
+ 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. 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
choisir un code postal.
diff --git a/lib/decidim/extra_user_fields/admin_engine.rb b/lib/decidim/extra_user_fields/admin_engine.rb
index 60d8516..0c058a3 100644
--- a/lib/decidim/extra_user_fields/admin_engine.rb
+++ b/lib/decidim/extra_user_fields/admin_engine.rb
@@ -41,7 +41,8 @@ class AdminEngine < ::Rails::Engine
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: "list-check"
end
end
diff --git a/lib/decidim/extra_user_fields/form_builder_methods.rb b/lib/decidim/extra_user_fields/form_builder_methods.rb
index 059eaf9..a1345a3 100644
--- a/lib/decidim/extra_user_fields/form_builder_methods.rb
+++ b/lib/decidim/extra_user_fields/form_builder_methods.rb
@@ -9,7 +9,7 @@ def custom_country_select(name, options = {})
label_text = label_for(name) if label_text.blank?
template = ""
- template += label(name, label_text + required_for_attribute(name)) if options.fetch(:label, true)
+ template += (label_text + required_for_attribute(name)) if options.fetch(:label, true)
template += country_select(name)
template.html_safe
end
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
diff --git a/lib/decidim/extra_user_fields/version.rb b/lib/decidim/extra_user_fields/version.rb
index e6bada4..f28f7fe 100644
--- a/lib/decidim/extra_user_fields/version.rb
+++ b/lib/decidim/extra_user_fields/version.rb
@@ -4,11 +4,11 @@ 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
- [">= 0.27.0", "< 0.28"].freeze
+ [">= 0.28"].freeze
end
end
end
diff --git a/spec/commands/decidim/create_omniauth_registration_spec.rb b/spec/commands/decidim/create_omniauth_registration_spec.rb
index 201c670..3a44850 100644
--- a/spec/commands/decidim/create_omniauth_registration_spec.rb
+++ b/spec/commands/decidim/create_omniauth_registration_spec.rb
@@ -14,18 +14,18 @@ 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" }
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..6760b25 100644
--- a/spec/commands/decidim/create_registration_spec.rb
+++ b/spec/commands/decidim/create_registration_spec.rb
@@ -12,24 +12,23 @@ 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" }
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" }
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
@@ -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,
@@ -55,7 +53,7 @@ module Comments
let(:form) do
RegistrationForm.from_params(
form_params,
- current_locale: current_locale
+ current_locale:
).with_context(
current_organization: organization
)
@@ -78,7 +76,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!
@@ -108,20 +106,19 @@ 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,
- 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..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
@@ -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 }
@@ -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
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 diff --git a/spec/forms/decidim/account_form_spec.rb b/spec/forms/decidim/account_form_spec.rb index 542a185..1b367c0 100644 --- a/spec/forms/decidim/account_form_spec.rb +++ b/spec/forms/decidim/account_form_spec.rb @@ -6,43 +6,56 @@ 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:, + old_password:, + 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 ) 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, + "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(:user_password) { "decidim1234567890" } + let(:old_password) { user_password } let(:name) { "Lord of the Foo" } 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" } 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" } @@ -61,6 +74,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) { "" } @@ -88,9 +109,9 @@ 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: email, organization: organization) } + let!(:existing_user) { create(:user, email:, organization:) } it "is invalid" do expect(subject).not_to be_valid @@ -98,7 +119,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 @@ -106,8 +127,8 @@ module Decidim end end - context "when it's already in use in another organization" do - let!(:existing_user) { create(:user, email: email) } + context "when it is already in use in another organization" do + let!(:existing_user) { create(:user, email:) } it "is valid" do expect(subject).to be_valid @@ -124,9 +145,9 @@ 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: nickname, organization: organization) } + let!(:existing_user) { create(:user, nickname:, organization:) } it "is invalid" do expect(subject).not_to be_valid @@ -134,7 +155,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 @@ -142,8 +163,8 @@ module Decidim end end - context "when it's already in use in another organization" do - let!(:existing_user) { create(:user, nickname: nickname) } + context "when it is already in use in another organization" do + let!(:existing_user) { create(:user, nickname:) } it "is valid" do expect(subject).to be_valid @@ -163,12 +184,47 @@ 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 + + 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 +232,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 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..3b25b82 100644 --- a/spec/forms/decidim/omniauth_registration_form_spec.rb +++ b/spec/forms/decidim/omniauth_registration_form_spec.rb @@ -20,26 +20,26 @@ 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" } 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..7d46383 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( @@ -12,34 +14,44 @@ 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(:nickname) { "justme" } let(:email) { "user@example.org" } let(:password) { "S4CGQ9AM4ttJdPKS" } - let(:password_confirmation) { password } let(:tos_agreement) { "1" } + let(:newsletter) { "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" } 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:, + email:, + password:, + tos_agreement:, + newsletter:, + country:, + postal_code:, + date_of_birth:, + gender:, + phone_number:, + location: } end @@ -56,113 +68,133 @@ 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 } + context "with invalid phone number format" do + let(:phone_number_pattern) { "^(\\+34)?[0-1 ]{9,12}$" } - it { is_expected.to be_invalid } + it "is invalid" do + expect(subject).not_to be_valid + end 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: organization, email: email) } + 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: 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 } + 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: organization, email: email) } + let!(:user_group) { create(:user_group, organization:, email:) } - it { is_expected.to be_invalid } + it { is_expected.not_to be_valid } end end - context "when the nickname already exists" do - context "and a user has the nickname" do - let!(:user) { create(:user, organization: organization, nickname: nickname.upcase) } + 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 "and is pending to accept the invitation" do - let!(:user) { create(:user, organization: organization, nickname: nickname, invitation_token: "foo", invitation_accepted_at: nil) } + context "when the password is not present" do + let(:password) { nil } - it { is_expected.to be_valid } - end - end + it { is_expected.not_to be_valid } + end - context "and a user_group has the nickname" do - let!(:user_group) { create(:user_group, organization: organization, nickname: nickname) } + context "when the password is weak" do + let(:password) { "aaaabbbbcccc" } - it { is_expected.to be_invalid } - end + it { is_expected.not_to be_valid } end - context "when the nickname is too long" do - let(:nickname) { "verylongnicknamethatcreatesanerror" } + 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 - context "when the name is an email" do - let(:name) { "test@example.org" } + describe "#newsletter_at" do + subject { form.newsletter_at } - it { is_expected.to be_invalid } - end + let(:current_time) { Time.current } + + it { is_expected.to be_between(current_time - 1.minute, current_time + 1.minute) } - context "when the nickname has spaces" do - let(:nickname) { "test example" } + context "when newsletter was not ordered" do + let(:newsletter) { "0" } - it { is_expected.to be_invalid } + it { is_expected.to be_nil } + end end - context "when the password is not present" do - let(:password) { nil } + describe "nickname" do + let(:name) { "justme" } - it { is_expected.to be_invalid } - end + context "when the nickname already exists" do + context "and a user has the nickname" do + let!(:another_user) { create(:user, organization:, nickname: name.upcase) } - context "when the password is weak" do - let(:password) { "aaaabbbbcccc" } + it { is_expected.to be_valid } - it { is_expected.to be_invalid } - end + it "adds a suffix in the nickname" do + expect(subject.nickname).to eq("justme_2") + end - context "when the password confirmation is not present" do - let(:password_confirmation) { nil } + 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_invalid } - end + it { is_expected.to be_valid } + end + end - context "when the password confirmation is different from password" do - let(:password_confirmation) { "invalid" } + context "and a user_group has the nickname" do + let!(:user_group) { create(:user_group, organization:, nickname: name) } - it { is_expected.to be_invalid } - end + it { is_expected.to be_valid } + end + end - context "when the tos_agreement is not accepted" do - let(:tos_agreement) { "0" } + 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_invalid } + 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 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/decidim/extra_user_fields/user_export_serializer_spec.rb similarity index 89% rename from spec/serializers/user_export_serializer_spec.rb rename to spec/serializers/decidim/extra_user_fields/user_export_serializer_spec.rb index e60c024..9eb39bd 100644 --- a/spec/serializers/user_export_serializer_spec.rb +++ b/spec/serializers/decidim/extra_user_fields/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 @@ -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" } diff --git a/spec/system/account_spec.rb b/spec/system/account_spec.rb index 44ca322..3033eaa 100644 --- a/spec/system/account_spec.rb +++ b/spec/system/account_spec.rb @@ -2,15 +2,15 @@ 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).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 @@ -46,8 +46,9 @@ end let(:phone_number) do - { "enabled" => true } + { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil } end + let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } let(:location) do { "enabled" => true } @@ -68,7 +69,7 @@ end describe "updating personal data" do - it "updates the user's data" do + before do within "form.edit_user" do select "Castellano", from: :user_locale fill_in :user_name, with: "Nikola Tesla" @@ -87,13 +88,31 @@ find("*[type=submit]").click end + end + it "updates the user's data" do within_flash_messages do expect(page).to have_content("successfully") end + end + + context "with phone number pattern blank" do + let(:phone_number_pattern) { nil } + + it "updates the user's data" do + within_flash_messages do + expect(page).to have_content("successfully") + end + end + end + + context "with phone number pattern not compatible with number" do + let(:phone_number_pattern) { "^(\\+34)?[0-1 ]{9,12}$" } - within ".title-bar" do - expect(page).to have_content("Nikola Tesla") + it "does not update the user's data" do + within("label[for='user_phone_number']") do + expect(page).to have_content("There is an error in this field.") + end end end end diff --git a/spec/system/admin_manages_officializations_spec.rb b/spec/system/admin_manages_officializations_spec.rb index fefb60d..3c9f367 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 } @@ -10,17 +10,21 @@ 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) login_as admin, scope: :user visit decidim_admin.root_path - click_link "Participants" + within ".layout-nav" do + click_on "Participants" + end end it "includes export dropdown button" do - click_link "Participants" + within ".sidebar-menu" do + click_on "Participants" + end 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 dde7091..1c46fec 100644 --- a/spec/system/admin_manages_organization_extra_user_fields_spec.rb +++ b/spec/system/admin_manages_organization_extra_user_fields_spec.rb @@ -2,9 +2,9 @@ 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: organization) } + let(:user) { create(:user, :admin, :confirmed, organization:) } before do switch_to_host(organization.host) @@ -14,7 +14,7 @@ it "creates a new item in submenu" do visit decidim_admin.edit_organization_path - within ".secondary-nav" do + within ".sidebar-menu" do expect(page).to have_content("Manage extra user fields") end end @@ -25,17 +25,15 @@ end it "displays the form" do - within "#extra_user_fields" do + within ".item_show__wrapper" do expect(page).to have_content("Manage extra user fields") + expect(page).to have_css("#extra_user_fields") end 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 @@ -44,7 +42,7 @@ it "flashes a success message" do page.check("extra_user_fields[enabled]") - find("*[type=submit]").click + find("*[type=submit]", text: "Save configuration").click expect(page).to have_content("Extra user fields correctly updated in organization") end end diff --git a/spec/system/registration_spec.rb b/spec/system/registration_spec.rb index 250aff3..9250b93 100644 --- a/spec/system/registration_spec.rb +++ b/spec/system/registration_spec.rb @@ -4,10 +4,8 @@ def fill_registration_form fill_in :registration_user_name, with: "Nikola Tesla" - fill_in :registration_user_nickname, with: "the-greatest-genius-in-history" fill_in :registration_user_email, with: "nikola.tesla@example.org" fill_in :registration_user_password, with: "sekritpass123" - fill_in :registration_user_password_confirmation, with: "sekritpass123" page.check("registration_user_newsletter") page.check("registration_user_tos_agreement") end @@ -24,7 +22,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 @@ -33,8 +31,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 { @@ -68,8 +66,9 @@ def fill_extra_user_fields end let(:phone_number) do - { "enabled" => true } + { "enabled" => true, "pattern" => phone_number_pattern, "placeholder" => nil } end + let(:phone_number_pattern) { "^(\\+34)?[0-9 ]{9,12}$" } let(:location) do { "enabled" => true } @@ -85,7 +84,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") @@ -109,6 +108,39 @@ def fill_extra_user_fields expect(page).to have_content("message with a confirmation link has been sent") end + context "with phone number pattern blank" do + let(:phone_number_pattern) { nil } + + it "allows to create a new account" do + fill_registration_form + fill_extra_user_fields + + within "form.new_user" do + find("*[type=submit]").click + end + + expect(page).to have_content("message with a confirmation link has been sent") + end + end + + context "with phone number pattern not compatible with number" do + let(:phone_number_pattern) { "^(\\+34)?[0-1 ]{9,12}$" } + + it "does not allow to create a new account" do + fill_registration_form + fill_extra_user_fields + + within "form.new_user" do + find("*[type=submit]").click + end + + expect(page).to have_no_content("message with a confirmation link has been sent") + within("label[for='registration_user_phone_number']") do + expect(page).to have_content("There is an error in this field.") + end + end + end + it_behaves_like "mandatory extra user fields", "date_of_birth" it_behaves_like "mandatory extra user fields", "gender" it_behaves_like "mandatory extra user fields", "country" @@ -123,12 +155,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