From 3c89024a461520277074de3a5673e26c6f27855a Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:38:47 +0100 Subject: [PATCH 1/7] fix: Rubocop configuration --- .rubocop_rails.yml | 3 +++ Gemfile | 2 +- Gemfile.lock | 3 ++- .../decidim/cleaner/admin/update_organization_cleaner_spec.rb | 2 +- spec/commands/decidim/destroy_account_spec.rb | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.rubocop_rails.yml b/.rubocop_rails.yml index 1d1371e..19de2a7 100644 --- a/.rubocop_rails.yml +++ b/.rubocop_rails.yml @@ -91,3 +91,6 @@ Rails/SkipsModelValidations: Rails/Validation: Include: - decidim-*/app/models/**/*.rb + +FactoryBot/FactoryAssociationWithStrategy: + Enabled: false \ No newline at end of file diff --git a/Gemfile b/Gemfile index 842faba..f729e52 100644 --- a/Gemfile +++ b/Gemfile @@ -12,8 +12,8 @@ gem "puma", ">= 4.3" 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" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 6d1822d..ace8cf4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -652,7 +652,7 @@ GEM rubocop-faker (1.1.0) faker (>= 2.12.0) rubocop (>= 0.82.0) - rubocop-rails (2.22.1) + rubocop-rails (2.19.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) @@ -773,6 +773,7 @@ DEPENDENCIES letter_opener_web (~> 2.0) listen (~> 3.1) puma (>= 4.3) + rubocop-rails (~> 2.19.0) spring (~> 2.0) spring-watcher-listen (~> 2.0) web-console (~> 4.2) diff --git a/spec/commands/decidim/cleaner/admin/update_organization_cleaner_spec.rb b/spec/commands/decidim/cleaner/admin/update_organization_cleaner_spec.rb index 15fec17..074194d 100644 --- a/spec/commands/decidim/cleaner/admin/update_organization_cleaner_spec.rb +++ b/spec/commands/decidim/cleaner/admin/update_organization_cleaner_spec.rb @@ -53,7 +53,7 @@ module Decidim::Cleaner::Admin expect { command.call }.to broadcast(:ok) end - it "traces the update", versioning: true do + it "traces the update", :versioning do expect(Decidim.traceability) .to receive(:update!) .with(organization, user, a_kind_of(Hash)) diff --git a/spec/commands/decidim/destroy_account_spec.rb b/spec/commands/decidim/destroy_account_spec.rb index 9340693..79360d4 100644 --- a/spec/commands/decidim/destroy_account_spec.rb +++ b/spec/commands/decidim/destroy_account_spec.rb @@ -105,4 +105,4 @@ module Decidim end end end -end \ No newline at end of file +end From e5126a03e8115acd73ed28cb4d98112357c7795a Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:45:10 +0100 Subject: [PATCH 2/7] fix: Add x86_64-linux support in Gemfile.lock --- Gemfile.lock | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index ace8cf4..798bb91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -473,6 +473,8 @@ GEM nio4r (2.5.9) nokogiri (1.14.5-arm64-darwin) racc (~> 1.4) + nokogiri (1.14.5-x86_64-linux) + racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) snaky_hash (~> 2.0) @@ -762,6 +764,7 @@ GEM PLATFORMS arm64-darwin-22 + x86_64-linux DEPENDENCIES bootsnap (~> 1.4) From ecd89c2c4b62873209a9508f681198c8e75fd1cb Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Thu, 16 Nov 2023 14:48:34 +0100 Subject: [PATCH 3/7] fix: Remove package-lock.json and yarn.lock --- package-lock.json | 6 ------ yarn.lock | 4 ---- 2 files changed, 10 deletions(-) delete mode 100644 package-lock.json delete mode 100644 yarn.lock diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index d7fa325..0000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "decidim-module-cleaner", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index fb57ccd..0000000 --- a/yarn.lock +++ /dev/null @@ -1,4 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - From c1e5777ca82401d4c7b846989b6118d90e354f07 Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Thu, 16 Nov 2023 15:32:23 +0100 Subject: [PATCH 4/7] fix: Add matrix spec in CI --- .github/workflows/ci_cleaner.yml | 12 ++++++++++++ Gemfile.lock | 2 +- decidim-cleaner.gemspec | 2 +- lib/decidim/cleaner/version.rb | 8 ++------ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci_cleaner.yml b/.github/workflows/ci_cleaner.yml index 320845d..1eb870d 100644 --- a/.github/workflows/ci_cleaner.yml +++ b/.github/workflows/ci_cleaner.yml @@ -39,12 +39,24 @@ jobs: DATABASE_USERNAME: postgres DATABASE_PASSWORD: postgres DATABASE_HOST: localhost + matrix: + include: + - decidim-version: '0.28.0' + ruby-version: '3.1.1' + node-version: '18.15.0' + gemfile: 'Gemfile' steps: - uses: rokroskar/workflow-run-cleanup-action@v0.3.0 if: "github.ref != 'refs/heads/develop'" env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - uses: OpenSourcePolitics/rspec-action@master + env: + DECIDIM_VERSION: ${{ matrix.decidim-version }} + RUBY_VERSION: ${{ matrix.ruby-version }} + NODE_VERSION: ${{ matrix.node-version }} + WEBPACKER_RUNTIME_COMPILE: ${{ matrix.webpacker-runtime-compile }} + BUNDLE_GEMFILE: ${{ matrix.gemfile }} with: command: "bundle exec rspec --exclude-pattern 'spec/system/**/*_spec.rb'" system_tests: diff --git a/Gemfile.lock b/Gemfile.lock index 798bb91..eb69d72 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,7 +177,7 @@ PATH remote: . specs: decidim-cleaner (4.1.2) - decidim-core (~> 0.28.dev) + decidim-core (>= 0.26.0, < 0.29) GEM remote: https://rubygems.org/ diff --git a/decidim-cleaner.gemspec b/decidim-cleaner.gemspec index e67a5bf..8b3ec2f 100644 --- a/decidim-cleaner.gemspec +++ b/decidim-cleaner.gemspec @@ -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::COMPAT_DECIDIM_VERSION end diff --git a/lib/decidim/cleaner/version.rb b/lib/decidim/cleaner/version.rb index 0944cca..5622b30 100644 --- a/lib/decidim/cleaner/version.rb +++ b/lib/decidim/cleaner/version.rb @@ -1,6 +1,5 @@ # frozen_string_literal: true -# :nocov: module Decidim # This holds the decidim-meetings version. module Cleaner @@ -8,9 +7,6 @@ def self.version "4.1.2" end - def self.compatible_decidim_version - "0.28.dev" - end + COMPAT_DECIDIM_VERSION = [">= 0.26.0", "< 0.29"].freeze end -end -# :nocov: +end \ No newline at end of file From 0ca396c00dd9e6dcd5d8245eaa2403bfd9deef04 Mon Sep 17 00:00:00 2001 From: Quentin Champenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:42:07 +0100 Subject: [PATCH 5/7] fix: Explicit hash for ruby < 3.0 --- app/jobs/decidim/cleaner/clean_inactive_users_job.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/jobs/decidim/cleaner/clean_inactive_users_job.rb b/app/jobs/decidim/cleaner/clean_inactive_users_job.rb index 0b5a4eb..236f43a 100644 --- a/app/jobs/decidim/cleaner/clean_inactive_users_job.rb +++ b/app/jobs/decidim/cleaner/clean_inactive_users_job.rb @@ -9,11 +9,11 @@ def perform Decidim::Organization.find_each do |organization| next unless organization.delete_inactive_users? - send_warning(Decidim::User.unscoped.where(organization:) + send_warning(Decidim::User.unscoped.where(organization: organization) .not_deleted .where.not(email: "") .where("current_sign_in_at < ?", email_inactive_before_date(organization))) - delete_user_and_send_email(Decidim::User.unscoped.where(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))) From fc5901f31e46c5d6d709a01b2836002f759d75e9 Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Fri, 17 Nov 2023 10:30:26 +0100 Subject: [PATCH 6/7] Revert "fix: Add matrix spec in CI" This reverts commit c1e5777ca82401d4c7b846989b6118d90e354f07. --- .github/workflows/ci_cleaner.yml | 12 ------------ Gemfile.lock | 2 +- decidim-cleaner.gemspec | 2 +- lib/decidim/cleaner/version.rb | 8 ++++++-- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci_cleaner.yml b/.github/workflows/ci_cleaner.yml index 1eb870d..320845d 100644 --- a/.github/workflows/ci_cleaner.yml +++ b/.github/workflows/ci_cleaner.yml @@ -39,24 +39,12 @@ jobs: DATABASE_USERNAME: postgres DATABASE_PASSWORD: postgres DATABASE_HOST: localhost - matrix: - include: - - decidim-version: '0.28.0' - ruby-version: '3.1.1' - node-version: '18.15.0' - gemfile: 'Gemfile' steps: - uses: rokroskar/workflow-run-cleanup-action@v0.3.0 if: "github.ref != 'refs/heads/develop'" env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - uses: OpenSourcePolitics/rspec-action@master - env: - DECIDIM_VERSION: ${{ matrix.decidim-version }} - RUBY_VERSION: ${{ matrix.ruby-version }} - NODE_VERSION: ${{ matrix.node-version }} - WEBPACKER_RUNTIME_COMPILE: ${{ matrix.webpacker-runtime-compile }} - BUNDLE_GEMFILE: ${{ matrix.gemfile }} with: command: "bundle exec rspec --exclude-pattern 'spec/system/**/*_spec.rb'" system_tests: diff --git a/Gemfile.lock b/Gemfile.lock index eb69d72..798bb91 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,7 +177,7 @@ PATH remote: . specs: decidim-cleaner (4.1.2) - decidim-core (>= 0.26.0, < 0.29) + decidim-core (~> 0.28.dev) GEM remote: https://rubygems.org/ diff --git a/decidim-cleaner.gemspec b/decidim-cleaner.gemspec index 8b3ec2f..e67a5bf 100644 --- a/decidim-cleaner.gemspec +++ b/decidim-cleaner.gemspec @@ -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::COMPAT_DECIDIM_VERSION + s.add_dependency "decidim-core", "~> #{Decidim::Cleaner.compatible_decidim_version}" end diff --git a/lib/decidim/cleaner/version.rb b/lib/decidim/cleaner/version.rb index 5622b30..0944cca 100644 --- a/lib/decidim/cleaner/version.rb +++ b/lib/decidim/cleaner/version.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +# :nocov: module Decidim # This holds the decidim-meetings version. module Cleaner @@ -7,6 +8,9 @@ def self.version "4.1.2" end - COMPAT_DECIDIM_VERSION = [">= 0.26.0", "< 0.29"].freeze + def self.compatible_decidim_version + "0.28.dev" + end end -end \ No newline at end of file +end +# :nocov: From 2df64db7ea95984fea3f670ab901f272f1de6825 Mon Sep 17 00:00:00 2001 From: quentinchampenois <26109239+Quentinchampenois@users.noreply.github.com> Date: Fri, 17 Nov 2023 12:06:28 +0100 Subject: [PATCH 7/7] fix: Rubocop syntax --- .rubocop_ruby.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.rubocop_ruby.yml b/.rubocop_ruby.yml index c5346f7..c688d07 100644 --- a/.rubocop_ruby.yml +++ b/.rubocop_ruby.yml @@ -528,6 +528,8 @@ Style/GuardClause: MinBodyLength: 6 Style/HashSyntax: + Exclude: + - app/jobs/decidim/cleaner/clean_inactive_users_job.rb EnforcedStyle: ruby19 SupportedStyles: # checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys