From 92929da65c64bdb7ba8e115c6cf3c38906af50ed Mon Sep 17 00:00:00 2001 From: Oliver Valls <199462+tramuntanal@users.noreply.github.com> Date: Wed, 19 Apr 2023 07:53:17 +0200 Subject: [PATCH 01/15] Upgrade to Ruby 3.0.6 --- .github/workflows/challenges_system_tests.yml | 2 +- .github/workflows/linters.yml | 2 +- .github/workflows/problems_system_tests.yml | 2 +- .github/workflows/sgds_system_tests.yml | 2 +- .github/workflows/solutions_system_tests.yml | 2 +- .github/workflows/test.yml | 2 +- .rubocop.yml | 2 +- .ruby-version | 2 +- CHANGELOG.md | 3 ++ Gemfile.lock | 33 ++++++++++++------- decidim-challenges.gemspec | 2 +- lib/decidim/challenges/version.rb | 2 +- 12 files changed, 34 insertions(+), 22 deletions(-) diff --git a/.github/workflows/challenges_system_tests.yml b/.github/workflows/challenges_system_tests.yml index 575d1421..0d002c73 100644 --- a/.github/workflows/challenges_system_tests.yml +++ b/.github/workflows/challenges_system_tests.yml @@ -9,7 +9,7 @@ on: pull_request: env: - RUBY_VERSION: 2.7.5 + RUBY_VERSION: 3.0.6 jobs: test-report: diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index 4b509301..ea6c5e8c 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -9,7 +9,7 @@ on: pull_request: env: - RUBY_VERSION: 2.7.5 + RUBY_VERSION: 3.0.6 jobs: test-report: diff --git a/.github/workflows/problems_system_tests.yml b/.github/workflows/problems_system_tests.yml index 97ac60b9..9fb1940c 100644 --- a/.github/workflows/problems_system_tests.yml +++ b/.github/workflows/problems_system_tests.yml @@ -9,7 +9,7 @@ on: pull_request: env: - RUBY_VERSION: 2.7.5 + RUBY_VERSION: 3.0.6 jobs: test-report: diff --git a/.github/workflows/sgds_system_tests.yml b/.github/workflows/sgds_system_tests.yml index 048acdfc..dd87b005 100644 --- a/.github/workflows/sgds_system_tests.yml +++ b/.github/workflows/sgds_system_tests.yml @@ -9,7 +9,7 @@ on: pull_request: env: - RUBY_VERSION: 2.7.5 + RUBY_VERSION: 3.0.6 jobs: test-report: diff --git a/.github/workflows/solutions_system_tests.yml b/.github/workflows/solutions_system_tests.yml index 923de54c..67b7fdbc 100644 --- a/.github/workflows/solutions_system_tests.yml +++ b/.github/workflows/solutions_system_tests.yml @@ -9,7 +9,7 @@ on: pull_request: env: - RUBY_VERSION: 2.7.5 + RUBY_VERSION: 3.0.6 jobs: test-report: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b7c5038a..4d1b0944 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ on: pull_request: env: - RUBY_VERSION: 2.7.5 + RUBY_VERSION: 3.0.6 jobs: test-report: diff --git a/.rubocop.yml b/.rubocop.yml index 2da637b0..43c19cd7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -65,7 +65,7 @@ AllCops: # If a value is specified for TargetRubyVersion then it is used. # Else if .ruby-version exists and it contains an MRI version it is used. # Otherwise we fallback to the oldest officially supported Ruby version (2.0). - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 RSpec: Patterns: diff --git a/.ruby-version b/.ruby-version index a603bb50..818bd47a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.5 +3.0.6 diff --git a/CHANGELOG.md b/CHANGELOG.md index 07372ab9..b0d8768b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Following Semantic Versioning 2. ## next version: +## Version 0.2.1 (MINOR) +- Upgrade module's Ruby to 3.0.6 + ## Version 0.2.0 (MINOR) - Increase minimum Decidim version to 0.26.2 diff --git a/Gemfile.lock b/Gemfile.lock index e65f9218..6a4230ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -175,7 +175,7 @@ GIT PATH remote: . specs: - decidim-challenges (0.2.0) + decidim-challenges (0.2.1) decidim-core (~> 0.26.2) GEM @@ -423,7 +423,7 @@ GEM invisible_captcha (0.13.0) rails (>= 3.2.0) json (2.6.2) - jwt (2.4.1) + jwt (2.5.0) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -487,7 +487,12 @@ GEM racc (~> 1.4) nokogiri (1.13.3-x86_64-linux) racc (~> 1.4) - oauth (0.5.10) + oauth (1.1.0) + oauth-tty (~> 1.0, >= 1.0.1) + snaky_hash (~> 2.0) + version_gem (~> 1.1) + oauth-tty (1.0.2) + version_gem (~> 1.1) oauth2 (1.4.10) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) @@ -521,8 +526,8 @@ GEM paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) - parallel (1.22.1) - parser (3.1.2.1) + parallel (1.23.0) + parser (3.2.2.0) ast (~> 2.4.1) pg (1.1.4) pg_search (2.3.6) @@ -600,7 +605,7 @@ GEM wisper (>= 1.6.1) redcarpet (3.5.1) redis (4.8.0) - regexp_parser (2.5.0) + regexp_parser (2.8.0) request_store (1.5.1) rack (>= 1.4) responders (3.0.1) @@ -647,15 +652,15 @@ GEM rubocop-ast (>= 0.5.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.21.0) - parser (>= 3.1.1.0) + rubocop-ast (1.28.0) + parser (>= 3.2.1.0) rubocop-rails (2.9.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 0.90.0, < 2.0) rubocop-rspec (1.43.2) rubocop (~> 0.87) - ruby-progressbar (1.11.0) + ruby-progressbar (1.13.0) ruby-vips (2.1.4) ffi (~> 1.12) ruby2_keywords (0.0.5) @@ -676,6 +681,9 @@ GEM simplecov (~> 0.8) simplecov-html (0.12.3) smart_properties (1.17.0) + snaky_hash (2.0.0) + hashie + version_gem (~> 1.1) social-share-button (1.2.4) coffee-rails spring (2.1.1) @@ -689,7 +697,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - ssrf_filter (1.0.8) + ssrf_filter (1.1.1) system_test_html_screenshots (0.2.0) actionpack (>= 5.2, < 6.1.a) temple (0.8.2) @@ -708,6 +716,7 @@ GEM valid_email2 (2.3.1) activemodel (>= 3.2) mail (~> 2.5) + version_gem (1.1.0) virtus (1.0.5) axiom-types (~> 0.1) coercible (~> 1.0) @@ -773,7 +782,7 @@ DEPENDENCIES web-console (~> 3.5) RUBY VERSION - ruby 2.7.5p203 + ruby 3.0.6p216 BUNDLED WITH - 2.3.4 + 2.3.6 diff --git a/decidim-challenges.gemspec b/decidim-challenges.gemspec index 3870617b..727db0d3 100644 --- a/decidim-challenges.gemspec +++ b/decidim-challenges.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.email = ["199462+tramuntanal@users.noreply.github.com"] s.license = "AGPL-3.0" s.homepage = "https://github.com/decidim/decidim-module-challenges" - s.required_ruby_version = "~> 2.7.2" + s.required_ruby_version = ">= 3.0.6" s.name = "decidim-challenges" s.summary = "A decidim challenges module" diff --git a/lib/decidim/challenges/version.rb b/lib/decidim/challenges/version.rb index b2e1c7dd..2235d629 100644 --- a/lib/decidim/challenges/version.rb +++ b/lib/decidim/challenges/version.rb @@ -4,7 +4,7 @@ module Decidim # This holds the decidim-meetings version. module Challenges def self.version - "0.2.0" + "0.2.1" end def self.decidim_version From 1907ab5a38d50da160f4d64e8168e401c1248385 Mon Sep 17 00:00:00 2001 From: Nicole Solarz Date: Thu, 28 Sep 2023 12:55:01 +0200 Subject: [PATCH 02/15] Upgrade to Decidim 0.27 --- CHANGELOG.md | 3 + Gemfile | 9 +- Gemfile.lock | 661 ++++++++++-------- .../challenges/admin/create_challenge.rb | 2 +- .../challenges/admin/destroy_challenge.rb | 2 +- .../admin/export_challenge_surveys.rb | 2 +- .../challenges/admin/publish_challenge.rb | 2 +- .../challenges/admin/unpublish_challenge.rb | 2 +- .../challenges/admin/update_challenge.rb | 2 +- .../challenges/admin/update_surveys.rb | 2 +- .../decidim/challenges/survey_challenge.rb | 2 +- .../decidim/problems/admin/create_problem.rb | 2 +- .../decidim/problems/admin/destroy_problem.rb | 2 +- .../decidim/problems/admin/publish_problem.rb | 2 +- .../problems/admin/unpublish_problem.rb | 2 +- .../decidim/problems/admin/update_problem.rb | 2 +- .../solutions/admin/create_solution.rb | 2 +- .../solutions/admin/destroy_solution.rb | 2 +- .../solutions/admin/publish_solution.rb | 2 +- .../solutions/admin/unpublish_solution.rb | 2 +- .../solutions/admin/update_solution.rb | 2 +- .../challenges/challenges_controller.rb | 20 +- .../decidim/problems/problems_controller.rb | 24 +- .../decidim/solutions/solutions_controller.rb | 18 +- app/models/decidim/challenges/challenge.rb | 19 +- app/models/decidim/challenges/survey.rb | 4 +- app/models/decidim/problems/problem.rb | 61 +- app/models/decidim/solutions/solution.rb | 29 +- .../decidim/problems/problem_search.rb | 4 +- .../challenges/challenges/_filters.html.erb | 8 +- .../problems/problems/_filters.html.erb | 12 +- .../sdgs_filter/_filter_selector.html.erb | 4 +- .../solutions/solutions/_filters.html.erb | 6 +- lib/decidim/challenges/version.rb | 4 +- .../decidim/challenges/challenge_cell_spec.rb | 2 +- .../challenges/challenge_m_cell_spec.rb | 2 +- .../decidim/problems/problem_cell_spec.rb | 2 +- .../decidim/problems/problem_m_cell_spec.rb | 2 +- .../decidim/solutions/solution_cell_spec.rb | 2 +- .../decidim/solutions/solution_m_cell_spec.rb | 2 +- .../challenges/admin/permissions_spec.rb | 8 +- .../problems/admin/permissions_spec.rb | 8 +- .../solutions/admin/permissions_spec.rb | 8 +- .../challenges/challenge_search_spec.rb | 20 +- .../decidim/problems/problem_search_spec.rb | 22 +- .../decidim/solutions/solution_search_spec.rb | 18 +- .../challenges/filter_challenges_spec.rb | 16 +- .../decidim/problems/filter_problems_spec.rb | 10 +- .../solutions/filter_solutions_spec.rb | 2 +- 49 files changed, 606 insertions(+), 440 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0d8768b..b08780d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,9 @@ Following Semantic Versioning 2. ## next version: +## Version 0.3.0 (MINOR) +- Increase minimum Decidim version to 0.27.4 + ## Version 0.2.1 (MINOR) - Upgrade module's Ruby to 3.0.6 diff --git a/Gemfile b/Gemfile index eab6ea47..30c9f0a5 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ source "https://rubygems.org" ruby RUBY_VERSION -DECIDIM_VERSION = { git: "https://github.com/decidim/decidim", branch: "release/0.26-stable" }.freeze +DECIDIM_VERSION = { git: "https://github.com/decidim/decidim", branch: "release/0.27-stable" }.freeze gem "decidim", DECIDIM_VERSION gem "decidim-challenges", path: "." @@ -16,6 +16,9 @@ gem "uglifier", "~> 4.1" # More exactly in comments in the homepage and in processes cards in the processes listing gem "nokogiri", "1.13.3" +# temporal solution while gems embrace new psych 4 (the default in Ruby 3.1) behavior. +gem "psych", "< 4" + group :development, :test do gem "byebug", ">= 11.1.3" gem "decidim-dev", DECIDIM_VERSION @@ -28,7 +31,7 @@ group :development do gem "faker" gem "letter_opener_web", "~> 1.3" gem "listen", "~> 3.1" - gem "spring", "~> 2.0" - gem "spring-watcher-listen", "~> 2.0" + gem "spring" + gem "spring-watcher-listen" gem "web-console", "~> 3.5" end diff --git a/Gemfile.lock b/Gemfile.lock index 6a4230ec..bd1a1cb5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,55 +1,55 @@ GIT remote: https://github.com/decidim/decidim - revision: 5043f94d3d98ae81f52c2138a3ad1217286aed18 - branch: release/0.26-stable + revision: 2d0a1fe016da514c4b8df974b949230d958186a2 + branch: release/0.27-stable specs: - decidim (0.26.2) - decidim-accountability (= 0.26.2) - decidim-admin (= 0.26.2) - decidim-api (= 0.26.2) - decidim-assemblies (= 0.26.2) - decidim-blogs (= 0.26.2) - decidim-budgets (= 0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - decidim-debates (= 0.26.2) - decidim-forms (= 0.26.2) - decidim-generators (= 0.26.2) - decidim-meetings (= 0.26.2) - decidim-pages (= 0.26.2) - decidim-participatory_processes (= 0.26.2) - decidim-proposals (= 0.26.2) - decidim-sortitions (= 0.26.2) - decidim-surveys (= 0.26.2) - decidim-system (= 0.26.2) - decidim-templates (= 0.26.2) - decidim-verifications (= 0.26.2) - decidim-accountability (0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - decidim-admin (0.26.2) + 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) active_link_to (~> 1.0) - decidim-core (= 0.26.2) + decidim-core (= 0.27.4) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0) - decidim-api (0.26.2) + decidim-api (0.27.4) graphql (~> 1.12, < 1.13) + graphql-docs (~> 2.1.0) 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) redcarpet (~> 3.5, >= 3.5.1) - decidim-assemblies (0.26.2) - decidim-core (= 0.26.2) - decidim-blogs (0.26.2) - decidim-admin (= 0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - decidim-budgets (0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - decidim-comments (0.26.2) - decidim-core (= 0.26.2) - redcarpet (~> 3.5, >= 3.5.1) - decidim-core (0.26.2) + decidim-core (0.27.4) active_link_to (~> 1.0) acts_as_list (~> 0.9) batch-loader (~> 1.2) @@ -58,21 +58,21 @@ GIT cells-erb (~> 0.1.0) cells-rails (~> 0.1.3) charlock_holmes (~> 0.7) - date_validator (~> 0.9.0) - decidim-api (= 0.26.2) + date_validator (~> 0.12.0) + decidim-api (= 0.27.4) devise (~> 4.7) devise-i18n (~> 1.2) diffy (~> 3.3) doorkeeper (~> 5.1) doorkeeper-i18n (~> 4.0) - file_validators (~> 2.1) + file_validators (~> 3.0) fog-local (~> 0.6) - foundation_rails_helper - geocoder (~> 1.7.5) + foundation_rails_helper (~> 4.0) + geocoder (~> 1.8) hashdiff (>= 0.4.0, < 2.0.0) invisible_captcha (~> 0.12) kaminari (~> 1.2, >= 1.2.1) - loofah (~> 2.3.1) + loofah (~> 2.19.0) mime-types (>= 1.16, < 4.0) mini_magick (~> 4.9) mustache (~> 1.1.0) @@ -87,132 +87,133 @@ GIT premailer-rails (~> 1.10) rack (~> 2.2, >= 2.2.3) rack-attack (~> 6.0) - rails (~> 6.0.4) + rails (~> 6.1.0) rails-i18n (~> 6.0) ransack (~> 2.4.1) - rectify (~> 0.13.0) redis (~> 4.1) request_store (~> 1.5.0) rubyXL (~> 3.4) rubyzip (~> 2.0) - searchlight (~> 4.1) 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) wisper (~> 2.0) - decidim-debates (0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - decidim-dev (0.26.2) + 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) byebug (~> 11.0) capybara (~> 3.24) db-query-matchers (~> 0.10.0) - decidim (= 0.26.2) + decidim (= 0.27.4) erb_lint (~> 0.0.35) factory_bot_rails (~> 4.8) i18n-tasks (~> 0.9.18) mdl (~> 0.5) - nokogiri (~> 1.12) + nokogiri (~> 1.13) + parallel_tests (~> 3.7) puma (~> 5.0) rails-controller-testing (~> 1.0) - rspec-cells (~> 0.3.4) + rspec-cells (~> 0.3.7) rspec-html-matchers (~> 0.9.1) rspec-rails (~> 4.0) rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.3.0) - rubocop (~> 0.92.0) - rubocop-rails (~> 2.8) - rubocop-rspec (= 1.43.2) - selenium-webdriver (~> 3.142) - simplecov (~> 0.19.0) - simplecov-cobertura (~> 1.3.1) - system_test_html_screenshots (~> 0.2) + rubocop (~> 1.28.0) + rubocop-rails (~> 2.14) + rubocop-rspec (~> 2.10) + selenium-webdriver (~> 4.1.0) + simplecov (~> 0.21.0) + simplecov-cobertura (~> 2.1.0) w3c_rspec_validators (~> 0.3.0) webmock (~> 3.6) wisper-rspec (~> 1.0) - decidim-forms (0.26.2) - decidim-core (= 0.26.2) + decidim-forms (0.27.4) + decidim-core (= 0.27.4) wicked_pdf (~> 2.1) wkhtmltopdf-binary (~> 0.12) - decidim-generators (0.26.2) - decidim-core (= 0.26.2) - decidim-meetings (0.26.2) - decidim-core (= 0.26.2) - decidim-forms (= 0.26.2) + 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) icalendar (~> 2.5) - decidim-pages (0.26.2) - decidim-core (= 0.26.2) - decidim-participatory_processes (0.26.2) - decidim-core (= 0.26.2) - decidim-proposals (0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - doc2text (~> 0.4.4) + 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) redcarpet (~> 3.5, >= 3.5.1) - decidim-sortitions (0.26.2) - decidim-admin (= 0.26.2) - decidim-comments (= 0.26.2) - decidim-core (= 0.26.2) - decidim-proposals (= 0.26.2) - decidim-surveys (0.26.2) - decidim-core (= 0.26.2) - decidim-forms (= 0.26.2) - decidim-templates (= 0.26.2) - decidim-system (0.26.2) + 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) active_link_to (~> 1.0) - decidim-core (= 0.26.2) + decidim-core (= 0.27.4) devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 2.0) - decidim-templates (0.26.2) - decidim-core (= 0.26.2) - decidim-forms (= 0.26.2) - decidim-verifications (0.26.2) - decidim-core (= 0.26.2) + 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) PATH remote: . specs: - decidim-challenges (0.2.1) - decidim-core (~> 0.26.2) + decidim-challenges (0.3.0) + decidim-core (~> 0.27) GEM remote: https://rubygems.org/ specs: - actioncable (6.0.5.1) - actionpack (= 6.0.5.1) + 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.0.5.1) - actionpack (= 6.0.5.1) - activejob (= 6.0.5.1) - activerecord (= 6.0.5.1) - activestorage (= 6.0.5.1) - activesupport (= 6.0.5.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.0.5.1) - actionpack (= 6.0.5.1) - actionview (= 6.0.5.1) - activejob (= 6.0.5.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.0.5.1) - actionview (= 6.0.5.1) - activesupport (= 6.0.5.1) - rack (~> 2.0, >= 2.0.8) + 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.0.5.1) - actionpack (= 6.0.5.1) - activerecord (= 6.0.5.1) - activestorage (= 6.0.5.1) - activesupport (= 6.0.5.1) + 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.0.5.1) - activesupport (= 6.0.5.1) + actionview (6.1.7.6) + activesupport (= 6.1.7.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -220,31 +221,33 @@ GEM active_link_to (1.0.5) actionpack addressable - activejob (6.0.5.1) - activesupport (= 6.0.5.1) + activejob (6.1.7.6) + activesupport (= 6.1.7.6) globalid (>= 0.3.6) - activemodel (6.0.5.1) - activesupport (= 6.0.5.1) - activerecord (6.0.5.1) - activemodel (= 6.0.5.1) - activesupport (= 6.0.5.1) - activestorage (6.0.5.1) - actionpack (= 6.0.5.1) - activejob (= 6.0.5.1) - activerecord (= 6.0.5.1) + 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) - activesupport (6.0.5.1) + mini_mime (>= 1.1.0) + activesupport (6.1.7.6) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.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.1) + addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - axe-core-api (4.4.1) + axe-core-api (4.7.0) dumb_delegator virtus axe-core-rspec (4.1.0) @@ -255,8 +258,9 @@ GEM descendants_tracker (~> 0.0.4) ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) + base64 (0.1.1) batch-loader (1.5.0) - bcrypt (3.1.18) + bcrypt (3.1.19) better_html (1.0.16) actionview (>= 4.0) activesupport (>= 4.0) @@ -266,12 +270,12 @@ GEM parser (>= 2.4) smart_properties bindex (0.8.1) - bootsnap (1.13.0) + bootsnap (1.16.0) msgpack (~> 1.2) browser (2.7.1) builder (3.2.4) byebug (11.1.3) - capybara (3.37.1) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) @@ -280,7 +284,7 @@ GEM rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) - carrierwave (2.2.2) + carrierwave (2.2.4) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) @@ -300,9 +304,9 @@ GEM actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.7) - chef-utils (17.10.0) + chef-utils (18.3.0) concurrent-ruby - childprocess (3.0.0) + childprocess (4.1.0) coercible (1.0.0) descendants_tracker (~> 0.0.1) coffee-rails (5.0.0) @@ -312,15 +316,17 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.10) + commonmarker (0.23.10) + concurrent-ruby (1.2.2) crack (0.4.5) rexml crass (1.0.6) - css_parser (1.11.0) + css_parser (1.16.0) addressable - date_validator (0.9.0) - activemodel - activesupport + date (3.3.3) + date_validator (0.12.0) + activemodel (>= 3) + activesupport (>= 3) db-query-matchers (0.10.0) activesupport (>= 4.0, < 7) rspec (~> 3.0) @@ -329,28 +335,27 @@ GEM declarative-option (0.1.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (4.8.1) + devise (4.9.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.10.2) - devise (>= 4.8.0) - devise_invitable (2.0.6) + devise-i18n (1.11.0) + devise (>= 4.9.0) + devise_invitable (2.0.8) actionmailer (>= 5.0) devise (>= 4.6) diff-lcs (1.5.0) diffy (3.4.2) - doc2text (0.4.5) - nokogiri (>= 1.13.2, < 1.14.0) + doc2text (0.4.6) + nokogiri (>= 1.13.2, < 1.15.0) rubyzip (~> 2.3.0) docile (1.4.0) - doorkeeper (5.5.4) + doorkeeper (5.6.6) railties (>= 5) doorkeeper-i18n (4.0.1) dumb_delegator (1.0.0) - equalizer (0.0.11) erb_lint (0.0.37) activesupport better_html (~> 1.0.7) @@ -361,22 +366,26 @@ GEM smart_properties erbse (0.1.4) temple - erubi (1.11.0) - excon (0.92.4) - execjs (2.8.1) + erubi (1.12.0) + escape_utils (1.3.0) + excon (0.103.0) + execjs (2.9.1) + 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.22.0) + faker (3.2.1) i18n (>= 1.8.11, < 2) - faraday (2.5.2) + faraday (2.7.11) + base64 faraday-net_http (>= 2.0, < 3.1) ruby2_keywords (>= 0.0.4) - faraday-net_http (3.0.0) - ffi (1.15.5) - file_validators (2.3.0) + faraday-net_http (3.0.2) + ffi (1.16.2) + file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) fog-core (2.3.0) @@ -392,16 +401,29 @@ GEM activemodel (>= 4.1, < 7.1) activesupport (>= 4.1, < 7.1) railties (>= 4.1, < 7.1) - geocoder (1.7.5) - globalid (1.0.0) - activesupport (>= 5.0) + gemoji (3.0.1) + geocoder (1.8.2) + globalid (1.2.1) + activesupport (>= 6.1) graphql (1.12.24) + graphql-docs (2.1.0) + commonmarker (~> 0.16) + escape_utils (~> 1.2) + extended-markdown-filter (~> 0.4) + gemoji (~> 3.0) + graphql (~> 1.12) + html-pipeline (~> 2.9) + sass (~> 3.4) hashdiff (1.0.1) hashie (5.0.0) - highline (2.0.3) + highline (2.1.0) + hkdf (0.3.0) + html-pipeline (2.14.3) + activesupport (>= 2) + nokogiri (>= 1.4) html_tokenizer (0.0.7) htmlentities (4.3.4) - i18n (1.12.0) + i18n (1.14.1) concurrent-ruby (~> 1.0) i18n-tasks (0.9.37) activesupport (>= 4.0.2) @@ -413,7 +435,7 @@ GEM rails-i18n rainbow (>= 2.2.2, < 4.0) terminal-table (>= 1.5.1) - icalendar (2.8.0) + icalendar (2.9.0) ice_cube (~> 0.16) ice_cube (0.16.4) ice_nine (0.11.2) @@ -422,8 +444,8 @@ GEM ruby-vips (>= 2.0.17, < 3) invisible_captcha (0.13.0) rails (>= 3.2.0) - json (2.6.2) - jwt (2.5.0) + json (2.6.3) + jwt (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -440,82 +462,90 @@ GEM rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - launchy (2.5.0) - addressable (~> 2.7) + launchy (2.5.2) + addressable (~> 2.8) letter_opener (1.8.1) launchy (>= 2.2, < 3) letter_opener_web (1.4.1) actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) - listen (3.7.1) + listen (3.8.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.3.1) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) - mdl (0.11.0) + 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.4.1) + mime-types (3.5.1) mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) - mini_magick (4.11.0) - mini_mime (1.1.2) - mini_portile2 (2.8.0) - minitest (5.16.3) + mime-types-data (3.2023.0808) + mini_magick (4.12.0) + mini_mime (1.1.5) + minitest (5.20.0) mixlib-cli (2.1.8) mixlib-config (3.0.27) tomlrb mixlib-shellout (3.2.7) chef-utils - msgpack (1.5.5) - multi_json (1.15.0) + msgpack (1.7.2) multi_xml (0.6.0) mustache (1.1.1) - nio4r (2.5.8) - nokogiri (1.13.3) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) + net-imap (0.3.7) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout + net-smtp (0.4.0) + net-protocol + nio4r (2.5.9) nokogiri (1.13.3-x86_64-linux) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) snaky_hash (~> 2.0) version_gem (~> 1.1) - oauth-tty (1.0.2) - version_gem (~> 1.1) - oauth2 (1.4.10) + oauth-tty (1.0.5) + version_gem (~> 1.1, >= 1.1.1) + oauth2 (2.0.9) faraday (>= 0.17.3, < 3.0) jwt (>= 1.0, < 3.0) - multi_json (~> 1.3) multi_xml (~> 0.5) - rack (>= 1.2, < 3) - omniauth (2.1.0) + rack (>= 1.2, < 4) + snaky_hash (~> 2.0) + version_gem (~> 1.1) + omniauth (2.1.1) hashie (>= 3.4.6) rack (>= 2.2.3) rack-protection omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (1.0.1) + omniauth-google-oauth2 (1.1.1) jwt (>= 2.0) - oauth2 (~> 1.1) + oauth2 (~> 2.0.6) omniauth (~> 2.0) - omniauth-oauth2 (~> 1.7.1) + omniauth-oauth2 (~> 1.8.0) omniauth-oauth (1.2.0) oauth omniauth (>= 1.0, < 3) - omniauth-oauth2 (1.7.3) + omniauth-oauth2 (1.8.0) oauth2 (>= 1.4, < 3) - omniauth (>= 1.9, < 3) + omniauth (~> 2.0) omniauth-rails_csrf_protection (1.0.1) actionpack (>= 4.2) omniauth (~> 2.0) @@ -527,109 +557,109 @@ GEM activerecord (>= 5.2) request_store (~> 1.1) parallel (1.23.0) - parser (3.2.2.0) + parallel_tests (3.13.0) + parallel + parser (3.2.2.3) ast (~> 2.4.1) + racc pg (1.1.4) pg_search (2.3.6) activerecord (>= 5.2) activesupport (>= 5.2) - premailer (1.16.0) + premailer (1.21.0) addressable - css_parser (>= 1.6.0) + css_parser (>= 1.12.0) htmlentities (>= 4.0.0) - premailer-rails (1.11.1) + premailer-rails (1.12.0) actionmailer (>= 3) + net-smtp premailer (~> 1.7, >= 1.7.9) - public_suffix (5.0.0) - puma (5.6.5) + psych (3.3.4) + public_suffix (5.0.3) + puma (5.6.7) nio4r (~> 2.0) - racc (1.6.0) - rack (2.2.4) - rack-attack (6.6.1) - rack (>= 1.0, < 3) + racc (1.7.1) + rack (2.2.8) + rack-attack (6.7.0) + rack (>= 1.0, < 4) rack-cors (1.1.1) rack (>= 2.0.0) - rack-protection (2.2.2) + rack-protection (3.1.0) + rack (~> 2.2, >= 2.2.4) + rack-proxy (0.7.7) rack - rack-proxy (0.7.2) - rack - rack-test (2.0.2) + rack-test (2.1.0) rack (>= 1.3) - rails (6.0.5.1) - actioncable (= 6.0.5.1) - actionmailbox (= 6.0.5.1) - actionmailer (= 6.0.5.1) - actionpack (= 6.0.5.1) - actiontext (= 6.0.5.1) - actionview (= 6.0.5.1) - activejob (= 6.0.5.1) - activemodel (= 6.0.5.1) - activerecord (= 6.0.5.1) - activestorage (= 6.0.5.1) - activesupport (= 6.0.5.1) - bundler (>= 1.3.0) - railties (= 6.0.5.1) + 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) + bundler (>= 1.15.0) + railties (= 6.1.7.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.0.5.1) - actionpack (= 6.0.5.1) - activesupport (= 6.0.5.1) + railties (6.1.7.6) + actionpack (= 6.1.7.6) + activesupport (= 6.1.7.6) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + 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) i18n - rb-fsevent (0.11.1) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - rectify (0.13.0) - activemodel (>= 4.1.0) - activerecord (>= 4.1.0) - activesupport (>= 4.1.0) - virtus (~> 1.0.5) - wisper (>= 1.6.1) - redcarpet (3.5.1) - redis (4.8.0) - regexp_parser (2.8.0) + redcarpet (3.6.0) + redis (4.8.1) + regexp_parser (2.8.1) request_store (1.5.1) rack (>= 1.4) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) - rexml (3.2.5) - rspec (3.11.0) - rspec-core (~> 3.11.0) - rspec-expectations (~> 3.11.0) - rspec-mocks (~> 3.11.0) - rspec-cells (0.3.7) + responders (3.1.0) + 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) cells (>= 4.0.0, < 6.0.0) - rspec-rails (< 6.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec-rails (>= 3.0.0, < 6.1.0) + rspec-core (3.12.2) + rspec-support (~> 3.12.0) + rspec-expectations (3.12.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) + rspec-support (~> 3.12.0) rspec-html-matchers (0.9.4) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.11.1) + rspec-mocks (3.12.6) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) + rspec-support (~> 3.12.0) rspec-rails (4.1.2) actionpack (>= 4.2) activesupport (>= 4.2) @@ -640,26 +670,26 @@ GEM rspec-support (~> 3.10) rspec-retry (0.6.2) rspec-core (> 3.3) - rspec-support (3.11.0) + rspec-support (3.12.1) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.92.0) + rubocop (1.28.2) parallel (~> 1.10) - parser (>= 2.7.1.5) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.7) + regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 0.5.0) + rubocop-ast (>= 1.17.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 2.0) - rubocop-ast (1.28.0) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.29.0) parser (>= 3.2.1.0) - rubocop-rails (2.9.1) + rubocop-rails (2.15.2) activesupport (>= 4.2.0) rack (>= 1.1) - rubocop (>= 0.90.0, < 2.0) - rubocop-rspec (1.43.2) - rubocop (~> 0.87) + rubocop (>= 1.7.0, < 2.0) + rubocop-rspec (2.11.1) + rubocop (~> 1.19) ruby-progressbar (1.13.0) ruby-vips (2.1.4) ffi (~> 1.12) @@ -668,60 +698,66 @@ GEM nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) rubyzip (2.3.2) - searchlight (4.1.0) - selenium-webdriver (3.142.7) - childprocess (>= 0.5, < 4.0) + 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.1.0) + childprocess (>= 0.5, < 5.0) + rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) semantic_range (3.0.0) seven_zip_ruby (1.3.0) - simplecov (0.19.1) + simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) - simplecov-cobertura (1.3.1) - simplecov (~> 0.8) + simplecov_json_formatter (~> 0.1) + simplecov-cobertura (2.1.0) + rexml + simplecov (~> 0.19) simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) smart_properties (1.17.0) - snaky_hash (2.0.0) + snaky_hash (2.0.1) hashie - version_gem (~> 1.1) + version_gem (~> 1.1, >= 1.1.1) social-share-button (1.2.4) coffee-rails - spring (2.1.1) - spring-watcher-listen (2.0.1) + spring (4.1.1) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) - sprockets (4.1.1) + spring (>= 4) + sprockets (4.2.1) concurrent-ruby (~> 1.0) - rack (> 1, < 3) + 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) - system_test_html_screenshots (0.2.0) - actionpack (>= 5.2, < 6.1.a) - temple (0.8.2) + ssrf_filter (1.1.2) + temple (0.10.2) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thor (1.2.1) + thor (1.2.2) thread_safe (0.3.6) - tilt (2.0.11) + tilt (2.3.0) + timeout (0.4.0) tomlrb (2.0.3) - tzinfo (1.2.10) - thread_safe (~> 0.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) uber (0.1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) - unicode-display_width (1.8.0) + unicode-display_width (2.4.2) valid_email2 (2.3.1) activemodel (>= 3.2) mail (~> 2.5) - version_gem (1.1.0) - virtus (1.0.5) + version_gem (1.1.3) + virtus (2.0.0) axiom-types (~> 0.1) coercible (~> 1.0) descendants_tracker (~> 0.0, >= 0.0.3) - equalizer (~> 0.0, >= 0.0.9) w3c_rspec_validators (0.3.0) rails rspec @@ -737,7 +773,7 @@ GEM activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webmock (3.18.1) + webmock (3.19.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) @@ -746,20 +782,22 @@ GEM rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - websocket-driver (0.7.5) + webpush (1.1.0) + hkdf (~> 0.2) + jwt (~> 2.0) + websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - wicked_pdf (2.6.3) + wicked_pdf (2.7.0) activesupport wisper (2.0.1) wisper-rspec (1.1.0) - wkhtmltopdf-binary (0.12.6.5) + wkhtmltopdf-binary (0.12.6.6) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.0) + zeitwerk (2.6.12) PLATFORMS - ruby x86_64-linux DEPENDENCIES @@ -772,12 +810,13 @@ DEPENDENCIES letter_opener_web (~> 1.3) listen (~> 3.1) nokogiri (= 1.13.3) + psych (< 4) puma (>= 4.3) rubocop rubocop-rails rubocop-rspec - spring (~> 2.0) - spring-watcher-listen (~> 2.0) + spring + spring-watcher-listen uglifier (~> 4.1) web-console (~> 3.5) @@ -785,4 +824,4 @@ RUBY VERSION ruby 3.0.6p216 BUNDLED WITH - 2.3.6 + 2.2.33 diff --git a/app/commands/decidim/challenges/admin/create_challenge.rb b/app/commands/decidim/challenges/admin/create_challenge.rb index e7c052f1..37600f65 100644 --- a/app/commands/decidim/challenges/admin/create_challenge.rb +++ b/app/commands/decidim/challenges/admin/create_challenge.rb @@ -4,7 +4,7 @@ module Decidim module Challenges module Admin # A command with all the business logic when a user creates a new challenge. - class CreateChallenge < Rectify::Command + class CreateChallenge < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. diff --git a/app/commands/decidim/challenges/admin/destroy_challenge.rb b/app/commands/decidim/challenges/admin/destroy_challenge.rb index 9b684f4a..ec6dd44c 100644 --- a/app/commands/decidim/challenges/admin/destroy_challenge.rb +++ b/app/commands/decidim/challenges/admin/destroy_challenge.rb @@ -4,7 +4,7 @@ module Decidim module Challenges module Admin # This command deals with destroying a Challenge from the admin panel. - class DestroyChallenge < Rectify::Command + class DestroyChallenge < Decidim::Command # Public: Initializes the command. # # page - The Challenge to be destroyed. diff --git a/app/commands/decidim/challenges/admin/export_challenge_surveys.rb b/app/commands/decidim/challenges/admin/export_challenge_surveys.rb index f2bc3520..2a466e2f 100644 --- a/app/commands/decidim/challenges/admin/export_challenge_surveys.rb +++ b/app/commands/decidim/challenges/admin/export_challenge_surveys.rb @@ -5,7 +5,7 @@ module Challenges module Admin # This command is executed when the user exports the registrations of # a Meeting from the admin panel. - class ExportChallengeSurveys < Rectify::Command + class ExportChallengeSurveys < Decidim::Command # challenge - The current instance of the page to be closed. # format - a string representing the export format # current_user - the user performing the action diff --git a/app/commands/decidim/challenges/admin/publish_challenge.rb b/app/commands/decidim/challenges/admin/publish_challenge.rb index 4255a5dd..b4807af9 100644 --- a/app/commands/decidim/challenges/admin/publish_challenge.rb +++ b/app/commands/decidim/challenges/admin/publish_challenge.rb @@ -4,7 +4,7 @@ module Decidim module Challenges module Admin # A command that sets a challenge as published. - class PublishChallenge < Rectify::Command + class PublishChallenge < Decidim::Command # Public: Initializes the command. # # challenge - A Challenge that will be published diff --git a/app/commands/decidim/challenges/admin/unpublish_challenge.rb b/app/commands/decidim/challenges/admin/unpublish_challenge.rb index eddeca6e..55ecce27 100644 --- a/app/commands/decidim/challenges/admin/unpublish_challenge.rb +++ b/app/commands/decidim/challenges/admin/unpublish_challenge.rb @@ -4,7 +4,7 @@ module Decidim module Challenges module Admin # A command that sets a challenge as unpublished. - class UnpublishChallenge < Rectify::Command + class UnpublishChallenge < Decidim::Command # Public: Initializes the command. # # challenge - A Challenge that will be published diff --git a/app/commands/decidim/challenges/admin/update_challenge.rb b/app/commands/decidim/challenges/admin/update_challenge.rb index 38b77d48..a2039aa9 100644 --- a/app/commands/decidim/challenges/admin/update_challenge.rb +++ b/app/commands/decidim/challenges/admin/update_challenge.rb @@ -4,7 +4,7 @@ module Decidim module Challenges module Admin # A command with all the business logic when a user updates a challenge. - class UpdateChallenge < Rectify::Command + class UpdateChallenge < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. diff --git a/app/commands/decidim/challenges/admin/update_surveys.rb b/app/commands/decidim/challenges/admin/update_surveys.rb index a9eadc6c..19abb39c 100644 --- a/app/commands/decidim/challenges/admin/update_surveys.rb +++ b/app/commands/decidim/challenges/admin/update_surveys.rb @@ -4,7 +4,7 @@ module Decidim module Challenges module Admin # This command is executed when the user updates the challenge survey, - class UpdateSurveys < Rectify::Command + class UpdateSurveys < Decidim::Command # Initializes a UpdateSurveys Command. # # form - The form from which to get the data. diff --git a/app/commands/decidim/challenges/survey_challenge.rb b/app/commands/decidim/challenges/survey_challenge.rb index fa590e27..0f640865 100644 --- a/app/commands/decidim/challenges/survey_challenge.rb +++ b/app/commands/decidim/challenges/survey_challenge.rb @@ -3,7 +3,7 @@ module Decidim module Challenges # This command is executed when the user answer a survey. - class SurveyChallenge < Rectify::Command + class SurveyChallenge < Decidim::Command # Initializes a SurveyChallenge Command. # # challenge - The current instance of the challenge to be answer the survey. diff --git a/app/commands/decidim/problems/admin/create_problem.rb b/app/commands/decidim/problems/admin/create_problem.rb index 874079bb..d2e10898 100644 --- a/app/commands/decidim/problems/admin/create_problem.rb +++ b/app/commands/decidim/problems/admin/create_problem.rb @@ -4,7 +4,7 @@ module Decidim module Problems module Admin # A command with all the business logic when a user creates a new problem. - class CreateProblem < Rectify::Command + class CreateProblem < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. diff --git a/app/commands/decidim/problems/admin/destroy_problem.rb b/app/commands/decidim/problems/admin/destroy_problem.rb index 166b8382..dd6940ee 100644 --- a/app/commands/decidim/problems/admin/destroy_problem.rb +++ b/app/commands/decidim/problems/admin/destroy_problem.rb @@ -4,7 +4,7 @@ module Decidim module Problems module Admin # This command deals with destroying a Problem from the admin panel. - class DestroyProblem < Rectify::Command + class DestroyProblem < Decidim::Command # Public: Initializes the command. # # page - The Problem to be destroyed. diff --git a/app/commands/decidim/problems/admin/publish_problem.rb b/app/commands/decidim/problems/admin/publish_problem.rb index ac007eb7..202a55f1 100644 --- a/app/commands/decidim/problems/admin/publish_problem.rb +++ b/app/commands/decidim/problems/admin/publish_problem.rb @@ -4,7 +4,7 @@ module Decidim module Problems module Admin # A command that sets a problem as published. - class PublishProblem < Rectify::Command + class PublishProblem < Decidim::Command # Public: Initializes the command. # # problem - A Problem that will be published diff --git a/app/commands/decidim/problems/admin/unpublish_problem.rb b/app/commands/decidim/problems/admin/unpublish_problem.rb index 56bc7511..83523cb0 100644 --- a/app/commands/decidim/problems/admin/unpublish_problem.rb +++ b/app/commands/decidim/problems/admin/unpublish_problem.rb @@ -4,7 +4,7 @@ module Decidim module Problems module Admin # A command that sets a problem as unpublished. - class UnpublishProblem < Rectify::Command + class UnpublishProblem < Decidim::Command # Public: Initializes the command. # # problem - A Problem that will be published diff --git a/app/commands/decidim/problems/admin/update_problem.rb b/app/commands/decidim/problems/admin/update_problem.rb index 88010230..c22d8406 100644 --- a/app/commands/decidim/problems/admin/update_problem.rb +++ b/app/commands/decidim/problems/admin/update_problem.rb @@ -4,7 +4,7 @@ module Decidim module Problems module Admin # A command with all the business logic when a user updates a Problem. - class UpdateProblem < Rectify::Command + class UpdateProblem < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. diff --git a/app/commands/decidim/solutions/admin/create_solution.rb b/app/commands/decidim/solutions/admin/create_solution.rb index ebb58e79..9fa2f8d9 100644 --- a/app/commands/decidim/solutions/admin/create_solution.rb +++ b/app/commands/decidim/solutions/admin/create_solution.rb @@ -4,7 +4,7 @@ module Decidim module Solutions module Admin # A command with all the business logic when a user creates a new solution. - class CreateSolution < Rectify::Command + class CreateSolution < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. diff --git a/app/commands/decidim/solutions/admin/destroy_solution.rb b/app/commands/decidim/solutions/admin/destroy_solution.rb index 66156356..b071dd61 100644 --- a/app/commands/decidim/solutions/admin/destroy_solution.rb +++ b/app/commands/decidim/solutions/admin/destroy_solution.rb @@ -4,7 +4,7 @@ module Decidim module Solutions module Admin # This command deals with destroying a Solution from the admin panel. - class DestroySolution < Rectify::Command + class DestroySolution < Decidim::Command # Public: Initializes the command. # # page - The Solution to be destroyed. diff --git a/app/commands/decidim/solutions/admin/publish_solution.rb b/app/commands/decidim/solutions/admin/publish_solution.rb index 7c7cee45..c0b249f0 100644 --- a/app/commands/decidim/solutions/admin/publish_solution.rb +++ b/app/commands/decidim/solutions/admin/publish_solution.rb @@ -4,7 +4,7 @@ module Decidim module Solutions module Admin # A command that sets a solution as published. - class PublishSolution < Rectify::Command + class PublishSolution < Decidim::Command # Public: Initializes the command. # # solution - A Solution that will be published diff --git a/app/commands/decidim/solutions/admin/unpublish_solution.rb b/app/commands/decidim/solutions/admin/unpublish_solution.rb index f07c0d4e..66f276d4 100644 --- a/app/commands/decidim/solutions/admin/unpublish_solution.rb +++ b/app/commands/decidim/solutions/admin/unpublish_solution.rb @@ -4,7 +4,7 @@ module Decidim module Solutions module Admin # A command that sets a solution as unpublished. - class UnpublishSolution < Rectify::Command + class UnpublishSolution < Decidim::Command # Public: Initializes the command. # # solution - A Solution that will be published diff --git a/app/commands/decidim/solutions/admin/update_solution.rb b/app/commands/decidim/solutions/admin/update_solution.rb index 8bf77391..dcdb2542 100644 --- a/app/commands/decidim/solutions/admin/update_solution.rb +++ b/app/commands/decidim/solutions/admin/update_solution.rb @@ -4,7 +4,7 @@ module Decidim module Solutions module Admin # A command with all the business logic when a user updates a Solution. - class UpdateSolution < Rectify::Command + class UpdateSolution < Decidim::Command # Public: Initializes the command. # # form - A form object with the params. diff --git a/app/controllers/decidim/challenges/challenges_controller.rb b/app/controllers/decidim/challenges/challenges_controller.rb index 0a3bbe96..9fe1b913 100644 --- a/app/controllers/decidim/challenges/challenges_controller.rb +++ b/app/controllers/decidim/challenges/challenges_controller.rb @@ -38,12 +38,12 @@ def challenge_scope def default_filter_params { - search_text: "", - category_id: default_filter_category_params, - state: %w(proposal execution finished), - scope_id: default_filter_scope_params, - related_to: "", - sdgs_codes: [], + search_text_cont: "", + with_any_category_id: default_filter_category_params, + with_any_state: %w(proposal execution finished), + with_any_scope_id: default_filter_scope_params, + with_related_to: "", + sdgs_codes_cont: [], } end @@ -64,12 +64,12 @@ def default_filter_scope_params end def challenges - @challenges ||= paginate(search.results.published) + @challenges ||= paginate(search.result) end - def search_klass - Decidim::Challenges::ChallengeSearch + def search_collection + ::Decidim::Challenges::Challenge.published end end end -end +end \ No newline at end of file diff --git a/app/controllers/decidim/problems/problems_controller.rb b/app/controllers/decidim/problems/problems_controller.rb index c45de3ed..e52d0c88 100644 --- a/app/controllers/decidim/problems/problems_controller.rb +++ b/app/controllers/decidim/problems/problems_controller.rb @@ -36,14 +36,14 @@ def challenge_scope def default_filter_params { - search_text: "", - category_id: default_filter_category_params, - state: %w(proposal execution finished), - sectorial_scope_id: default_filter_scope_params, - technological_scope_id: default_filter_scope_params, - territorial_scope_id: default_filter_scope_params, - related_to: "", - sdgs_codes: [], + search_text_cont: "", + with_any_category_id: default_filter_category_params, + with_any_state: %w(proposal execution finished), + with_any_sectorial_scope_id: default_filter_scope_params, + with_any_technological_scope_id: default_filter_scope_params, + with_any_territorial_scope_id: default_filter_scope_params, + with_related_to: "", + sdgs_codes_cont: [], } end @@ -64,12 +64,12 @@ def default_filter_scope_params end def problems - @problems ||= paginate(search.results.published) + @problems ||= paginate(search.result) end - def search_klass - Decidim::Problems::ProblemSearch + def search_collection + ::Decidim::Problems::Problem.published end end end -end +end \ No newline at end of file diff --git a/app/controllers/decidim/solutions/solutions_controller.rb b/app/controllers/decidim/solutions/solutions_controller.rb index bd3880f4..669d17e7 100644 --- a/app/controllers/decidim/solutions/solutions_controller.rb +++ b/app/controllers/decidim/solutions/solutions_controller.rb @@ -36,11 +36,11 @@ def show def default_filter_params { - search_text: "", - category_id: default_filter_category_params, - territorial_scope_id: default_filter_scope_params, - related_to: "", - sdgs_codes: [], + search_text_cont: "", + with_any_category_id: default_filter_category_params, + with_any_territorial_scope_id: default_filter_scope_params, + with_related_to: "", + sdgs_codes_cont: [], } end @@ -61,7 +61,7 @@ def default_filter_scope_params end def solutions - @solutions ||= paginate(search.results.published) + @solutions ||= paginate(search.result) end def solution @@ -89,9 +89,9 @@ def technological_scope @technological_scope ||= current_organization.scopes.find_by(id: @solution.problem.decidim_technological_scope_id) end - def search_klass - Decidim::Solutions::SolutionSearch + def search_collection + ::Decidim::Solutions::Solution.published end end end -end +end \ No newline at end of file diff --git a/app/models/decidim/challenges/challenge.rb b/app/models/decidim/challenges/challenge.rb index 5cdfa7cd..fa207afd 100644 --- a/app/models/decidim/challenges/challenge.rb +++ b/app/models/decidim/challenges/challenge.rb @@ -5,6 +5,7 @@ module Challenges # The data store for a Challenge in the Decidim::Challenges component. class Challenge < Decidim::ApplicationRecord include Decidim::HasComponent + include Decidim::FilterableResource include Decidim::Loggable include Decidim::Publicable include Decidim::Resourceable @@ -42,6 +43,22 @@ class Challenge < Decidim::ApplicationRecord scope :in_execution, -> { where(state: VALID_STATES.index(:execution)) } scope :in_finished, -> { where(state: VALID_STATES.index(:finished)) } + scope :with_any_state, lambda { |*values| + where(state: Array(values).map(&:to_sym) & VALID_STATES) + } + + scope :search_text_cont, lambda { |search_text| + where("title ->> '#{I18n.locale}' ILIKE ?", "%#{search_text}%") + } + + scope :with_sdgs_codes, lambda { |sdgs_codes| + where(sdg_code: sdgs_codes) + } + + def self.ransackable_scopes(_auth_object = nil) + [:with_any_state, :search_text_cont, :with_sdgs_codes] + end + searchable_fields({ scope_id: :decidim_scope_id, participatory_space: :itself, @@ -61,4 +78,4 @@ def published? def remove_card_image; end end end -end +end \ No newline at end of file diff --git a/app/models/decidim/challenges/survey.rb b/app/models/decidim/challenges/survey.rb index ea6d1234..4a8344f9 100644 --- a/app/models/decidim/challenges/survey.rb +++ b/app/models/decidim/challenges/survey.rb @@ -4,7 +4,7 @@ module Decidim module Challenges # The data store for a Survey in the Decidim::Challenges component. class Survey < Decidim::ApplicationRecord - include Decidim::DataPortability + include Decidim::DownloadYourData belongs_to :challenge, foreign_key: "decidim_challenge_id", class_name: "Decidim::Challenges::Challenge" belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User" @@ -12,7 +12,7 @@ class Survey < Decidim::ApplicationRecord validates :user, uniqueness: { scope: :challenge } def self.export_serializer - Decidim::Challenges::DataPortabilitySurveySerializer + Decidim::Challenges::DownloadYourDataSurveySerializer end end end diff --git a/app/models/decidim/problems/problem.rb b/app/models/decidim/problems/problem.rb index 7a629731..e6a0e300 100644 --- a/app/models/decidim/problems/problem.rb +++ b/app/models/decidim/problems/problem.rb @@ -5,6 +5,7 @@ module Problems # The data store for a Problem in the Decidim::Problems component. class Problem < Decidim::ApplicationRecord include Decidim::HasComponent + include Decidim::FilterableResource include Decidim::Loggable include Decidim::Publicable include Decidim::Resourceable @@ -37,6 +38,64 @@ class Problem < Decidim::ApplicationRecord scope :in_execution, -> { where(state: VALID_STATES.index(:execution)) } scope :in_finished, -> { where(state: VALID_STATES.index(:finished)) } + scope :with_any_state, lambda { |*values| + where(state: Array(values).map(&:to_sym) & VALID_STATES) + } + + scope :search_text_cont, lambda { |search_text| + where("title ->> '#{I18n.locale}' ILIKE ?", "%#{search_text}%") + } + + scope :with_sdgs_codes, lambda { |sdgs_codes| + joins(:challenge).where("decidim_challenges_challenges" => { sdg_code: sdgs_codes }) + } + + scope :with_any_sectorial_scope_id, lambda { |*sectorial_scope_id| + if sectorial_scope_id.include?("all") + all + else + clean_scope_ids = sectorial_scope_id + + conditions = [] + conditions << "#{model_name.plural}.decidim_sectorial_scope_id IS NULL" if clean_scope_ids.delete("global") + conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? + + includes(:sectorial_scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) + end + } + + scope :with_any_technological_scope_id, lambda { |*technological_scope_id| + if technological_scope_id.include?("all") + all + else + clean_scope_ids = technological_scope_id + + conditions = [] + conditions << "#{model_name.plural}.decidim_technological_scope_id IS NULL" if clean_scope_ids.delete("global") + conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? + + includes(:technological_scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) + end + } + + scope :with_any_territorial_scope_id, lambda { |*territorial_scope_id| + if territorial_scope_id.include?("all") + all + else + clean_scope_ids = territorial_scope_id + + conditions = [] + conditions << "decidim_challenges_challenges.decidim_scope_id IS NULL" if clean_scope_ids.delete("global") + conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? + + includes(challenge: :scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) + end + } + + def self.ransackable_scopes(_auth_object = nil) + [:with_any_state, :search_text_cont, :with_sdgs_codes, :with_any_sectorial_scope_id, :with_any_technological_scope_id, :with_any_territorial_scope_id] + end + searchable_fields({ scope_id: "decidim_sectorial_scope_id", participatory_space: :itself, @@ -54,4 +113,4 @@ def published? end end end -end +end \ No newline at end of file diff --git a/app/models/decidim/solutions/solution.rb b/app/models/decidim/solutions/solution.rb index a924dd41..78f202d4 100644 --- a/app/models/decidim/solutions/solution.rb +++ b/app/models/decidim/solutions/solution.rb @@ -5,6 +5,7 @@ module Solutions # The data store for a Solution in the Decidim::Solutions component. class Solution < Solutions::ApplicationRecord include Decidim::HasComponent + include Decidim::FilterableResource include Decidim::Loggable include Decidim::Publicable include Decidim::Resourceable @@ -20,6 +21,32 @@ class Solution < Solutions::ApplicationRecord scope :published, -> { where.not(published_at: nil) } + scope :search_text_cont, lambda { |search_text| + where("title ->> '#{I18n.locale}' ILIKE ?", "%#{search_text}%") + } + + scope :with_sdgs_codes, lambda { |sdgs_codes| + joins(:challenge).where("decidim_challenges_challenges" => { sdg_code: sdgs_codes }) + } + + scope :with_any_territorial_scope_id, lambda { |*territorial_scope_id| + if territorial_scope_id.include?("all") + all + else + clean_scope_ids = territorial_scope_id + + conditions = [] + conditions << "decidim_challenges_challenges.decidim_scope_id IS NULL" if clean_scope_ids.delete("global") + conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? + + includes(problem: { challenge: :scope }).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) + end + } + + def self.ransackable_scopes(_auth_object = nil) + [:search_text_cont, :with_sdgs_codes, :with_any_territorial_scope_id] + end + searchable_fields({ participatory_space: :itself, A: :title, @@ -36,4 +63,4 @@ def published? end end end -end +end \ No newline at end of file diff --git a/app/services/decidim/problems/problem_search.rb b/app/services/decidim/problems/problem_search.rb index ce3e4038..b763a3b9 100644 --- a/app/services/decidim/problems/problem_search.rb +++ b/app/services/decidim/problems/problem_search.rb @@ -45,7 +45,7 @@ def search_sectorial_scope_id clean_scope_ids = sectorial_scope_id conditions = [] - conditions << "#{query.model_name.plural}.decidim_sectorial_scope_id IS NULL" if clean_scope_ids.delete("global") + conditions << "#{model_name.plural}.decidim_sectorial_scope_id IS NULL" if clean_scope_ids.delete("global") conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? query.includes(:sectorial_scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) @@ -64,7 +64,7 @@ def search_technological_scope_id clean_scope_ids = technological_scope_id conditions = [] - conditions << "#{query.model_name.plural}.decidim_technological_scope_id IS NULL" if clean_scope_ids.delete("global") + conditions << "#{model_name.plural}.decidim_technological_scope_id IS NULL" if clean_scope_ids.delete("global") conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? query.includes(:technological_scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) diff --git a/app/views/decidim/challenges/challenges/_filters.html.erb b/app/views/decidim/challenges/challenges/_filters.html.erb index e632e95d..0be9f9d3 100644 --- a/app/views/decidim/challenges/challenges/_filters.html.erb +++ b/app/views/decidim/challenges/challenges/_filters.html.erb @@ -2,7 +2,7 @@
- +<%= javascript_pack_tag "decidim_sdgs" %> diff --git a/app/views/decidim/solutions/solutions/_count.html.erb b/app/views/decidim/solutions/solutions/_count.html.erb index 598e48b5..f0e040ec 100644 --- a/app/views/decidim/solutions/solutions/_count.html.erb +++ b/app/views/decidim/solutions/solutions/_count.html.erb @@ -1 +1 @@ -<%= t(".solutions_count", count: solutions.total_count) %> +<%= t(".solutions_count", count: solutions.count) %> diff --git a/lib/decidim/challenges/component.rb b/lib/decidim/challenges/component.rb index 05980be1..c0dfd939 100644 --- a/lib/decidim/challenges/component.rb +++ b/lib/decidim/challenges/component.rb @@ -12,7 +12,7 @@ component.admin_engine = Decidim::Challenges::AdminEngine component.icon = "media/images/decidim_challenges_icon.svg" - component.data_portable_entities = ["Decidim::Challenge::Survey"] + component.data_portable_entities = ["Decidim::Challenges::Survey"] # component.on(:before_destroy) do |instance| # # Code executed before removing the component diff --git a/spec/services/decidim/challenges/challenge_search_spec.rb b/spec/services/decidim/challenges/challenge_search_spec.rb index 02c6bc25..50681909 100644 --- a/spec/services/decidim/challenges/challenge_search_spec.rb +++ b/spec/services/decidim/challenges/challenge_search_spec.rb @@ -19,7 +19,7 @@ module Challenges with_related_to: related_to, with_any_scope_id: scope_ids, with_any_category_id: category_ids, - sdgs_codes: sdgs_codes + with_any_sdgs_codes: sdgs_codes ).result end diff --git a/spec/services/decidim/problems/problem_search_spec.rb b/spec/services/decidim/problems/problem_search_spec.rb index 18c6a9f6..e06e7521 100644 --- a/spec/services/decidim/problems/problem_search_spec.rb +++ b/spec/services/decidim/problems/problem_search_spec.rb @@ -22,7 +22,7 @@ module Problems with_any_technological_scope_id: technological_scope_ids, with_any_territorial_scope_id: territorial_scope_ids, with_any_category_id: category_ids, - sdgs_codes: sdgs_codes + with_any_sdgs_codes: sdgs_codes ).result end diff --git a/spec/services/decidim/solutions/solution_search_spec.rb b/spec/services/decidim/solutions/solution_search_spec.rb index c117786b..756357ef 100644 --- a/spec/services/decidim/solutions/solution_search_spec.rb +++ b/spec/services/decidim/solutions/solution_search_spec.rb @@ -21,7 +21,7 @@ module Solutions with_related_to: related_to, with_any_territorial_scope_id: territorial_scope_ids, with_any_category_id: category_ids, - sdgs_codes: sdgs_codes + with_any_sdgs_codes: sdgs_codes ).result end From 6bb3b08303125b4973a1cdd120fda480c56643f8 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 27 Oct 2023 12:25:50 +0200 Subject: [PATCH 08/15] Fix challenges filters --- Gemfile.lock | 6 +- .../decidim/challenges/survey_challenge.rb | 2 +- .../challenges/challenges_controller.rb | 26 +-- app/models/decidim/challenges/challenge.rb | 4 +- .../decidim/challenges/challenge_search.rb | 40 ----- .../challenges/challenges/_filters.html.erb | 4 +- .../challenges/challenge_search_spec.rb | 162 ------------------ .../challenges/filter_challenges_spec.rb | 116 ++++--------- 8 files changed, 43 insertions(+), 317 deletions(-) delete mode 100644 app/services/decidim/challenges/challenge_search.rb delete mode 100644 spec/services/decidim/challenges/challenge_search_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index bd1a1cb5..c9fe97b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/decidim/decidim - revision: 2d0a1fe016da514c4b8df974b949230d958186a2 + revision: f25fd77687c92f7458dbb006db32b2718e4bd765 branch: release/0.27-stable specs: decidim (0.27.4) @@ -247,7 +247,7 @@ GEM addressable (2.8.5) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - axe-core-api (4.7.0) + axe-core-api (4.8.0) dumb_delegator virtus axe-core-rspec (4.1.0) @@ -483,7 +483,7 @@ GEM net-smtp marcel (1.0.2) matrix (0.4.2) - mdl (0.12.0) + mdl (0.13.0) kramdown (~> 2.3) kramdown-parser-gfm (~> 1.1) mixlib-cli (~> 2.1, >= 2.1.1) diff --git a/app/commands/decidim/challenges/survey_challenge.rb b/app/commands/decidim/challenges/survey_challenge.rb index 8aaa5d9f..925000a3 100644 --- a/app/commands/decidim/challenges/survey_challenge.rb +++ b/app/commands/decidim/challenges/survey_challenge.rb @@ -56,7 +56,7 @@ def create_survey end def questionnaire? - survey_form.model_name == "Questionnaire" + survey_form.model_name.human == "Questionnaire" end def can_answer_survey? diff --git a/app/controllers/decidim/challenges/challenges_controller.rb b/app/controllers/decidim/challenges/challenges_controller.rb index e0c524ed..d959ecc0 100644 --- a/app/controllers/decidim/challenges/challenges_controller.rb +++ b/app/controllers/decidim/challenges/challenges_controller.rb @@ -21,8 +21,8 @@ class ChallengesController < Decidim::Challenges::ApplicationController def index @challenges = search.result - @challenges = reorder(challenges) - @challenges = paginate(challenges) + @challenges = reorder(@challenges) + @challenges = paginate(@challenges) end def show @@ -41,32 +41,16 @@ def challenge_scope def default_filter_params { search_text_cont: "", - with_any_category_id: default_filter_category_params, + with_any_category: default_filter_category_params, with_any_state: %w(proposal execution finished), - with_any_scope_id: default_filter_scope_params, + with_any_scope: default_filter_scope_params, with_related_to: "", with_any_sdgs_codes: [], } end - def default_filter_category_params - return "all" unless current_component.participatory_space.categories.any? - - ["all"] + current_component.participatory_space.categories.map { |category| category.id.to_s } - end - - def default_filter_scope_params - return "all" unless current_component.participatory_space.scopes.any? - - if current_component.participatory_space.scope - ["all", current_component.participatory_space.scope.id] + current_component.participatory_space.scope.children.map { |scope| scope.id.to_s } - else - %w(all global) + current_component.participatory_space.scopes.map { |scope| scope.id.to_s } - end - end - def challenges - @challenges ||= paginate(search.result) + @challenges ||= reorder(paginate(search.result)) end def search_collection diff --git a/app/models/decidim/challenges/challenge.rb b/app/models/decidim/challenges/challenge.rb index c696e601..2307082c 100644 --- a/app/models/decidim/challenges/challenge.rb +++ b/app/models/decidim/challenges/challenge.rb @@ -6,6 +6,8 @@ module Challenges class Challenge < Decidim::ApplicationRecord include Decidim::HasComponent include Decidim::FilterableResource + include Decidim::ScopableResource + include Decidim::HasCategory include Decidim::Loggable include Decidim::Publicable include Decidim::Resourceable @@ -56,7 +58,7 @@ class Challenge < Decidim::ApplicationRecord } def self.ransackable_scopes(_auth_object = nil) - [:with_any_state, :search_text_cont, :with_any_sdgs_codes] + [:with_any_state, :search_text_cont, :with_any_sdgs_codes, :with_any_scope, :with_any_category] end searchable_fields({ diff --git a/app/services/decidim/challenges/challenge_search.rb b/app/services/decidim/challenges/challenge_search.rb deleted file mode 100644 index 0362e9a3..00000000 --- a/app/services/decidim/challenges/challenge_search.rb +++ /dev/null @@ -1,40 +0,0 @@ -# frozen_string_literal: true - -module Decidim - module Challenges - # A service to encapsualte all the logic when searching and filtering - # challenges in a participatory process. - class ChallengeSearch < ResourceSearch - # text_search_fields :title - - # Public: Initializes the service. - # component - A Decidim::Component to get the challenges from. - # page - The page number to paginate the results. - # per_page - The number of challenges to return per page. - def initialize(options = {}) - super(Challenge.published.all, options) - end - - # Handle the search_text filter - def search_search_text - query.where("title ->> '#{I18n.locale}' ILIKE ?", "%#{search_text}%") - end - - # Handle the state filter - def search_state - in_proposal = state.include?("proposal") ? query.in_proposal : nil - in_execution = state.member?("execution") ? query.in_execution : nil - in_finished = state.member?("finished") ? query.in_finished : nil - - query - .where(id: in_proposal) - .or(query.where(id: in_execution)) - .or(query.where(id: in_finished)) - end - - def search_with_any_sdgs_codes - query.where(sdg_code: with_any_sdgs_codes) - end - end - end -end diff --git a/app/views/decidim/challenges/challenges/_filters.html.erb b/app/views/decidim/challenges/challenges/_filters.html.erb index 1cd44488..07ce772b 100644 --- a/app/views/decidim/challenges/challenges/_filters.html.erb +++ b/app/views/decidim/challenges/challenges/_filters.html.erb @@ -15,11 +15,11 @@ <%= form.check_boxes_tree :with_any_state, filter_challenges_state_values, legend_title: t(".state") %> <% if current_participatory_space.has_subscopes? %> - <%= form.check_boxes_tree :with_any_scope_id, filter_scopes_values, legend_title: t(".scope") %> + <%= form.check_boxes_tree :with_any_scope, filter_scopes_values, legend_title: t(".scope") %> <% end %> <% if current_component.categories.any? %> - <%= form.check_boxes_tree :with_any_category_id, filter_categories_values, legend_title: t(".category") %> + <%= form.check_boxes_tree :with_any_category, filter_categories_values, legend_title: t(".category") %> <% end %> <% if current_participatory_space.components.published.where(manifest_name: "sdgs").any? %> diff --git a/spec/services/decidim/challenges/challenge_search_spec.rb b/spec/services/decidim/challenges/challenge_search_spec.rb deleted file mode 100644 index 50681909..00000000 --- a/spec/services/decidim/challenges/challenge_search_spec.rb +++ /dev/null @@ -1,162 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" -require_relative "../search_scopes_examples" - -module Decidim - module Challenges - describe ChallengeSearch do - let(:component) { create(:challenges_component) } - let(:participatory_process) { component.participatory_space } - let!(:challenges_list) { create_list(:challenge, 3, component: component) } - - describe "results" do - subject do - described_class.new( - component: component, - search_text_cont: search_text_cont, - with_any_state: states, - with_related_to: related_to, - with_any_scope_id: scope_ids, - with_any_category_id: category_ids, - with_any_sdgs_codes: sdgs_codes - ).result - end - - let(:search_text_cont) { nil } - let(:related_to) { nil } - let(:states) { nil } - let(:scope_ids) { nil } - let(:category_ids) { nil } - let(:sdgs_codes) { nil } - - it "only includes challenges from the given component" do - other_challenge = create(:challenge) - - expect(subject).to match_array(challenges_list) - expect(subject).not_to include(other_challenge) - end - - describe "search_text_cont filter" do - let(:search_text_cont) { "dog" } - - it "returns the challenges containing the search in the title or the body" do - dog_challenge = create(:challenge, title: { I18n.locale => "A dog" }, component: component) - - expect(subject).to include(dog_challenge) - expect(subject.size).to eq(1) - end - end - - describe "state filter" do - context "when filtering for default states" do - it "returns all challenges" do - expect(subject.size).to eq(3) - expect(subject).to match_array(challenges_list) - end - end - - context "when filtering challenges in :proposal state" do - let(:states) { %w(proposal) } - - it "hides execution and finished proposals" do - create(:challenge, :finished, component: component) - proposal_challenge = create(:challenge, :proposal, component: component) - - expect(subject.size).to eq(1) - expect(subject).to include(proposal_challenge) - end - end - - context "when filtering challenges in :execution state" do - let(:states) { %w(execution) } - - it "returns only execution proposals" do - create(:challenge, :finished, component: component) - create(:challenge, :proposal, component: component) - - expect(subject.size).to eq(3) - expect(subject).to match_array(challenges_list) - end - end - - context "when filtering challenges in :finished state" do - let(:states) { %w(finished) } - - it "returns only finished proposals" do - finished_challenge = create(:challenge, :finished, component: component) - create(:challenge, :proposal, component: component) - - expect(subject.size).to eq(1) - expect(subject).to include(finished_challenge) - end - end - end - - describe "challenge territorial scopes" do - include_context "with example scopes" - - let(:resources_list) { challenges_list } - let!(:resource_without_scope) { create(:challenge, component: component, scope: nil) } - let!(:resource_1) { create(:challenge, component: component, scope: scope_1) } - let!(:resource_2) { create(:challenge, component: component, scope: scope_2) } - let!(:resource_3) { create(:challenge, component: component, scope: subscope_1) } - - context "with sectorial_scope_ids" do - include_examples "search scope filter", "scope_ids" - end - end - - describe "ods filter" do - context "when none is selected" do - it "does not apply the filter" do - expect(subject).to match_array(challenges_list) - end - end - - context "when one SDG is selected" do - let(:sdg_code) { Decidim::Sdgs::Sdg::SDGS.index(:responsible_consumption) } - let!(:challenge_w_sdg) { create(:challenge, component: component, sdg_code: sdg_code) } - let(:sdgs_codes) { [sdg_code] } - - it "returns the problems associated to the given SDG" do - expect(subject.pluck(:id)).to contain_exactly(challenge_w_sdg.id) - end - end - end - - # describe "related_to filter" do - pending "when filtering by related to problems" - # let(:related_to) { 'Decidim::Meetings::Meeting'.underscore } - # let(:problems_component) { create(:component, manifest_name: 'problems', participatory_space: participatory_process) } - # let(:problem) { create :problem, component: problems_component } - - # it "returns only challenges related to problems" - # related_challenge = create(:challenge, :accepted, component: component) - # related_challenge_2 = create(:challenge, :accepted, component: component) - # create_list(:challenge, 3, component: component) - # problem.link_resources([related_challenge], 'challenges_from_problem') - # related_challenge_2.link_resources([problem], 'challenges_from_problem') - - # expect(subject).to match_array([related_challenge, related_challenge_2]) - # end - - pending "when filtering by related to resources" - # let(:related_to) { 'Decidim::DummyResources::DummyResource'.underscore } - # let(:dummy_component) { create(:component, manifest_name: 'dummy', participatory_space: participatory_process) } - # let(:dummy_resource) { create :dummy_resource, component: dummy_component } - - # it "returns only challenges related to results" - # related_challenge = create(:challenge, :accepted, component: component) - # related_challenge_2 = create(:challenge, :accepted, component: component) - # create_list(:challenge, 3, component: component) - # dummy_resource.link_resources([related_challenge], 'included_challenges') - # related_challenge_2.link_resources([dummy_resource], 'included_challenges') - - # expect(subject).to match_array([related_challenge, related_challenge_2]) - # end - # end - end - end - end -end diff --git a/spec/system/decidim/challenges/filter_challenges_spec.rb b/spec/system/decidim/challenges/filter_challenges_spec.rb index fa09505c..b7e76334 100644 --- a/spec/system/decidim/challenges/filter_challenges_spec.rb +++ b/spec/system/decidim/challenges/filter_challenges_spec.rb @@ -30,7 +30,7 @@ context "when selecting the global scope" do it "lists the filtered challenges", :slow do - within ".filters .with_any_scope_id_check_boxes_tree_filter" do + within ".filters .with_any_scope_check_boxes_tree_filter" do uncheck "All" check "Global" end @@ -42,7 +42,7 @@ context "when selecting one scope" do it "lists the filtered challenges", :slow do - within ".filters .with_any_scope_id_check_boxes_tree_filter" do + within ".filters .with_any_scope_check_boxes_tree_filter" do uncheck "All" check scope.name[I18n.locale.to_s] end @@ -54,7 +54,7 @@ context "when selecting the global scope and another scope" do it "lists the filtered challenges", :slow do - within ".filters .with_any_scope_id_check_boxes_tree_filter" do + within ".filters .with_any_scope_check_boxes_tree_filter" do uncheck "All" check "Global" check scope.name[I18n.locale.to_s] @@ -67,7 +67,7 @@ context "when unselecting the selected scope" do it "lists the filtered challenges" do - within ".filters .with_any_scope_id_check_boxes_tree_filter" do + within ".filters .with_any_scope_check_boxes_tree_filter" do uncheck "All" check scope.name[I18n.locale.to_s] check "Global" @@ -187,6 +187,7 @@ before do find(".filters__section.sdgs-filter button").click expect(page).to have_css("#sdgs-modal") + # TODO: not works! any webpacker stuff find('#sdgs-modal .sdg-cell[data-value="no_poverty"]').click find('#sdgs-modal .sdg-cell[data-value="good_health"]').click find("#sdgs-modal .reveal__footer a.button").click @@ -200,95 +201,36 @@ end end - # context "when filtering challenges by CATEGORY", :slow do - # context "when the user is logged in" do - # let!(:category2) { create :category, participatory_space: participatory_process } - # let!(:category3) { create :category, participatory_space: participatory_process } - # let!(:challenge1) { create(:challenge, component: component, category: category) } - # let!(:challenge2) { create(:challenge, component: component, category: category2) } - # let!(:challenge3) { create(:challenge, component: component, category: category3) } + context "when filtering challenges by CATEGORY" do + let!(:challenge) { create(:challenge, component: component, category: category) } - # before do - # login_as user, scope: :user - # end - - # it "can be filtered by a category" do - # visit_component - - # within ".filters .category_id_check_boxes_tree_filter" do - # uncheck "All" - # check category.name[I18n.locale.to_s] - # end - - # expect(page).to have_css(".card--challenge", count: 1) - # end - - # it "can be filtered by two categories" do - # visit_component - - # within ".filters .category_id_check_boxes_tree_filter" do - # uncheck "All" - # check category.name[I18n.locale.to_s] - # check category2.name[I18n.locale.to_s] - # end - - # expect(page).to have_css(".card--challenge", count: 2) - # end - # end - # end - - # context "when using the browser history", :slow do - # before do - # create_list(:challenge, 2, component: component) - # create_list(:challenge, 2, :official, component: component) - # create_list(:challenge, 2, :official, :accepted, component: component) - # create_list(:challenge, 2, :official, :rejected, component: component) - - # visit_component - # end - - # it "recover filters from initial pages" do - # within ".filters .state_check_boxes_tree_filter" do - # check "Rejected" - # end - - # expect(page).to have_css(".card.card--challenge", count: 8) - - # page.go_back - - # expect(page).to have_css(".card.card--challenge", count: 6) - # end - - # it "recover filters from previous pages" do - # within ".filters .state_check_boxes_tree_filter" do - # check "All" - # uncheck "All" - # end - # within ".filters .origin_check_boxes_tree_filter" do - # uncheck "All" - # end - - # within ".filters .origin_check_boxes_tree_filter" do - # check "Official" - # end - - # within ".filters .state_check_boxes_tree_filter" do - # check "Accepted" - # end + before do + login_as user, scope: :user + visit_component + end - # expect(page).to have_css(".card.card--challenge", count: 2) + it "can be filtered by category" do + within ".filters .with_any_category_check_boxes_tree_filter" do + uncheck "All" + check category.name[I18n.locale.to_s] + end - # page.go_back + expect(page).to have_css(".card--challenge", count: 1) + end - # expect(page).to have_css(".card.card--challenge", count: 6) + it "works with 'back to list' link" do + within ".filters .with_any_category_check_boxes_tree_filter" do + uncheck "All" + check category.name[I18n.locale.to_s] + end - # page.go_back + expect(page).to have_css(".card--challenge", count: 1) - # expect(page).to have_css(".card.card--challenge", count: 8) + page.find(".card--challenge .card__link").click - # page.go_forward + click_link "Return to list" - # expect(page).to have_css(".card.card--challenge", count: 6) - # end - # end + expect(page).to have_css(".card--challenge", count: 1) + end + end end From 96a08ec161c19f7dec628b25b1fe6ccbb6a8f493 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 27 Oct 2023 12:46:52 +0200 Subject: [PATCH 09/15] Fix problems filters --- .../decidim/problems/problems_controller.rb | 14 +-- app/models/decidim/problems/problem.rb | 5 +- .../decidim/problems/problem_search.rb | 97 ------------------- .../problems/admin/problems/_form.html.erb | 2 +- .../problems/problems/_filters.html.erb | 6 +- 5 files changed, 10 insertions(+), 114 deletions(-) delete mode 100644 app/services/decidim/problems/problem_search.rb diff --git a/app/controllers/decidim/problems/problems_controller.rb b/app/controllers/decidim/problems/problems_controller.rb index c942af79..72bcf246 100644 --- a/app/controllers/decidim/problems/problems_controller.rb +++ b/app/controllers/decidim/problems/problems_controller.rb @@ -21,8 +21,8 @@ class ProblemsController < Decidim::Problems::ApplicationController def index @problems = search.result - @problems = reorder(problems) - @problems = paginate(problems) + @problems = reorder(@problems) + @problems = paginate(@problems) end def show @@ -39,7 +39,7 @@ def challenge_scope def default_filter_params { search_text_cont: "", - with_any_category_id: default_filter_category_params, + with_any_category: default_filter_category_params, with_any_state: %w(proposal execution finished), with_any_sectorial_scope_id: default_filter_scope_params, with_any_technological_scope_id: default_filter_scope_params, @@ -49,12 +49,6 @@ def default_filter_params } end - def default_filter_category_params - return "all" unless current_component.participatory_space.categories.any? - - ["all"] + current_component.participatory_space.categories.map { |category| category.id.to_s } - end - def default_filter_scope_params return "all" unless current_component.participatory_space.scopes.any? @@ -66,7 +60,7 @@ def default_filter_scope_params end def problems - @problems ||= paginate(search.result) + @problems ||= order(paginate(search.result)) end def search_collection diff --git a/app/models/decidim/problems/problem.rb b/app/models/decidim/problems/problem.rb index 6cd0bda8..dc18890e 100644 --- a/app/models/decidim/problems/problem.rb +++ b/app/models/decidim/problems/problem.rb @@ -6,6 +6,8 @@ module Problems class Problem < Decidim::ApplicationRecord include Decidim::HasComponent include Decidim::FilterableResource + include Decidim::ScopableResource + include Decidim::HasCategory include Decidim::Loggable include Decidim::Publicable include Decidim::Resourceable @@ -93,7 +95,8 @@ class Problem < Decidim::ApplicationRecord } def self.ransackable_scopes(_auth_object = nil) - [:with_any_state, :search_text_cont, :with_any_sdgs_codes, :with_any_sectorial_scope_id, :with_any_technological_scope_id, :with_any_territorial_scope_id] + [:with_any_state, :search_text_cont, :with_any_sdgs_codes, :with_any_category, + :with_any_sectorial_scope_id, :with_any_technological_scope_id, :with_any_territorial_scope_id] end searchable_fields({ diff --git a/app/services/decidim/problems/problem_search.rb b/app/services/decidim/problems/problem_search.rb deleted file mode 100644 index de59f1c2..00000000 --- a/app/services/decidim/problems/problem_search.rb +++ /dev/null @@ -1,97 +0,0 @@ -# frozen_string_literal: true - -module Decidim - module Problems - # A service to encapsualte all the logic when searching and filtering - # Problems in a participatory process. - class ProblemSearch < ResourceSearch - # text_search_fields :title - - # Public: Initializes the service. - # component - A Decidim::Component to get the problems from. - # page - The page number to paginate the results. - # per_page - The number of problems to return per page. - def initialize(options = {}) - super(Problem.published.all, options) - end - - # Handle the search_text filter - def search_search_text - query.where("title ->> '#{I18n.locale}' ILIKE ?", "%#{search_text}%") - end - - # Handle the state filter - def search_state - in_proposal = state.include?("proposal") ? query.in_proposal : nil - in_execution = state.member?("execution") ? query.in_execution : nil - in_finished = state.member?("finished") ? query.in_finished : nil - - query - .where(id: in_proposal) - .or(query.where(id: in_execution)) - .or(query.where(id: in_finished)) - end - - # Handles the sectorial_scope_id filter. When we want to show only those that do not - # have a sectorial_scope_id set, we cannot pass an empty String or nil because Searchlight - # will automatically filter out these params, so the method will not be used. - # Instead, we need to pass a fake ID and then convert it inside. In this case, - # in order to select those elements that do not have a sectorial_scope_id set we use - # `"global"` as parameter, and in the method we do the needed changes to search - # properly. - def search_sectorial_scope_id - return query if sectorial_scope_id.include?("all") - - clean_scope_ids = sectorial_scope_id - - conditions = [] - conditions << "#{model_name.plural}.decidim_sectorial_scope_id IS NULL" if clean_scope_ids.delete("global") - conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? - - query.includes(:sectorial_scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) - end - - # Handles the technological_scope_id filter. When we want to show only those that do not - # have a technological_scope_id set, we cannot pass an empty String or nil because Searchlight - # will automatically filter out these params, so the method will not be used. - # Instead, we need to pass a fake ID and then convert it inside. In this case, - # in order to select those elements that do not have a technological_scope_id set we use - # `"global"` as parameter, and in the method we do the needed changes to search - # properly. - def search_technological_scope_id - return query if technological_scope_id.include?("all") - - clean_scope_ids = technological_scope_id - - conditions = [] - conditions << "#{model_name.plural}.decidim_technological_scope_id IS NULL" if clean_scope_ids.delete("global") - conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? - - query.includes(:technological_scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) - end - - # Handles the territorial challenge.scope_id filter. When we want to show only those that do not - # have a scope_id set, we cannot pass an empty String or nil because Searchlight - # will automatically filter out these params, so the method will not be used. - # Instead, we need to pass a fake ID and then convert it inside. In this case, - # in order to select those elements that do not have a scope_id set we use - # `"global"` as parameter, and in the method we do the needed changes to search - # properly. - def search_territorial_scope_id - return query if territorial_scope_id.include?("all") - - clean_scope_ids = territorial_scope_id - - conditions = [] - conditions << "decidim_challenges_challenges.decidim_scope_id IS NULL" if clean_scope_ids.delete("global") - conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? - - query.includes(challenge: :scope).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) - end - - def search_with_any_sdgs_codes - query.joins(:challenge).where("decidim_challenges_challenges" => { sdg_code: sdgs_codes }) - end - end - end -end diff --git a/app/views/decidim/problems/admin/problems/_form.html.erb b/app/views/decidim/problems/admin/problems/_form.html.erb index 86a36592..b9a014a3 100644 --- a/app/views/decidim/problems/admin/problems/_form.html.erb +++ b/app/views/decidim/problems/admin/problems/_form.html.erb @@ -57,7 +57,7 @@
<%= form.select :decidim_challenges_challenge_id, @form.select_challenge_collection, - selected: @form.try(:challenge) ? [translated_attribute(@form.try(:challenge).title), @form.try(:challenge).id] : '', + selected: @form.try(:decidim_challenges_challenge_id) ? [translated_attribute(Decidim::Challenges::Challenge.find(@form.try(:decidim_challenges_challenge_id)).title), @form.try(:decidim_challenges_challenge_id)] : '', label: t("models.problem.fields.challenge", scope: "decidim.problems.admin"), include_blank: "" %>
diff --git a/app/views/decidim/problems/problems/_filters.html.erb b/app/views/decidim/problems/problems/_filters.html.erb index 7d2747b2..f43d4551 100644 --- a/app/views/decidim/problems/problems/_filters.html.erb +++ b/app/views/decidim/problems/problems/_filters.html.erb @@ -21,16 +21,12 @@ <% end %> <% if current_component.categories.any? %> - <%= form.check_boxes_tree :with_any_category_id, filter_categories_values, legend_title: t(".category") %> + <%= form.check_boxes_tree :with_any_category, filter_categories_values, legend_title: t(".category") %> <% end %> <% if current_participatory_space.components.published.where(manifest_name: "sdgs").any? %> <%= sdgs_filter_selector(form) %> <% end %> - <%# if linked_classes_for(Decidim::Proposals::Proposal).any? %> - <%#= form.collection_radio_buttons :related_to, linked_classes_filter_values_for(Decidim::Proposals::Proposal), :first, :last, legend_title: t(".related_to") %> - <%# end %> - <%= hidden_field_tag :order, order, id: nil, class: "order_filter" %> <% end %> From 877ac0e7ada029b37eabd878d5dc3e19bf6d70d9 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 27 Oct 2023 13:15:54 +0200 Subject: [PATCH 10/15] Fix solutions filters and update challenge --- .../solutions/admin/create_solution.rb | 33 +-- .../solutions/admin/update_solution.rb | 33 +-- .../decidim/solutions/solutions_controller.rb | 8 +- app/models/decidim/solutions/solution.rb | 3 +- .../decidim/solutions/solution_search.rb | 47 ----- .../solutions/solutions/_filters.html.erb | 2 +- .../decidim/problems/problem_search_spec.rb | 196 ------------------ .../decidim/search_scopes_examples.rb | 52 ----- .../decidim/solutions/solution_search_spec.rb | 133 ------------ 9 files changed, 40 insertions(+), 467 deletions(-) delete mode 100644 app/services/decidim/solutions/solution_search.rb delete mode 100644 spec/services/decidim/problems/problem_search_spec.rb delete mode 100644 spec/services/decidim/search_scopes_examples.rb delete mode 100644 spec/services/decidim/solutions/solution_search_spec.rb diff --git a/app/commands/decidim/solutions/admin/create_solution.rb b/app/commands/decidim/solutions/admin/create_solution.rb index 9fa2f8d9..a6ac30ec 100644 --- a/app/commands/decidim/solutions/admin/create_solution.rb +++ b/app/commands/decidim/solutions/admin/create_solution.rb @@ -34,25 +34,18 @@ def call attr_reader :form, :solution def create_solution! - parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite - parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite - parsed_objectives = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.objectives, current_organization: form.current_organization).rewrite - parsed_indicators = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.indicators, current_organization: form.current_organization).rewrite - parsed_beneficiaries = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.beneficiaries, current_organization: form.current_organization).rewrite - parsed_requirements = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.requirements, current_organization: form.current_organization).rewrite - parsed_financing_type = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.financing_type, current_organization: form.current_organization).rewrite params = { - title: parsed_title, - description: parsed_description, + title: parsed_attribute(:title), + description: parsed_attribute(:description), component: form.current_component, decidim_problems_problem_id: form.decidim_problems_problem_id, - decidim_challenges_challenge_id: form.decidim_challenges_challenge_id, + decidim_challenges_challenge_id: challenge, tags: form.tags, - objectives: parsed_objectives, - indicators: parsed_indicators, - beneficiaries: parsed_beneficiaries, - requirements: parsed_requirements, - financing_type: parsed_financing_type, + objectives: parsed_attribute(:objectives), + indicators: parsed_attribute(:indicators), + beneficiaries: parsed_attribute(:beneficiaries), + requirements: parsed_attribute(:requirements), + financing_type: parsed_attribute(:financing_type), } @solution = Decidim.traceability.create!( @@ -62,6 +55,16 @@ def create_solution! visibility: "all" ) end + + def parsed_attribute(attribute) + Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite + end + + def challenge + problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) + + problem.present? ? problem.decidim_challenges_challenge_id.presence || nil : nil + end end end end diff --git a/app/commands/decidim/solutions/admin/update_solution.rb b/app/commands/decidim/solutions/admin/update_solution.rb index dcdb2542..a2694aba 100644 --- a/app/commands/decidim/solutions/admin/update_solution.rb +++ b/app/commands/decidim/solutions/admin/update_solution.rb @@ -44,27 +44,30 @@ def update_solution end def attributes - parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite - parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite - parsed_objectives = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.objectives, current_organization: form.current_organization).rewrite - parsed_indicators = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.indicators, current_organization: form.current_organization).rewrite - parsed_beneficiaries = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.beneficiaries, current_organization: form.current_organization).rewrite - parsed_requirements = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.requirements, current_organization: form.current_organization).rewrite - parsed_financing_type = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.financing_type, current_organization: form.current_organization).rewrite { - title: parsed_title, - description: parsed_description, + title: parsed_attribute(:title), + description: parsed_attribute(:description), component: form.current_component, decidim_problems_problem_id: form.decidim_problems_problem_id, - decidim_challenges_challenge_id: form.decidim_challenges_challenge_id, + decidim_challenges_challenge_id: challenge, tags: form.tags, - objectives: parsed_objectives, - indicators: parsed_indicators, - beneficiaries: parsed_beneficiaries, - requirements: parsed_requirements, - financing_type: parsed_financing_type, + objectives: parsed_attribute(:objectives), + indicators: parsed_attribute(:indicators), + beneficiaries: parsed_attribute(:beneficiaries), + requirements: parsed_attribute(:requirements), + financing_type: parsed_attribute(:financing_type), } end + + def parsed_attribute(attribute) + Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite + end + + def challenge + problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) + + problem.present? ? problem.decidim_challenges_challenge_id.presence || nil : nil + end end end end diff --git a/app/controllers/decidim/solutions/solutions_controller.rb b/app/controllers/decidim/solutions/solutions_controller.rb index 232f4fcc..ca650852 100644 --- a/app/controllers/decidim/solutions/solutions_controller.rb +++ b/app/controllers/decidim/solutions/solutions_controller.rb @@ -39,19 +39,13 @@ def show def default_filter_params { search_text_cont: "", - with_any_category_id: default_filter_category_params, + with_any_category: default_filter_category_params, with_any_territorial_scope_id: default_filter_scope_params, with_related_to: "", with_any_sdgs_codes: [], } end - def default_filter_category_params - return "all" unless current_component.participatory_space.categories.any? - - ["all"] + current_component.participatory_space.categories.map { |category| category.id.to_s } - end - def default_filter_scope_params return "all" unless current_component.participatory_space.scopes.any? diff --git a/app/models/decidim/solutions/solution.rb b/app/models/decidim/solutions/solution.rb index bb987f46..d9d7dbc2 100644 --- a/app/models/decidim/solutions/solution.rb +++ b/app/models/decidim/solutions/solution.rb @@ -6,6 +6,7 @@ module Solutions class Solution < Solutions::ApplicationRecord include Decidim::HasComponent include Decidim::FilterableResource + include Decidim::HasCategory include Decidim::Loggable include Decidim::Publicable include Decidim::Resourceable @@ -44,7 +45,7 @@ class Solution < Solutions::ApplicationRecord } def self.ransackable_scopes(_auth_object = nil) - [:search_text_cont, :with_any_sdgs_codes, :with_any_territorial_scope_id] + [:search_text_cont, :with_any_category, :with_any_sdgs_codes, :with_any_territorial_scope_id] end searchable_fields({ diff --git a/app/services/decidim/solutions/solution_search.rb b/app/services/decidim/solutions/solution_search.rb deleted file mode 100644 index 42b40a05..00000000 --- a/app/services/decidim/solutions/solution_search.rb +++ /dev/null @@ -1,47 +0,0 @@ -# frozen_string_literal: true - -module Decidim - module Solutions - # A service to encapsualte all the logic when searching and filtering - # Solutions in a participatory process. - class SolutionSearch < ResourceSearch - # text_search_fields :title - - # Public: Initializes the service. - # component - A Decidim::Component to get the solutions from. - # page - The page number to paginate the results. - # per_page - The number of solutions to return per page. - def initialize(options = {}) - super(Solution.published.all, options) - end - - # Handle the search_text filter - def search_search_text - query.where("title ->> '#{I18n.locale}' ILIKE ?", "%#{search_text}%") - end - - # Handles the territorial challenge.scope_id filter. When we want to show only those that do not - # have a scope_id set, we cannot pass an empty String or nil because Searchlight - # will automatically filter out these params, so the method will not be used. - # Instead, we need to pass a fake ID and then convert it inside. In this case, - # in order to select those elements that do not have a scope_id set we use - # `"global"` as parameter, and in the method we do the needed changes to search - # properly. - def search_territorial_scope_id - return query if territorial_scope_id.include?("all") - - clean_scope_ids = territorial_scope_id - - conditions = [] - conditions << "decidim_challenges_challenges.decidim_scope_id IS NULL" if clean_scope_ids.delete("global") - conditions.concat(["? = ANY(decidim_scopes.part_of)"] * clean_scope_ids.count) if clean_scope_ids.any? - - query.includes(problem: { challenge: :scope }).references(:decidim_scopes).where(conditions.join(" OR "), *clean_scope_ids.map(&:to_i)) - end - - def search_sdgs_codes - query.joins(problem: :challenge).where("decidim_challenges_challenges.sdg_code" => sdgs_codes) - end - end - end -end diff --git a/app/views/decidim/solutions/solutions/_filters.html.erb b/app/views/decidim/solutions/solutions/_filters.html.erb index bba62b58..f0106aaf 100644 --- a/app/views/decidim/solutions/solutions/_filters.html.erb +++ b/app/views/decidim/solutions/solutions/_filters.html.erb @@ -17,7 +17,7 @@ <% end %> <% if current_component.categories.any? %> - <%= form.check_boxes_tree :with_any_category_id, filter_categories_values, legend_title: t(".category") %> + <%= form.check_boxes_tree :with_any_category, filter_categories_values, legend_title: t(".category") %> <% end %> <% if current_participatory_space.components.published.where(manifest_name: "sdgs").any? %> diff --git a/spec/services/decidim/problems/problem_search_spec.rb b/spec/services/decidim/problems/problem_search_spec.rb deleted file mode 100644 index e06e7521..00000000 --- a/spec/services/decidim/problems/problem_search_spec.rb +++ /dev/null @@ -1,196 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" -require_relative "../search_scopes_examples" - -module Decidim - module Problems - describe ProblemSearch do - let!(:challenge) { create(:challenge) } - let(:component) { create(:component, organization: challenge.component.organization, manifest_name: "problems") } - let(:participatory_process) { component.participatory_space } - let!(:problems_list) { create_list(:problem, 3, component: component, challenge: challenge) } - - describe "results" do - subject do - described_class.new( - component: component, - search_text_cont: search_text_cont, - with_any_state: states, - with_related_to: related_to, - with_any_sectorial_scope_id: sectorial_scope_ids, - with_any_technological_scope_id: technological_scope_ids, - with_any_territorial_scope_id: territorial_scope_ids, - with_any_category_id: category_ids, - with_any_sdgs_codes: sdgs_codes - ).result - end - - let(:search_text_cont) { nil } - let(:related_to) { nil } - let(:states) { nil } - let(:sectorial_scope_ids) { nil } - let(:technological_scope_ids) { nil } - let(:territorial_scope_ids) { nil } - let(:category_ids) { nil } - let(:sdgs_codes) { nil } - - it "only includes problems from the given component" do - other_problem = create(:problem) - - expect(subject).to match_array(problems_list) - expect(subject).not_to include(other_problem) - end - - describe "search_text_cont filter" do - let(:search_text_cont) { "dog" } - - it "returns the problems containing the search in the title or the body" do - dog_problem = create(:problem, title: { I18n.locale => "A dog" }, component: component) - - expect(subject).to include(dog_problem) - expect(subject.size).to eq(1) - end - end - - # describe "when filtering problems by challenge" do - pending "finds the problems associated with the given challenge" - # end - - describe "problem scopes" do - include_context "with example scopes" - - let(:resources_list) { problems_list } - let!(:resource_without_scope) { create(:problem, component: component, sectorial_scope: nil, technological_scope: nil) } - let!(:resource_1) { create(:problem, component: component, sectorial_scope: scope_1, technological_scope: scope_1) } - let!(:resource_2) { create(:problem, component: component, sectorial_scope: scope_2, technological_scope: scope_2) } - let!(:resource_3) { create(:problem, component: component, sectorial_scope: subscope_1, technological_scope: subscope_1) } - - context "with sectorial_scope_ids" do - include_examples "search scope filter", "sectorial_scope_ids" - end - - context "with technological_scope_ids" do - include_examples "search scope filter", "technological_scope_ids" - end - end - - describe "challenge territorial scopes" do - include_context "with example scopes" - - let(:challenges_component) { create(:challenges_component, participatory_space: component.participatory_space) } - let!(:challenge_without_scope) { create(:challenge, component: challenges_component, scope: nil) } - let!(:challenge_1) { create(:challenge, component: challenges_component, scope: scope_1) } - let!(:challenge_2) { create(:challenge, component: challenges_component, scope: scope_2) } - let!(:challenge_3) { create(:challenge, component: challenges_component, scope: subscope_1) } - - let(:resources_list) { problems_list } - let!(:resource_without_scope) { create(:problem, component: component, challenge: challenge_without_scope) } - let!(:resource_1) { create(:problem, component: component, challenge: challenge_1) } - let!(:resource_2) { create(:problem, component: component, challenge: challenge_2) } - let!(:resource_3) { create(:problem, component: component, challenge: challenge_3) } - - context "with sectorial_scope_ids" do - include_examples "search scope filter", "territorial_scope_ids" - end - end - - describe "state filter" do - context "when filtering for default states" do - it "returns all problems" do - expect(subject.size).to eq(3) - expect(subject).to match_array(problems_list) - end - end - - context "when filtering problems in :proposal state" do - let(:states) { %w(proposal) } - - it "hides execution and finished proposals" do - create(:problem, :finished, component: component) - proposal_problem = create(:problem, :proposal, component: component) - - expect(subject.size).to eq(1) - expect(subject).to include(proposal_problem) - end - end - - context "when filtering problems in :execution state" do - let(:states) { %w(execution) } - - it "returns only execution proposals" do - create(:problem, :finished, component: component, challenge: challenge) - create(:problem, :proposal, component: component, challenge: challenge) - - expect(subject.size).to eq(3) - expect(subject).to match_array(problems_list) - end - end - - context "when filtering problems in :finished state" do - let(:states) { %w(finished) } - - it "returns only finished proposals" do - finished_problem = create(:problem, :finished, component: component) - create(:problem, :proposal, component: component) - - expect(subject.size).to eq(1) - expect(subject).to include(finished_problem) - end - end - end - - describe "SDGs filter" do - context "when none is selected" do - it "does not apply the filter" do - expect(subject).to match_array(problems_list) - end - end - - context "when one SDG is selected" do - let(:sdg_code) { :zero_hunger } - let!(:challenge_w_sdg) { create(:challenge, component: challenge.component, sdg_code: sdg_code) } - let!(:problem_w_sdg) { create(:problem, component: component, challenge: challenge_w_sdg) } - let(:sdgs_codes) { [sdg_code] } - - it "returns the problems associated to the given SDG" do - expect(subject.pluck(:id)).to match_array([problem_w_sdg.id]) - end - end - end - - # describe "related_to filter" do - pending "when filtering by related to problems" - # let(:related_to) { 'Decidim::Meetings::Meeting'.underscore } - # let(:problems_component) { create(:component, manifest_name: 'problems', participatory_space: participatory_process) } - # let(:problem) { create :problem, component: problems_component } - - # it "returns only problems related to problems" - # related_problem = create(:problem, :accepted, component: component) - # related_problem_2 = create(:problem, :accepted, component: component) - # create_list(:problem, 3, component: component) - # problem.link_resources([related_problem], 'problems_from_problem') - # related_problem_2.link_resources([problem], 'problems_from_problem') - - # expect(subject).to match_array([related_problem, related_problem_2]) - # end - - pending "when filtering by related to resources" - # let(:related_to) { 'Decidim::DummyResources::DummyResource'.underscore } - # let(:dummy_component) { create(:component, manifest_name: 'dummy', participatory_space: participatory_process) } - # let(:dummy_resource) { create :dummy_resource, component: dummy_component } - - # it "returns only problems related to results" - # related_problem = create(:problem, :accepted, component: component) - # related_problem_2 = create(:problem, :accepted, component: component) - # create_list(:problem, 3, component: component) - # dummy_resource.link_resources([related_problem], 'included_problems') - # related_problem_2.link_resources([dummy_resource], 'included_problems') - - # expect(subject).to match_array([related_problem, related_problem_2]) - # end - # end - end - end - end -end diff --git a/spec/services/decidim/search_scopes_examples.rb b/spec/services/decidim/search_scopes_examples.rb deleted file mode 100644 index 6a791bac..00000000 --- a/spec/services/decidim/search_scopes_examples.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -RSpec.shared_context "with example scopes" do - let(:scope_1) { create :scope, organization: component.organization } - let(:scope_2) { create :scope, organization: component.organization } - let(:subscope_1) { create :scope, organization: component.organization, parent: scope_1 } -end - -# Parameters: -# scope_filter_param_name - is the symbol corresponding to the name used for the filter's parameter. -# -RSpec.shared_examples "search scope filter" do |scope_filter_param_name| - context "when a parent scope id is being sent" do - let(scope_filter_param_name) { [scope_1.id] } - - it "filters resources by scope" do - expect(subject).to match_array [resource_1, resource_3] - end - end - - context "when a subscope id is being sent" do - let(scope_filter_param_name) { [subscope_1.id] } - - it "filters resources by scope" do - expect(subject).to eq [resource_3] - end - end - - context "when multiple ids are sent" do - let(scope_filter_param_name) { [scope_2.id, scope_1.id] } - - it "filters resources by scope" do - expect(subject).to match_array [resource_1, resource_2, resource_3] - end - end - - context "when `global` is being sent" do - let(scope_filter_param_name) { ["global"] } - - it "returns resources without a scope" do - expect(subject.pluck(:id).sort).to eq(resources_list.pluck(:id) + [resource_without_scope.id]) - end - end - - context "when `global` and some ids is being sent" do - let(scope_filter_param_name) { ["global", scope_2.id, scope_1.id] } - - it "returns resources without a scope and with selected scopes" do - expect(subject.pluck(:id)).to match_array(resources_list.pluck(:id) + [resource_without_scope.id, resource_1.id, resource_2.id, resource_3.id]) - end - end -end diff --git a/spec/services/decidim/solutions/solution_search_spec.rb b/spec/services/decidim/solutions/solution_search_spec.rb deleted file mode 100644 index 756357ef..00000000 --- a/spec/services/decidim/solutions/solution_search_spec.rb +++ /dev/null @@ -1,133 +0,0 @@ -# frozen_string_literal: true - -require "spec_helper" -require_relative "../search_scopes_examples" - -module Decidim - module Solutions - describe SolutionSearch do - let!(:challenge) { create(:challenge) } - let!(:problem) { create(:problem, challenge: challenge) } - let(:component) { create(:solutions_component, organization: challenge.component.organization) } - let(:participatory_process) { component.participatory_space } - let!(:solutions_list) { create_list(:solution, 3, component: component, problem: problem) } - - describe "results" do - subject do - described_class.new( - component: component, - search_text_cont: search_text_cont, - with_any_state: states, - with_related_to: related_to, - with_any_territorial_scope_id: territorial_scope_ids, - with_any_category_id: category_ids, - with_any_sdgs_codes: sdgs_codes - ).result - end - - let(:search_text_cont) { nil } - let(:related_to) { nil } - let(:states) { nil } - let(:territorial_scope_ids) { nil } - let(:category_ids) { nil } - let(:sdgs_codes) { nil } - - it "only includes solutions from the given component" do - other_solution = create(:solution, problem: problem) - - expect(subject).to match_array(solutions_list) - expect(subject).not_to include(other_solution) - end - - describe "search_text_cont filter" do - let(:search_text_cont) { "dog" } - - it "returns the solutions containing the search in the title or the body" do - dog_solution = create(:solution, title: { I18n.locale => "A dog" }, component: component) - - expect(subject).to include(dog_solution) - expect(subject.size).to eq(1) - end - end - - describe "challenge territorial scopes" do - include_context "with example scopes" - - let(:challenges_component) { create(:challenges_component, participatory_space: component.participatory_space) } - let!(:challenge_without_scope) { create(:challenge, component: challenges_component, scope: nil) } - let!(:challenge_1) { create(:challenge, component: challenges_component, scope: scope_1) } - let!(:challenge_2) { create(:challenge, component: challenges_component, scope: scope_2) } - let!(:challenge_3) { create(:challenge, component: challenges_component, scope: subscope_1) } - - let(:problems_component) { create(:problems_component, participatory_space: component.participatory_space) } - let!(:problem_without_scope) { create(:problem, component: problems_component, challenge: challenge_without_scope) } - let!(:problem_1) { create(:problem, component: problems_component, challenge: challenge_1) } - let!(:problem_2) { create(:problem, component: problems_component, challenge: challenge_2) } - let!(:problem_3) { create(:problem, component: problems_component, challenge: challenge_3) } - - let(:resources_list) { solutions_list } - let!(:resource_without_scope) { create(:solution, component: component, problem: problem_without_scope) } - let!(:resource_1) { create(:solution, component: component, problem: problem_1) } - let!(:resource_2) { create(:solution, component: component, problem: problem_2) } - let!(:resource_3) { create(:solution, component: component, problem: problem_3) } - - context "with sectorial_scope_ids" do - include_examples "search scope filter", "territorial_scope_ids" - end - end - - describe "SDGs filter" do - context "when none is selected" do - it "does not apply the filter" do - expect(subject).to match_array(solutions_list) - end - end - - context "when one SDG is selected" do - let(:sdg_code) { :partnership } - let!(:challenge_w_sdg) { create(:challenge, component: challenge.component, sdg_code: sdg_code) } - let!(:problem_w_sdg) { create(:problem, component: problem.component, challenge: challenge_w_sdg) } - let!(:solution_w_sdg) { create(:solution, component: component, problem: problem_w_sdg) } - let(:sdgs_codes) { [sdg_code] } - - it "returns the solutions associated to the given SDG" do - expect(subject.pluck(:id)).to match_array([solution_w_sdg.id]) - end - end - end - - # describe "related_to filter" do - pending "when filtering by related to solutions" - # let(:related_to) { 'Decidim::Meetings::Meeting'.underscore } - # let(:solutions_component) { create(:component, manifest_name: 'solutions', participatory_space: participatory_process) } - # let(:solution) { create :solution, component: solutions_component } - - # it "returns only solutions related to solutions" - # related_solution = create(:solution, :accepted, component: component) - # related_solution_2 = create(:solution, :accepted, component: component) - # create_list(:solution, 3, component: component) - # solution.link_resources([related_solution], 'solutions_from_solution') - # related_solution_2.link_resources([solution], 'solutions_from_solution') - - # expect(subject).to match_array([related_solution, related_solution_2]) - # end - - pending "when filtering by related to resources" - # let(:related_to) { 'Decidim::DummyResources::DummyResource'.underscore } - # let(:dummy_component) { create(:component, manifest_name: 'dummy', participatory_space: participatory_process) } - # let(:dummy_resource) { create :dummy_resource, component: dummy_component } - - # it "returns only solutions related to results" - # related_solution = create(:solution, :accepted, component: component) - # related_solution_2 = create(:solution, :accepted, component: component) - # create_list(:solution, 3, component: component) - # dummy_resource.link_resources([related_solution], 'included_solutions') - # related_solution_2.link_resources([dummy_resource], 'included_solutions') - - # expect(subject).to match_array([related_solution, related_solution_2]) - # end - # end - end - end - end -end From 248cd9718815ba958875cf4e550f3bc472de8a24 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 27 Oct 2023 13:20:26 +0200 Subject: [PATCH 11/15] Change CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b08780d2..7308f32f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ Following Semantic Versioning 2. ## Version 0.3.0 (MINOR) - Increase minimum Decidim version to 0.27.4 +- Refactor scope, category and SDG filters with Ransack +- Fix when save challenge in CRUD solutions when there is a associated problem. ## Version 0.2.1 (MINOR) - Upgrade module's Ruby to 3.0.6 From c590345560ce0f35992dd2c00ee2965689e9a195 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 27 Oct 2023 13:35:09 +0200 Subject: [PATCH 12/15] Fix command tests --- spec/commands/decidim/solutions/admin/create_solution_spec.rb | 4 ++-- spec/commands/decidim/solutions/admin/update_solution_spec.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/commands/decidim/solutions/admin/create_solution_spec.rb b/spec/commands/decidim/solutions/admin/create_solution_spec.rb index 7699afb3..001d1c67 100644 --- a/spec/commands/decidim/solutions/admin/create_solution_spec.rb +++ b/spec/commands/decidim/solutions/admin/create_solution_spec.rb @@ -127,9 +127,9 @@ module Admin expect { subject.call }.to change(Solution, :count).by(1) end - it "sets the challenge" do + it "challenge is nil" do subject.call - expect(solution.challenge).to eq challenge + expect(solution.challenge).to eq nil end it "sets the component" do diff --git a/spec/commands/decidim/solutions/admin/update_solution_spec.rb b/spec/commands/decidim/solutions/admin/update_solution_spec.rb index 325a430f..a8a16a9d 100644 --- a/spec/commands/decidim/solutions/admin/update_solution_spec.rb +++ b/spec/commands/decidim/solutions/admin/update_solution_spec.rb @@ -136,9 +136,9 @@ module Admin expect(translated(solution.title)).to eq title end - it "sets challenge" do + it "challenge is nil" do subject.call - expect(solution.challenge).to eq(challenge) + expect(solution.challenge).to eq nil end it "sets the tags" do From 8335e3704e9480fc6eb3d3d8794a8d46d476b1f0 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Fri, 27 Oct 2023 14:16:26 +0200 Subject: [PATCH 13/15] Fix SDGs tests --- .../challenges/filter_challenges_spec.rb | 10 ++++++---- .../decidim/problems/filter_problems_spec.rb | 9 ++++++--- .../decidim/solutions/filter_solutions_spec.rb | 17 ++++++++++------- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/spec/system/decidim/challenges/filter_challenges_spec.rb b/spec/system/decidim/challenges/filter_challenges_spec.rb index b7e76334..fa975004 100644 --- a/spec/system/decidim/challenges/filter_challenges_spec.rb +++ b/spec/system/decidim/challenges/filter_challenges_spec.rb @@ -187,10 +187,12 @@ before do find(".filters__section.sdgs-filter button").click expect(page).to have_css("#sdgs-modal") - # TODO: not works! any webpacker stuff - find('#sdgs-modal .sdg-cell[data-value="no_poverty"]').click - find('#sdgs-modal .sdg-cell[data-value="good_health"]').click - find("#sdgs-modal .reveal__footer a.button").click + + within "#sdgs-modal" do + find('.sdg-cell[data-value="no_poverty"]').click + find('.sdg-cell[data-value="good_health"]').click + find(".reveal__footer a.button").click + end end it "lists the challenges with the selected SDGs" do diff --git a/spec/system/decidim/problems/filter_problems_spec.rb b/spec/system/decidim/problems/filter_problems_spec.rb index f74ae7d1..55e06df9 100644 --- a/spec/system/decidim/problems/filter_problems_spec.rb +++ b/spec/system/decidim/problems/filter_problems_spec.rb @@ -130,9 +130,12 @@ before do find(".filters__section.sdgs-filter button").click expect(page).to have_css("#sdgs-modal") - find('#sdgs-modal .sdg-cell[data-value="no_poverty"]').click - find('#sdgs-modal .sdg-cell[data-value="good_health"]').click - find("#sdgs-modal .reveal__footer a.button").click + + within "#sdgs-modal" do + find('.sdg-cell[data-value="no_poverty"]').click + find('.sdg-cell[data-value="good_health"]').click + find(".reveal__footer a.button").click + end end it "lists the problems with the selected SDGs" do diff --git a/spec/system/decidim/solutions/filter_solutions_spec.rb b/spec/system/decidim/solutions/filter_solutions_spec.rb index d25f1ba0..c39e956a 100644 --- a/spec/system/decidim/solutions/filter_solutions_spec.rb +++ b/spec/system/decidim/solutions/filter_solutions_spec.rb @@ -52,16 +52,16 @@ before do challenge = create(:challenge, component: challenges_component, sdg_code: :no_poverty) problem = create(:problem, component: problems_component, challenge: challenge) - create_list(:solution, 2, component: component, problem: problem) + create_list(:solution, 2, component: component, problem: problem, challenge: challenge) challenge = create(:challenge, component: challenges_component, sdg_code: :zero_hunger) problem = create(:problem, component: problems_component, challenge: challenge) - create(:solution, component: component, problem: problem) + create(:solution, component: component, problem: problem, challenge: challenge) challenge = create(:challenge, component: challenges_component, sdg_code: :good_health) problem = create(:problem, component: problems_component, challenge: challenge) - create(:solution, component: component, problem: problem) + create(:solution, component: component, problem: problem, challenge: challenge) challenge = create(:challenge, component: challenges_component) problem = create(:problem, component: problems_component, challenge: challenge) - create(:solution, component: component, problem: problem) + create(:solution, component: component, problem: problem, challenge: challenge) visit_component end @@ -80,9 +80,12 @@ before do find(".filters__section.sdgs-filter button").click expect(page).to have_css("#sdgs-modal") - find('#sdgs-modal .sdg-cell[data-value="no_poverty"]').click - find('#sdgs-modal .sdg-cell[data-value="good_health"]').click - find("#sdgs-modal .reveal__footer a.button").click + + within "#sdgs-modal" do + find('.sdg-cell[data-value="no_poverty"]').click + find('.sdg-cell[data-value="good_health"]').click + find(".reveal__footer a.button").click + end end it "lists the solutions with the selected SDGs" do From 7f618f509b979923a12f2d5129998eff2bbed1d4 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Mon, 13 Nov 2023 17:28:57 +0100 Subject: [PATCH 14/15] Extract duplicated code --- .../decidim/solutions/admin/create_solution.rb | 14 +++----------- .../decidim/solutions/admin/update_solution.rb | 14 +++----------- lib/decidim/challenges.rb | 9 +++++++++ 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/app/commands/decidim/solutions/admin/create_solution.rb b/app/commands/decidim/solutions/admin/create_solution.rb index a6ac30ec..1e38ef2b 100644 --- a/app/commands/decidim/solutions/admin/create_solution.rb +++ b/app/commands/decidim/solutions/admin/create_solution.rb @@ -5,6 +5,8 @@ module Solutions module Admin # A command with all the business logic when a user creates a new solution. class CreateSolution < Decidim::Command + include Decidim::Challenges + # Public: Initializes the command. # # form - A form object with the params. @@ -39,7 +41,7 @@ def create_solution! description: parsed_attribute(:description), component: form.current_component, decidim_problems_problem_id: form.decidim_problems_problem_id, - decidim_challenges_challenge_id: challenge, + decidim_challenges_challenge_id: challenge_id, tags: form.tags, objectives: parsed_attribute(:objectives), indicators: parsed_attribute(:indicators), @@ -55,16 +57,6 @@ def create_solution! visibility: "all" ) end - - def parsed_attribute(attribute) - Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite - end - - def challenge - problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) - - problem.present? ? problem.decidim_challenges_challenge_id.presence || nil : nil - end end end end diff --git a/app/commands/decidim/solutions/admin/update_solution.rb b/app/commands/decidim/solutions/admin/update_solution.rb index a2694aba..66e56272 100644 --- a/app/commands/decidim/solutions/admin/update_solution.rb +++ b/app/commands/decidim/solutions/admin/update_solution.rb @@ -5,6 +5,8 @@ module Solutions module Admin # A command with all the business logic when a user updates a Solution. class UpdateSolution < Decidim::Command + include Decidim::Challenges + # Public: Initializes the command. # # form - A form object with the params. @@ -49,7 +51,7 @@ def attributes description: parsed_attribute(:description), component: form.current_component, decidim_problems_problem_id: form.decidim_problems_problem_id, - decidim_challenges_challenge_id: challenge, + decidim_challenges_challenge_id: challenge_id, tags: form.tags, objectives: parsed_attribute(:objectives), indicators: parsed_attribute(:indicators), @@ -58,16 +60,6 @@ def attributes financing_type: parsed_attribute(:financing_type), } end - - def parsed_attribute(attribute) - Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite - end - - def challenge - problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) - - problem.present? ? problem.decidim_challenges_challenge_id.presence || nil : nil - end end end end diff --git a/lib/decidim/challenges.rb b/lib/decidim/challenges.rb index 3bb1839d..08b6b55f 100644 --- a/lib/decidim/challenges.rb +++ b/lib/decidim/challenges.rb @@ -9,5 +9,14 @@ module Decidim # This namespace holds the logic of the `Challenges` component. This component # allows users to create challenges in a participatory space. module Challenges + def parsed_attribute(attribute) + Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite + end + + def challenge_id + problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) + + problem&.decidim_challenges_challenge_id.presence + end end end From 100a0bd310421b2e54550b0cbee99a95d14179c7 Mon Sep 17 00:00:00 2001 From: Laura Jaime Date: Mon, 20 Nov 2023 13:35:39 +0100 Subject: [PATCH 15/15] Fix tests and move shared code to a command helper --- app/commands/decidim/command_utils.rb | 20 +++++++++++++++++++ .../solutions/admin/create_solution.rb | 1 + .../solutions/admin/update_solution.rb | 1 + lib/decidim/challenges.rb | 9 --------- .../solutions/admin/create_solution_spec.rb | 4 ++-- .../solutions/admin/update_solution_spec.rb | 4 ++-- 6 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 app/commands/decidim/command_utils.rb diff --git a/app/commands/decidim/command_utils.rb b/app/commands/decidim/command_utils.rb new file mode 100644 index 00000000..a62b863e --- /dev/null +++ b/app/commands/decidim/command_utils.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Decidim + module CommandUtils + def parsed_attribute(attribute) + Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite + end + + def challenge_id + challenge = form.decidim_challenges_challenge_id + problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) + + if challenge.present? + Decidim::Challenges::Challenge.find(form.decidim_challenges_challenge_id).id + else + problem&.decidim_challenges_challenge_id.presence + end + end + end +end diff --git a/app/commands/decidim/solutions/admin/create_solution.rb b/app/commands/decidim/solutions/admin/create_solution.rb index 1e38ef2b..75fb9e75 100644 --- a/app/commands/decidim/solutions/admin/create_solution.rb +++ b/app/commands/decidim/solutions/admin/create_solution.rb @@ -6,6 +6,7 @@ module Admin # A command with all the business logic when a user creates a new solution. class CreateSolution < Decidim::Command include Decidim::Challenges + include Decidim::CommandUtils # Public: Initializes the command. # diff --git a/app/commands/decidim/solutions/admin/update_solution.rb b/app/commands/decidim/solutions/admin/update_solution.rb index 66e56272..9134e99d 100644 --- a/app/commands/decidim/solutions/admin/update_solution.rb +++ b/app/commands/decidim/solutions/admin/update_solution.rb @@ -6,6 +6,7 @@ module Admin # A command with all the business logic when a user updates a Solution. class UpdateSolution < Decidim::Command include Decidim::Challenges + include Decidim::CommandUtils # Public: Initializes the command. # diff --git a/lib/decidim/challenges.rb b/lib/decidim/challenges.rb index 08b6b55f..3bb1839d 100644 --- a/lib/decidim/challenges.rb +++ b/lib/decidim/challenges.rb @@ -9,14 +9,5 @@ module Decidim # This namespace holds the logic of the `Challenges` component. This component # allows users to create challenges in a participatory space. module Challenges - def parsed_attribute(attribute) - Decidim::ContentProcessor.parse_with_processor(:hashtag, form.send(attribute), current_organization: form.current_organization).rewrite - end - - def challenge_id - problem = Decidim::Problems::Problem.find_by(id: form.decidim_problems_problem_id) - - problem&.decidim_challenges_challenge_id.presence - end end end diff --git a/spec/commands/decidim/solutions/admin/create_solution_spec.rb b/spec/commands/decidim/solutions/admin/create_solution_spec.rb index 001d1c67..7699afb3 100644 --- a/spec/commands/decidim/solutions/admin/create_solution_spec.rb +++ b/spec/commands/decidim/solutions/admin/create_solution_spec.rb @@ -127,9 +127,9 @@ module Admin expect { subject.call }.to change(Solution, :count).by(1) end - it "challenge is nil" do + it "sets the challenge" do subject.call - expect(solution.challenge).to eq nil + expect(solution.challenge).to eq challenge end it "sets the component" do diff --git a/spec/commands/decidim/solutions/admin/update_solution_spec.rb b/spec/commands/decidim/solutions/admin/update_solution_spec.rb index a8a16a9d..325a430f 100644 --- a/spec/commands/decidim/solutions/admin/update_solution_spec.rb +++ b/spec/commands/decidim/solutions/admin/update_solution_spec.rb @@ -136,9 +136,9 @@ module Admin expect(translated(solution.title)).to eq title end - it "challenge is nil" do + it "sets challenge" do subject.call - expect(solution.challenge).to eq nil + expect(solution.challenge).to eq(challenge) end it "sets the tags" do