diff --git a/.github/workflows/ci_cleaner.yml b/.github/workflows/ci_cleaner.yml index 320845d..12d23bf 100644 --- a/.github/workflows/ci_cleaner.yml +++ b/.github/workflows/ci_cleaner.yml @@ -4,11 +4,12 @@ on: [push] env: CI: "true" CODECOV: "true" - RUBY_VERSION: 3.1.1 - NODE_VERSION: 16.9.1 - WEBPACKER_RUNTIME_COMPILE: "false" + RUBY_VERSION: 3.2.2 + NODE_VERSION: 18.17.1 + SHAKAPACKER_RUNTIME_COMPILE: "false" RAILS_ENV: test - + DISABLE_SPRING: "true" + jobs: lint: name: Lint code @@ -82,4 +83,4 @@ jobs: - uses: OpenSourcePolitics/publish-gem-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} - rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }} \ No newline at end of file + rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }} diff --git a/.node-version b/.node-version index 06e7515..4a1f488 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -16.9.1 +18.17.1 diff --git a/.rubocop.yml b/.rubocop.yml index 53ea2b4..4d75286 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +require: rubocop-factory_bot + inherit_from: - .rubocop_ruby.yml - .rubocop_rails.yml @@ -19,4 +21,4 @@ AllCops: RSpec/DescribeClass: Exclude: - - spec/system/* \ No newline at end of file + - spec/system/* diff --git a/.rubocop_ruby.yml b/.rubocop_ruby.yml index c688d07..02b35ab 100644 --- a/.rubocop_ruby.yml +++ b/.rubocop_ruby.yml @@ -975,9 +975,10 @@ Style/SymbolArray: Style/SymbolProc: # A list of method names to be ignored by the check. # The names should be fairly unique, otherwise you'll end up ignoring lots of code. - IgnoredMethods: - - respond_to - - define_method + Enabled: true + Exclude: + - respond_to + - define_method Style/TernaryParentheses: EnforcedStyle: require_no_parentheses diff --git a/.ruby-version b/.ruby-version index 94ff29c..be94e6f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.1 +3.2.2 diff --git a/Gemfile b/Gemfile index f729e52..237b072 100644 --- a/Gemfile +++ b/Gemfile @@ -4,23 +4,23 @@ source "https://rubygems.org" ruby RUBY_VERSION -gem "decidim", git: "https://github.com/decidim/decidim" +gem "decidim", "~> 0.29.1" gem "decidim-cleaner", path: "." gem "bootsnap", "~> 1.4" -gem "puma", ">= 4.3" +gem "puma", ">= 6.3.1" group :development, :test do gem "byebug", "~> 11.0", platform: :mri - gem "decidim-dev", git: "https://github.com/decidim/decidim" - gem "rubocop-rails", "~> 2.19.0" + gem "decidim-dev", "~> 0.29.1" + gem "rubocop-rails", "~> 2.25" end group :development do gem "faker", "~> 3.2" gem "letter_opener_web", "~> 2.0" gem "listen", "~> 3.1" - gem "spring", "~> 2.0" + gem "spring", "~> 4.0" gem "spring-watcher-listen", "~> 2.0" gem "web-console", "~> 4.2" end diff --git a/Gemfile.lock b/Gemfile.lock index 798bb91..7d1d085 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,65 +1,198 @@ -GIT - remote: https://github.com/decidim/decidim - revision: 840ad0186b1ac74b039066c16e9e883dfc9b002f +PATH + remote: . + specs: + decidim-cleaner (5.0.0) + decidim-core (~> 0.29.0) + +GEM + remote: https://rubygems.org/ specs: - decidim (0.28.0.dev) - decidim-accountability (= 0.28.0.dev) - decidim-admin (= 0.28.0.dev) - decidim-api (= 0.28.0.dev) - decidim-assemblies (= 0.28.0.dev) - decidim-blogs (= 0.28.0.dev) - decidim-budgets (= 0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-debates (= 0.28.0.dev) - decidim-forms (= 0.28.0.dev) - decidim-generators (= 0.28.0.dev) - decidim-meetings (= 0.28.0.dev) - decidim-pages (= 0.28.0.dev) - decidim-participatory_processes (= 0.28.0.dev) - decidim-proposals (= 0.28.0.dev) - decidim-sortitions (= 0.28.0.dev) - decidim-surveys (= 0.28.0.dev) - decidim-system (= 0.28.0.dev) - decidim-templates (= 0.28.0.dev) - decidim-verifications (= 0.28.0.dev) - decidim-accountability (0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-admin (0.28.0.dev) + actioncable (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.8.7) + actionpack (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activesupport (= 7.0.8.7) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.8.7) + actionview (= 7.0.8.7) + activesupport (= 7.0.8.7) + rack (~> 2.0, >= 2.2.4) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.8.7) + actionpack (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.8.7) + activesupport (= 7.0.8.7) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + active_link_to (1.0.5) + actionpack + addressable + activejob (7.0.8.7) + activesupport (= 7.0.8.7) + globalid (>= 0.3.6) + activemodel (7.0.8.7) + activesupport (= 7.0.8.7) + activerecord (7.0.8.7) + activemodel (= 7.0.8.7) + activesupport (= 7.0.8.7) + activestorage (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activesupport (= 7.0.8.7) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.8.7) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + acts_as_list (1.2.4) + activerecord (>= 6.1) + activesupport (>= 6.1) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.2) + base64 (0.2.0) + batch-loader (1.5.0) + bcrypt (3.1.20) + better_html (2.1.1) + actionview (>= 6.0) + activesupport (>= 6.0) + ast (~> 2.0) + erubi (~> 1.4) + parser (>= 2.4) + smart_properties + bigdecimal (3.1.9) + bindex (0.8.1) + bootsnap (1.18.4) + msgpack (~> 1.2) + browser (2.7.1) + builder (3.3.0) + bullet (7.1.6) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.11) + byebug (11.1.3) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + cells (4.1.8) + declarative-builder (~> 0.2.0) + declarative-option (< 0.2.0) + tilt (>= 1.4, < 3) + uber (< 0.2.0) + cells-erb (0.1.0) + cells (~> 4.0) + erbse (>= 0.1.1) + cells-rails (0.1.6) + actionpack (>= 5.0) + cells (>= 4.1.6, < 5.0.0) + charlock_holmes (0.7.9) + childprocess (5.1.0) + logger (~> 1.5) + commonmarker (0.23.11) + concurrent-ruby (1.3.4) + crack (1.0.0) + bigdecimal + rexml + crass (1.0.6) + css_parser (1.21.0) + addressable + csv (3.3.2) + dartsass (1.49.8) + date (3.4.1) + date_validator (0.12.0) + activemodel (>= 3) + activesupport (>= 3) + decidim (0.29.1) + decidim-accountability (= 0.29.1) + decidim-admin (= 0.29.1) + decidim-api (= 0.29.1) + decidim-assemblies (= 0.29.1) + decidim-blogs (= 0.29.1) + decidim-budgets (= 0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + decidim-debates (= 0.29.1) + decidim-forms (= 0.29.1) + decidim-generators (= 0.29.1) + decidim-meetings (= 0.29.1) + decidim-pages (= 0.29.1) + decidim-participatory_processes (= 0.29.1) + decidim-proposals (= 0.29.1) + decidim-sortitions (= 0.29.1) + decidim-surveys (= 0.29.1) + decidim-system (= 0.29.1) + decidim-verifications (= 0.29.1) + decidim-accountability (0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + decidim-admin (0.29.1) active_link_to (~> 1.0) - decidim-core (= 0.28.0.dev) + decidim-core (= 0.29.1) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-api (0.28.0.dev) - commonmarker (~> 0.23.0, >= 0.23.9) - graphql (~> 2.0.0) - graphql-docs (~> 3.0.1) + decidim-api (0.29.1) + decidim-core (= 0.29.1) + graphql (~> 2.2.6) + graphql-docs (~> 4.0) rack-cors (~> 1.0) - decidim-assemblies (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-blogs (0.28.0.dev) - decidim-admin (= 0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-budgets (0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-comments (0.28.0.dev) - decidim-core (= 0.28.0.dev) + decidim-assemblies (0.29.1) + decidim-core (= 0.29.1) + decidim-blogs (0.29.1) + decidim-admin (= 0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + decidim-budgets (0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + decidim-comments (0.29.1) + decidim-core (= 0.29.1) redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.28.0.dev) + decidim-core (0.29.1) active_link_to (~> 1.0) acts_as_list (~> 1.0) batch-loader (~> 1.2) browser (~> 2.7) - carrierwave (~> 2.2.1) cells-erb (~> 0.1.0) cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) date_validator (~> 0.12.0) - decidim-api (= 0.28.0.dev) devise (~> 4.7) devise-i18n (~> 1.2, < 1.11.1) diffy (~> 3.3) @@ -70,13 +203,14 @@ GIT foundation_rails_helper (~> 4.0) geocoder (~> 1.8) hashdiff (>= 0.4.0, < 2.0.0) + image_processing (~> 1.2) invisible_captcha (~> 0.12) kaminari (~> 1.2, >= 1.2.1) 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) + nokogiri (~> 1.16, >= 1.16.2) omniauth (~> 2.0) omniauth-facebook (~> 5.0) omniauth-google-oauth2 (~> 1.0) @@ -87,33 +221,32 @@ GIT pg_search (~> 2.2) premailer-rails (~> 1.10) psych (~> 4.0) - rack (~> 2.2, >= 2.2.6.4) + rack (~> 2.2, >= 2.2.8.1) rack-attack (~> 6.0) - rails (~> 6.1.7, >= 6.1.7.4) - rails-i18n (~> 6.0) + rails (~> 7.0.8) + rails-i18n (~> 7.0) ransack (~> 3.2.1) redis (~> 4.1) request_store (~> 1.5.0) rubyXL (~> 3.4) rubyzip (~> 2.0) - seven_zip_ruby (~> 1.3) shakapacker (~> 7.1.0) valid_email2 (~> 4.0) web-push (~> 3.0) wisper (~> 2.0) - decidim-debates (0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-dev (0.28.0.dev) - bullet (~> 7.0) + decidim-debates (0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + decidim-dev (0.29.1) + bullet (~> 7.1.6) byebug (~> 11.0) capybara (~> 3.39) - decidim (= 0.28.0.dev) + decidim (= 0.29.1) erb_lint (~> 0.4.0) factory_bot_rails (~> 6.2) faker (~> 3.2) i18n-tasks (~> 1.0) - nokogiri (~> 1.14, >= 1.14.3) + nokogiri (~> 1.16, >= 1.16.2) parallel_tests (~> 4.2) puma (~> 6.2, >= 6.3.1) rails-controller-testing (~> 1.0) @@ -123,195 +256,62 @@ GIT rspec-rails (~> 6.0) rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.6.0) - rubocop (~> 1.50.0) + rubocop (~> 1.65.0) + rubocop-capybara (~> 2.21) + rubocop-factory_bot (~> 2.26) rubocop-faker (~> 1.1) - rubocop-rails (~> 2.19) - rubocop-rspec (~> 2.20) + rubocop-performance (~> 1.21) + rubocop-rails (~> 2.25) + rubocop-rspec (~> 3.0) + rubocop-rspec_rails (~> 2.30) + rubocop-rubycw (~> 0.1) selenium-webdriver (~> 4.9) simplecov (~> 0.22.0) simplecov-cobertura (~> 2.1.0) + spring (~> 4.0) + spring-watcher-listen (~> 2.0) w3c_rspec_validators (~> 0.3.0) webmock (~> 3.18) wisper-rspec (~> 1.0) - decidim-forms (0.28.0.dev) - decidim-core (= 0.28.0.dev) + decidim-forms (0.29.1) + decidim-core (= 0.29.1) wicked_pdf (~> 2.1) - wkhtmltopdf-binary (~> 0.12) - decidim-generators (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-meetings (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-forms (= 0.28.0.dev) + wkhtmltopdf-binary (= 0.12.6.6) + decidim-generators (0.29.1) + decidim-core (= 0.29.1) + decidim-meetings (0.29.1) + decidim-core (= 0.29.1) + decidim-forms (= 0.29.1) icalendar (~> 2.5) - decidim-pages (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-participatory_processes (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-proposals (0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - doc2text (~> 0.4.6) + decidim-pages (0.29.1) + decidim-core (= 0.29.1) + decidim-participatory_processes (0.29.1) + decidim-core (= 0.29.1) + decidim-proposals (0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + doc2text (~> 0.4.7) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.28.0.dev) - decidim-admin (= 0.28.0.dev) - decidim-comments (= 0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-proposals (= 0.28.0.dev) - decidim-surveys (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-forms (= 0.28.0.dev) - decidim-templates (= 0.28.0.dev) - decidim-system (0.28.0.dev) + decidim-sortitions (0.29.1) + decidim-admin (= 0.29.1) + decidim-comments (= 0.29.1) + decidim-core (= 0.29.1) + decidim-proposals (= 0.29.1) + decidim-surveys (0.29.1) + decidim-core (= 0.29.1) + decidim-forms (= 0.29.1) + decidim-system (0.29.1) active_link_to (~> 1.0) - decidim-core (= 0.28.0.dev) + decidim-core (= 0.29.1) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0, >= 2.0.9) - decidim-templates (0.28.0.dev) - decidim-core (= 0.28.0.dev) - decidim-forms (= 0.28.0.dev) - decidim-verifications (0.28.0.dev) - decidim-core (= 0.28.0.dev) - -PATH - remote: . - specs: - decidim-cleaner (4.1.2) - decidim-core (~> 0.28.dev) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) - 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) - 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) - 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) - 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) - nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_link_to (1.0.5) - actionpack - addressable - activejob (6.1.7.6) - activesupport (= 6.1.7.6) - 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) - marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (6.1.7.6) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - acts_as_list (1.1.0) - activerecord (>= 4.2) - addressable (2.8.5) - public_suffix (>= 2.0.2, < 6.0) - ast (2.4.2) - base64 (0.2.0) - batch-loader (1.5.0) - bcrypt (3.1.19) - better_html (2.0.2) - actionview (>= 6.0) - activesupport (>= 6.0) - ast (~> 2.0) - erubi (~> 1.4) - parser (>= 2.4) - smart_properties - bindex (0.8.1) - bootsnap (1.17.0) - msgpack (~> 1.2) - browser (2.7.1) - builder (3.2.4) - bullet (7.1.3) - activesupport (>= 3.0.0) - uniform_notifier (~> 1.11) - byebug (11.1.3) - capybara (3.39.2) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.8) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - carrierwave (2.2.4) - activemodel (>= 5.0.0) - activesupport (>= 5.0.0) - addressable (~> 2.6) - image_processing (~> 1.1) - marcel (~> 1.0.0) - mini_mime (>= 0.1.3) - ssrf_filter (~> 1.0) - cells (4.1.7) - declarative-builder (< 0.2.0) - declarative-option (< 0.2.0) - tilt (>= 1.4, < 3) - uber (< 0.2.0) - cells-erb (0.1.0) - cells (~> 4.0) - erbse (>= 0.1.1) - cells-rails (0.1.5) - actionpack (>= 5.0) - cells (>= 4.1.6, < 5.0.0) - charlock_holmes (0.7.7) - commonmarker (0.23.10) - concurrent-ruby (1.2.2) - crack (0.4.5) - rexml - crass (1.0.6) - css_parser (1.16.0) - addressable - date (3.3.4) - date_validator (0.12.0) - activemodel (>= 3) - activesupport (>= 3) - declarative-builder (0.1.0) - declarative-option (< 0.2.0) + decidim-verifications (0.29.1) + decidim-core (= 0.29.1) + declarative-builder (0.2.0) + trailblazer-option (~> 0.1.0) declarative-option (0.1.0) - devise (4.9.3) + devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) @@ -322,13 +322,13 @@ GEM devise_invitable (2.0.9) actionmailer (>= 5.0) devise (>= 4.6) - diff-lcs (1.5.0) - diffy (3.4.2) - doc2text (0.4.6) - nokogiri (>= 1.13.2, < 1.15.0) + diff-lcs (1.5.1) + diffy (3.4.3) + doc2text (0.4.7) + nokogiri (>= 1.13.2, < 1.17.0) rubyzip (~> 2.3.0) - docile (1.4.0) - doorkeeper (5.6.6) + docile (1.4.1) + doorkeeper (5.8.1) railties (>= 5) doorkeeper-i18n (4.0.1) erb_lint (0.4.0) @@ -340,30 +340,32 @@ GEM smart_properties erbse (0.1.4) temple - erubi (1.12.0) - escape_utils (1.2.2) - excon (0.104.0) + erubi (1.13.1) + escape_utils (1.3.0) + excon (1.2.2) extended-markdown-filter (0.7.0) html-pipeline (~> 2.9) - factory_bot (6.2.1) + factory_bot (6.5.0) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) railties (>= 5.0.0) - faker (3.2.2) + faker (3.5.1) i18n (>= 1.8.11, < 2) - faraday (2.7.11) - base64 - faraday-net_http (>= 2.0, < 3.1) - ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.2) - ffi (1.16.3) + faraday (2.12.2) + faraday-net_http (>= 2.0, < 3.5) + json + logger + faraday-net_http (3.4.0) + net-http (>= 0.5.0) + ffi (1.17.0-x86_64-darwin) + ffi (1.17.0-x86_64-linux-gnu) file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) - fog-core (2.3.0) + fog-core (2.6.0) builder - excon (~> 0.71) + excon (~> 1.0) formatador (>= 0.2, < 2.0) mime-types fog-local (0.8.0) @@ -375,31 +377,34 @@ GEM activesupport (>= 4.1, < 7.1) railties (>= 4.1, < 7.1) gemoji (3.0.1) - geocoder (1.8.2) + geocoder (1.8.5) + base64 (>= 0.1.0) + csv (>= 3.0.0) globalid (1.2.1) activesupport (>= 6.1) - graphql (2.0.27) - graphql-docs (3.0.1) - commonmarker (~> 0.16) - escape_utils (~> 1.2.2) + graphql (2.2.16) + base64 + graphql-docs (4.0.0) + commonmarker (~> 0.23, >= 0.23.6) + dartsass (~> 1.49) + escape_utils (~> 1.2) extended-markdown-filter (~> 0.4) gemoji (~> 3.0) graphql (~> 2.0) - html-pipeline (~> 2.9) - sass (~> 3.4) - hashdiff (1.0.1) + html-pipeline (~> 2.14, >= 2.14.3) + hashdiff (1.1.2) hashie (5.0.0) - highline (2.1.0) + highline (3.1.1) + reline html-pipeline (2.14.3) activesupport (>= 2) nokogiri (>= 1.4) htmlentities (4.3.4) - i18n (1.14.1) + i18n (1.14.6) concurrent-ruby (~> 1.0) - i18n-tasks (1.0.13) + i18n-tasks (1.0.14) activesupport (>= 4.0.2) ast (>= 2.1.0) - better_html (>= 1.0, < 3.0) erubi highline (>= 2.0.0) i18n @@ -407,16 +412,19 @@ GEM rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) - icalendar (2.10.0) + icalendar (2.10.3) ice_cube (~> 0.16) - ice_cube (0.16.4) - image_processing (1.12.2) + ostruct + ice_cube (0.17.0) + image_processing (1.13.0) 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) + io-console (0.8.0) + json (2.9.1) + jwt (2.10.1) + base64 kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -429,19 +437,22 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - launchy (2.5.2) + language_server-protocol (3.17.0.3) + launchy (3.0.1) 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 (2.0.0) actionmailer (>= 5.2) letter_opener (~> 1.7) railties (>= 5.2) rexml - listen (3.8.0) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.22.0) + logger (1.6.4) + loofah (2.23.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -449,31 +460,34 @@ GEM net-imap net-pop net-smtp - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - method_source (1.0.0) - mime-types (3.5.1) + method_source (1.1.0) + mime-types (3.6.0) + logger mime-types-data (~> 3.2015) - mime-types-data (3.2023.1003) - mini_magick (4.12.0) + mime-types-data (3.2024.1203) + mini_magick (4.13.2) mini_mime (1.1.5) - minitest (5.20.0) - msgpack (1.7.2) - multi_xml (0.6.0) - mustache (1.1.1) - net-imap (0.4.5) + minitest (5.25.4) + msgpack (1.7.5) + multi_xml (0.7.1) + bigdecimal (~> 3.1) + net-http (0.6.0) + uri + net-imap (0.5.4) date net-protocol net-pop (0.1.2) net-protocol 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) + nio4r (2.7.4) + nokogiri (1.16.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.14.5-x86_64-linux) + nokogiri (1.16.8-x86_64-linux) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) @@ -488,24 +502,25 @@ 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) - jwt (>= 2.0) - oauth2 (~> 2.0.6) + omniauth-google-oauth2 (1.2.0) + jwt (>= 2.9) + oauth2 (~> 2.0) omniauth (~> 2.0) - omniauth-oauth2 (~> 1.8.0) - omniauth-oauth (1.2.0) + omniauth-oauth2 (~> 1.8) + omniauth-oauth (1.2.1) oauth omniauth (>= 1.0, < 3) + rack (>= 1.6.2, < 4) omniauth-oauth2 (1.8.0) oauth2 (>= 1.4, < 3) omniauth (~> 2.0) - omniauth-rails_csrf_protection (1.0.1) + omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) omniauth-twitter (1.4.0) @@ -513,22 +528,23 @@ GEM rack openssl (3.2.0) orm_adapter (0.5.0) + ostruct (0.6.1) paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) - parallel (1.23.0) - parallel_tests (4.3.0) + parallel (1.26.3) + parallel_tests (4.7.2) parallel - parser (3.2.2.4) + parser (3.3.6.0) ast (~> 2.4.1) racc pg (1.4.6) - pg_search (2.3.6) - activerecord (>= 5.2) - activesupport (>= 5.2) - premailer (1.21.0) + pg_search (2.3.7) + activerecord (>= 6.1) + activesupport (>= 6.1) + premailer (1.27.0) addressable - css_parser (>= 1.12.0) + css_parser (>= 1.19.0) htmlentities (>= 4.0.0) premailer-rails (1.12.0) actionmailer (>= 3) @@ -536,36 +552,36 @@ GEM premailer (~> 1.7, >= 1.7.9) psych (4.0.6) stringio - public_suffix (5.0.3) - puma (6.4.0) + public_suffix (6.0.1) + puma (6.5.0) nio4r (~> 2.0) - racc (1.7.3) - rack (2.2.8) + racc (1.8.1) + rack (2.2.10) 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.7) rack - rack-test (2.1.0) + rack-test (2.2.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 (7.0.8.7) + actioncable (= 7.0.8.7) + actionmailbox (= 7.0.8.7) + actionmailer (= 7.0.8.7) + actionpack (= 7.0.8.7) + actiontext (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activemodel (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) bundler (>= 1.15.0) - railties (= 6.1.7.6) - sprockets-rails (>= 2.0.0) + railties (= 7.0.8.7) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -574,113 +590,120 @@ GEM activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) + rails-html-sanitizer (1.6.2) loofah (~> 2.21) - nokogiri (~> 1.14) - rails-i18n (6.0.0) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rails-i18n (7.0.10) 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.0.0, < 8) + railties (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.1.0) + 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) + rb-inotify (0.11.1) ffi (~> 1.0) redcarpet (3.6.0) redis (4.8.1) - regexp_parser (2.8.2) + regexp_parser (2.10.0) + reline (0.6.0) + io-console (~> 0.5) request_store (1.5.1) rack (>= 1.4) 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) + rexml (3.4.0) + rspec (3.13.0) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-cells (0.3.10) 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) + rspec-core (3.13.2) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) + rspec-support (~> 3.13.0) rspec-html-matchers (0.10.0) nokogiri (~> 1) rspec (>= 3.0.0.a) - rspec-mocks (3.12.6) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.12.0) - rspec-rails (6.0.3) + rspec-support (~> 3.13.0) + rspec-rails (6.1.5) actionpack (>= 6.1) activesupport (>= 6.1) railties (>= 6.1) - rspec-core (~> 3.12) - rspec-expectations (~> 3.12) - rspec-mocks (~> 3.12) - rspec-support (~> 3.12) + 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-support (3.13.2) rspec_junit_formatter (0.6.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (1.50.2) + rubocop (1.65.1) json (~> 2.3) + language_server-protocol (>= 3.17.0) parallel (~> 1.10) - parser (>= 3.2.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) + regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.28.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) - rubocop-capybara (2.19.0) + rubocop-ast (1.37.0) + parser (>= 3.3.1.0) + rubocop-capybara (2.21.0) rubocop (~> 1.41) - rubocop-factory_bot (2.24.0) - rubocop (~> 1.33) - rubocop-faker (1.1.0) + rubocop-factory_bot (2.26.1) + rubocop (~> 1.61) + rubocop-faker (1.2.0) faker (>= 2.12.0) - rubocop (>= 0.82.0) - rubocop-rails (2.19.1) + rubocop (>= 1.13.0) + rubocop-performance (1.23.0) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rails (2.28.0) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - rubocop-rspec (2.25.0) - rubocop (~> 1.40) - rubocop-capybara (~> 2.17) - rubocop-factory_bot (~> 2.22) + rubocop (>= 1.52.0, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-rspec (3.3.0) + rubocop (~> 1.61) + rubocop-rspec_rails (2.30.0) + rubocop (~> 1.61) + rubocop-rspec (~> 3, >= 3.0.1) + rubocop-rubycw (0.1.6) + rubocop (~> 1.0) ruby-progressbar (1.13.0) - ruby-vips (2.2.0) + ruby-vips (2.2.2) ffi (~> 1.12) - ruby2_keywords (0.0.5) - rubyXL (3.4.25) + logger + rubyXL (3.4.33) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - selenium-webdriver (4.15.0) + selenium-webdriver (4.27.0) + base64 (~> 0.2) + logger (~> 1.4) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) - semantic_range (3.0.0) - seven_zip_ruby (1.3.0) + semantic_range (3.1.0) shakapacker (7.1.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) @@ -693,40 +716,34 @@ GEM simplecov-cobertura (2.1.0) rexml simplecov (~> 0.19) - simplecov-html (0.12.3) + simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) smart_properties (1.17.0) snaky_hash (2.0.1) hashie version_gem (~> 1.1, >= 1.1.1) - spring (2.1.1) - spring-watcher-listen (2.0.1) + spring (4.2.1) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.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.2) - stringio (3.0.9) + spring (>= 4) + stringio (3.1.2) temple (0.10.3) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thor (1.3.0) - tilt (2.3.0) - timeout (0.4.1) + thor (1.3.2) + tilt (2.5.0) + timeout (0.4.3) + trailblazer-option (0.1.2) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) - unicode-display_width (2.5.0) + unicode-display_width (2.6.0) uniform_notifier (1.16.0) + uri (1.0.2) valid_email2 (4.0.6) activemodel (>= 3.2) mail (~> 2.5) - version_gem (1.1.3) + version_gem (1.1.4) w3c_rspec_validators (0.3.0) rails rspec @@ -745,44 +762,45 @@ GEM web-push (3.0.1) jwt (~> 2.0) openssl (~> 3.0) - webmock (3.19.1) + webmock (3.24.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket (1.2.10) + websocket (1.2.11) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - wicked_pdf (2.7.0) + wicked_pdf (2.8.2) activesupport + ostruct 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.12) + zeitwerk (2.7.1) PLATFORMS - arm64-darwin-22 + x86_64-darwin x86_64-linux DEPENDENCIES bootsnap (~> 1.4) byebug (~> 11.0) - decidim! + decidim (~> 0.29.1) decidim-cleaner! - decidim-dev! + decidim-dev (~> 0.29.1) faker (~> 3.2) letter_opener_web (~> 2.0) listen (~> 3.1) - puma (>= 4.3) - rubocop-rails (~> 2.19.0) - spring (~> 2.0) + puma (>= 6.3.1) + rubocop-rails (~> 2.25) + spring (~> 4.0) spring-watcher-listen (~> 2.0) web-console (~> 4.2) RUBY VERSION - ruby 3.1.1p18 + ruby 3.2.2p53 BUNDLED WITH - 2.4.9 + 2.5.22 diff --git a/app/commands/decidim/cleaner/custom_destroy_account.rb b/app/commands/decidim/cleaner/custom_destroy_account.rb new file mode 100644 index 0000000..373dae4 --- /dev/null +++ b/app/commands/decidim/cleaner/custom_destroy_account.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true + +module Decidim + module Cleaner + # This command destroys the user's account. + class CustomDestroyAccount < Decidim::DestroyAccount + # Destroy a user's account. + # + # user - The user to be updated. + # form - The form with the data. + def initialize(user, form) + @user = user + @form = form + end + + private + + def destroy_user_account! + @user.name = "" + @user.nickname = "" + @user.email = "" + @user.personal_url = "" + @user.about = "" + @user.delete_reason = @form.delete_reason + @user.admin = false if @user.admin? + @user.deleted_at = Time.current + @user.skip_reconfirmation! + @user.avatar.purge + @user.save! + + # Invalidate all sessions after cleaning Decidim::User record to prevent Active Record error + @user.invalidate_all_sessions! + end + + def destroy_user_identities + @user.identities.destroy_all + end + + def destroy_user_group_memberships + Decidim::UserGroupMembership.where(user: @user).destroy_all + end + + def destroy_follows + Decidim::Follow.where(followable: @user).destroy_all + Decidim::Follow.where(user: @user).destroy_all + end + + def destroy_participatory_space_private_user + Decidim::ParticipatorySpacePrivateUser.where(user: @user).destroy_all + end + + def delegate_destroy_to_participatory_spaces + Decidim.participatory_space_manifests.each do |space_manifest| + space_manifest.invoke_on_destroy_account(@user) + end + end + end + end +end diff --git a/app/jobs/decidim/cleaner/clean_admin_logs_job.rb b/app/jobs/decidim/cleaner/clean_admin_logs_job.rb index 23a88f1..b562d18 100644 --- a/app/jobs/decidim/cleaner/clean_admin_logs_job.rb +++ b/app/jobs/decidim/cleaner/clean_admin_logs_job.rb @@ -10,7 +10,7 @@ def perform next unless organization.delete_admin_logs? Decidim::ActionLog.where(organization:) - .where("created_at < ?", delete_admin_logs_before_date(organization)) + .where(created_at: ...delete_admin_logs_before_date(organization)) .delete_all end end diff --git a/app/jobs/decidim/cleaner/clean_deleted_users_data_job.rb b/app/jobs/decidim/cleaner/clean_deleted_users_data_job.rb index 68e471a..96addfc 100644 --- a/app/jobs/decidim/cleaner/clean_deleted_users_data_job.rb +++ b/app/jobs/decidim/cleaner/clean_deleted_users_data_job.rb @@ -18,7 +18,7 @@ def remove_versions_for_deleted_users INNER JOIN decidim_users ON decidim_users.id = versions.item_id AND versions.item_type IN ('Decidim::User', 'Decidim::UserBaseEntity') SQL - ).where("deleted_at < ?", date_before_delete_user_versions).each do |version| + ).where(decidim_users: { deleted_at: ...date_before_delete_user_versions }).each do |version| version.destroy! Rails.logger.info "Version for user with id #{version.item_id} destroyed" end @@ -31,7 +31,7 @@ def remove_versions_for_deleted_authorizations AND versions.item_type = 'Decidim::Authorization' SQL ).where(item_type: "Decidim::Authorization", decidim_authorizations: { id: nil }) - .where("versions.created_at < ?", date_before_delete_authorization_versions) + .where(versions: { created_at: ...date_before_delete_authorization_versions }) .each do |version| version.destroy! Rails.logger.info "Version for authorization with id #{version.item_id} destroyed" diff --git a/app/jobs/decidim/cleaner/clean_inactive_users_job.rb b/app/jobs/decidim/cleaner/clean_inactive_users_job.rb index 236f43a..f65515d 100644 --- a/app/jobs/decidim/cleaner/clean_inactive_users_job.rb +++ b/app/jobs/decidim/cleaner/clean_inactive_users_job.rb @@ -12,11 +12,11 @@ def perform send_warning(Decidim::User.unscoped.where(organization: organization) .not_deleted .where.not(email: "") - .where("current_sign_in_at < ?", email_inactive_before_date(organization))) + .where(current_sign_in_at: ...email_inactive_before_date(organization))) delete_user_and_send_email(Decidim::User.unscoped.where(organization: organization) .not_deleted .where.not(email: "") - .where("warning_date < ?", delete_inactive_before_date(organization))) + .where(warning_date: ...delete_inactive_before_date(organization))) end end @@ -40,7 +40,7 @@ def delete_user_and_send_email(users) InactiveUsersMailer.warning_deletion(user).deliver_now Rails.logger.info "Deletion warning sent to #{user.email}" - Decidim::DestroyAccount.call(user, Decidim::DeleteAccountForm.from_params({ delete_reason: I18n.t("decidim.cleaner.delete_reason") })) + CustomDestroyAccount.call(user, Decidim::DeleteAccountForm.from_params({ delete_reason: I18n.t("decidim.cleaner.delete_reason") })) Rails.logger.info "User with id #{user.id} destroyed" end end diff --git a/app/views/decidim/cleaner/admin/organization_cleaner/_form.html.erb b/app/views/decidim/cleaner/admin/organization_cleaner/_form.html.erb index 974cdc5..814cff3 100644 --- a/app/views/decidim/cleaner/admin/organization_cleaner/_form.html.erb +++ b/app/views/decidim/cleaner/admin/organization_cleaner/_form.html.erb @@ -3,35 +3,30 @@

<%= t ".admin_log_cleaner_title" %>

-
-
- <%= form.check_box :delete_admin_logs %> -
- -
- <%= form.number_field :delete_admin_logs_after %> -
+
+ <%= form.check_box :delete_admin_logs %> +
+
+ <%= form.number_field :delete_admin_logs_after %>
-

<%= t ".inactive_users_cleaner_title" %>

-
-
- <%= form.check_box :delete_inactive_users %> -
+
+ <%= form.check_box :delete_inactive_users %> +
-
- <%= form.number_field :delete_inactive_users_email_after %> -
+
+ <%= form.number_field :delete_inactive_users_email_after %> +
-
- <%= form.number_field :delete_inactive_users_after %> -
+
+ <%= form.number_field :delete_inactive_users_after %>
+ diff --git a/app/views/decidim/cleaner/admin/organization_cleaner/edit.html.erb b/app/views/decidim/cleaner/admin/organization_cleaner/edit.html.erb index ee9b947..0817afc 100644 --- a/app/views/decidim/cleaner/admin/organization_cleaner/edit.html.erb +++ b/app/views/decidim/cleaner/admin/organization_cleaner/edit.html.erb @@ -1,6 +1,14 @@ -<%= decidim_form_for(@form, html: { class: "form edit_organization_cleaner" }, url:"/admin/organization/cleaner" , method: :put) do |f| %> - <%= render partial: "form", object: f %> -
- <%= f.submit t(".update") %> -
-<% end %> +
+

<%= t '.title' %>

+
+
+ <%= decidim_form_for(@form, html: { class: "form form-defaults edit_organization_cleaner" }, url:"/admin/organization/cleaner" , method: :put) do |form| %> +
+ <%= render partial: "form", locals: { form: } %> +
+
+ <%= form.submit t(".update"), class: "button button__sm md:button__lg button__secondary" %> +
+ <% end %> +
+ diff --git a/config/locales/en.yml b/config/locales/en.yml index fd985c3..0b44f84 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -22,6 +22,7 @@ en: admin: organization_cleaner: edit: + title: Edit Data cleaner update: Update form: admin_log_cleaner_title: Admin log diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 100af2d..570cad8 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -23,6 +23,7 @@ fr: admin: organization_cleaner: edit: + title: Modifier Nettoyeur de données update: Mettre à jour form: admin_log_cleaner_title: Historique d'administration diff --git a/decidim-cleaner.gemspec b/decidim-cleaner.gemspec index e67a5bf..af44704 100644 --- a/decidim-cleaner.gemspec +++ b/decidim-cleaner.gemspec @@ -17,7 +17,7 @@ Gem::Specification.new do |s| "homepage_uri" => "https://decidim.org", "source_code_uri" => "https://github.com/decidim/decidim" } - s.required_ruby_version = ">= 2.7.5" + s.required_ruby_version = "~> 3.2" s.name = "decidim-cleaner" s.summary = "A decidim cleaner module" @@ -25,5 +25,5 @@ Gem::Specification.new do |s| s.files = Dir["{app,config,db,lib}/**/*", "LICENSE-AGPLv3.txt", "Rakefile", "README.md"] - s.add_dependency "decidim-core", "~> #{Decidim::Cleaner.compatible_decidim_version}" + s.add_dependency "decidim-core", Decidim::Cleaner.compatible_decidim_version end diff --git a/lib/decidim/cleaner.rb b/lib/decidim/cleaner.rb index c202785..b41bfb5 100644 --- a/lib/decidim/cleaner.rb +++ b/lib/decidim/cleaner.rb @@ -3,7 +3,6 @@ require "decidim/cleaner/admin" require "decidim/cleaner/engine" require "decidim/cleaner/admin_engine" -require "decidim/cleaner/extends/commands/decidim/destroy_account" module Decidim # This namespace holds the logic of the `Cleaner` module. diff --git a/lib/decidim/cleaner/engine.rb b/lib/decidim/cleaner/engine.rb index ecb02cb..aa8cc87 100644 --- a/lib/decidim/cleaner/engine.rb +++ b/lib/decidim/cleaner/engine.rb @@ -8,10 +8,6 @@ module Cleaner # This is the engine that runs on the public interface of cleaner. class Engine < ::Rails::Engine isolate_namespace Decidim::Cleaner - - config.to_prepare do - Decidim::DestroyAccount.include(Decidim::Cleaner::Extends::DestroyAccount) - end end end end diff --git a/lib/decidim/cleaner/extends/commands/decidim/destroy_account.rb b/lib/decidim/cleaner/extends/commands/decidim/destroy_account.rb deleted file mode 100644 index 24df182..0000000 --- a/lib/decidim/cleaner/extends/commands/decidim/destroy_account.rb +++ /dev/null @@ -1,31 +0,0 @@ -# frozen_string_literal: true - -module Decidim - module Cleaner - module Extends - # This command destroys the user's account. - module DestroyAccount - extend ActiveSupport::Concern - - included do - private - - # Invalidate all sessions after cleaning Decidim::User record to prevent Active Record error - def destroy_user_account! - @user.name = "" - @user.nickname = "" - @user.email = "" - @user.delete_reason = @form.delete_reason - @user.admin = false if @user.admin? - @user.deleted_at = Time.current - @user.skip_reconfirmation! - @user.avatar.purge - @user.save! - - @user.invalidate_all_sessions! - end - end - end - end - end -end diff --git a/lib/decidim/cleaner/version.rb b/lib/decidim/cleaner/version.rb index 0944cca..67062ce 100644 --- a/lib/decidim/cleaner/version.rb +++ b/lib/decidim/cleaner/version.rb @@ -5,11 +5,11 @@ module Decidim # This holds the decidim-meetings version. module Cleaner def self.version - "4.1.2" + "5.0.0" end def self.compatible_decidim_version - "0.28.dev" + "~> 0.29.0" end end end diff --git a/spec/commands/decidim/cleaner/custom_destroy_account_spec.rb b/spec/commands/decidim/cleaner/custom_destroy_account_spec.rb new file mode 100644 index 0000000..1b402bf --- /dev/null +++ b/spec/commands/decidim/cleaner/custom_destroy_account_spec.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true + +require "spec_helper" + +module Decidim + module Cleaner + describe CustomDestroyAccount do + let(:command) { described_class.new(user, form) } + let(:user) { create(:user, :confirmed) } + let!(:identity) { create(:identity, user:) } + let(:valid) { true } + let(:data) do + { + delete_reason: "I want to delete my account" + } + end + + let(:form) do + form = double( + delete_reason: data[:delete_reason], + valid?: valid + ) + + form + end + + context "when invalid" do + let(:valid) { false } + + it "broadcasts invalid" do + expect { command.call }.to broadcast(:invalid) + end + end + + context "when valid" do + let(:valid) { true } + + it "broadcasts ok" do + expect { command.call }.to broadcast(:ok) + end + + it "changes the auth salt to invalidate all other sessions" do + old_salt = user.authenticatable_salt + command.call + expect(user.reload.authenticatable_salt).not_to eq(old_salt) + end + + it "stores the deleted_at and delete_reason to the user" do + command.call + expect(user.reload.delete_reason).to eq(data[:delete_reason]) + expect(user.reload.deleted_at).not_to be_nil + end + + it "set name, nickname, personal_url, about and email to blank string" do + command.call + user.reload + expect(user.name).to eq("") + expect(user.nickname).to eq("") + expect(user.email).to eq("") + expect(user.personal_url).to eq("") + expect(user.about).to eq("") + end + + it "destroys the current user avatar" do + command.call + expect(user.reload.avatar).not_to be_present + end + + it "deletes user's identities" do + expect do + command.call + end.to change(Identity, :count).by(-1) + end + + it "deletes user group memberships" do + user_group = create(:user_group) + create(:user_group_membership, user_group:, user:) + + expect do + command.call + end.to change(UserGroupMembership, :count).by(-1) + end + + it "deletes the follows" do + other_user = create(:user) + create(:follow, followable: user, user: other_user) + create(:follow, followable: other_user, user:) + + expect do + command.call + end.to change(Follow, :count).by(-2) + end + + it "deletes participatory space private user" do + create(:participatory_space_private_user, user:) + + expect do + command.call + end.to change(ParticipatorySpacePrivateUser, :count).by(-1) + end + + context "when user is admin" do + let(:user) { create(:user, :confirmed, :admin) } + + it "removes admin role" do + command.call + expect(user.reload.admin).to be_falsey + end + end + end + end + end +end diff --git a/spec/commands/decidim/destroy_account_spec.rb b/spec/commands/decidim/destroy_account_spec.rb deleted file mode 100644 index 79360d4..0000000 --- a/spec/commands/decidim/destroy_account_spec.rb +++ /dev/null @@ -1,108 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" - -module Decidim - describe DestroyAccount do - let(:command) { described_class.new(user, form) } - let(:user) { create(:user, :confirmed) } - let!(:identity) { create(:identity, user:) } - let(:valid) { true } - let(:data) do - { - delete_reason: "I want to delete my account" - } - end - - let(:form) do - form = double( - delete_reason: data[:delete_reason], - valid?: valid - ) - - form - end - - context "when invalid" do - let(:valid) { false } - - it "broadcasts invalid" do - expect { command.call }.to broadcast(:invalid) - end - end - - context "when valid" do - let(:valid) { true } - - it "broadcasts ok" do - expect { command.call }.to broadcast(:ok) - end - - it "changes the auth salt to invalidate all other sessions" do - old_salt = user.authenticatable_salt - command.call - expect(user.reload.authenticatable_salt).not_to eq(old_salt) - end - - it "stores the deleted_at and delete_reason to the user" do - command.call - expect(user.reload.delete_reason).to eq(data[:delete_reason]) - expect(user.reload.deleted_at).not_to be_nil - end - - it "set name, nickname and email to blank string" do - command.call - expect(user.reload.name).to eq("") - expect(user.reload.nickname).to eq("") - expect(user.reload.email).to eq("") - end - - it "destroys the current user avatar" do - command.call - expect(user.reload.avatar).not_to be_present - end - - it "deletes user's identities" do - expect do - command.call - end.to change(Identity, :count).by(-1) - end - - it "deletes user group memberships" do - user_group = create(:user_group) - create(:user_group_membership, user_group:, user:) - - expect do - command.call - end.to change(UserGroupMembership, :count).by(-1) - end - - it "deletes the follows" do - other_user = create(:user) - create(:follow, followable: user, user: other_user) - create(:follow, followable: other_user, user:) - - expect do - command.call - end.to change(Follow, :count).by(-2) - end - - it "deletes participatory space private user" do - create(:participatory_space_private_user, user:) - - expect do - command.call - end.to change(ParticipatorySpacePrivateUser, :count).by(-1) - end - - context "when user is admin" do - let(:user) { create(:user, :confirmed, :admin) } - - it "removes admin role" do - command.call - expect(user.reload.admin).to be_falsey - end - end - end - end -end diff --git a/spec/factories.rb b/spec/factories.rb index dcdd368..9924ee8 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -5,10 +5,15 @@ FactoryBot.modify do factory :organization, class: "Decidim::Organization" do transient do + skip_injection { false } create_static_pages { true } end - name { Faker::Company.unique.name } + # we do not want machine translation here + name do + Decidim.available_locales.index_with { |_locale| Faker::Company.unique.name } + end + reference_prefix { Faker::Name.suffix } time_zone { "UTC" } twitter_handler { Faker::Hipster.word } @@ -17,12 +22,11 @@ youtube_handler { Faker::Hipster.word } github_handler { Faker::Hipster.word } sequence(:host) { |n| "#{n}.lvh.me" } - description { Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title } } + description { generate_localized_description(:organization_description, skip_injection:) } favicon { Decidim::Dev.test_file("icon.png", "image/png") } 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,10 +35,10 @@ user_groups_enabled { true } send_welcome_notification { true } comments_max_length { 1000 } - admin_terms_of_service_body { Decidim::Faker::Localized.wrapped("

", "

") { generate_localized_title } } + admin_terms_of_service_body { generate_localized_description(:admin_terms_of_service_body, skip_injection:) } 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"] } + external_domain_allowlist { ["example.org", "twitter.com", "facebook.com", "youtube.com", "github.com", "mytesturl.me"] } smtp_settings do { "from" => "test@example.org", @@ -46,6 +50,26 @@ end file_upload_settings { Decidim::OrganizationSettings.default(:upload) } enable_participatory_space_filters { true } + 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 + delete_admin_logs { false } delete_inactive_users { false } @@ -56,7 +80,7 @@ after(:create) do |organization, evaluator| if evaluator.create_static_pages tos_page = Decidim::StaticPage.find_by(slug: "terms-of-service", organization:) - create(:static_page, :tos, organization:) if tos_page.nil? + create(:static_page, :tos, organization:, skip_injection: evaluator.skip_injection) if tos_page.nil? end end end diff --git a/spec/lib/decidim/cleaner/version_spec.rb b/spec/lib/decidim/cleaner/version_spec.rb index 5a21b61..7aaa0b0 100644 --- a/spec/lib/decidim/cleaner/version_spec.rb +++ b/spec/lib/decidim/cleaner/version_spec.rb @@ -7,11 +7,11 @@ module Decidim subject { described_class } it "has version" do - expect(subject.version).to eq("4.1.2") + expect(subject.version).to eq("5.0.0") end it "has decidim version compatibility" do - expect(subject.compatible_decidim_version).to eq("0.28.dev") + expect(subject.compatible_decidim_version).to eq("~> 0.29.0") end end end diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +