Commit Graph

20617 Commits

Author SHA1 Message Date
Javi Martín
f35916cbb9 Upgrade Ruby to version 3.3.10
We're also updating the parser gem so we don't get any warnings.
2025-10-27 13:18:01 +01:00
taitus
d338417432 Remove obsolete Foundation meta generator tag
This meta tag was added years ago as a workaround for
foundation-sites issue 12167, in commit 791b2e12 from PR 4753
("Fix invalid HTML in application layout").

Since we now use foundation-sites >= 6.8.1 (fixed in 6.7.1),
the workaround is unnecessary.
2025-10-23 16:04:34 +02:00
Javi Martín
cb85d5d401 Merge pull request #6121 from consuldemocracy/add_csv_to_gemfile
Explicitly add csv to Gemfile
2025-10-23 11:01:23 +02:00
Javi Martín
361e4e08a6 Explicitly add csv to Gemfile
We were getting a warning on staging and production environments:

```
app/models/local_census_records/import.rb:1: warning: csv was loaded
from the standard library, but will no longer be part of the default
gems starting from Ruby 3.4.0.

You can add csv to your Gemfile or gemspec to silence this warning
```

The reason we weren't getting this warning during development is that we
do have `csv` in our `Gemfile.lock`, but only in development
environments, since it's an indirect dependency of pronto. On production
environments, we don't install pronto or its dependencies, though.

We can reproduce the warning locally by temporarily removing the pronto
gems from the Gemfile, running `bundle install` and starting a rails
console.
2025-10-22 21:15:58 +02:00
Sebastia
05204f0e5b Merge pull request #6119 from consuldemocracy/i18n_crowdin
Update translations from Crowdin
2025-10-22 15:17:31 +02:00
Javi Martín
be6f5857d7 Merge pull request #6113 from consuldemocracy/saml_on_demand
Only access SAML single sign-on URL when necessary
2025-10-22 15:17:04 +02:00
Javi Martín
e092034483 Merge pull request #6118 from consuldemocracy/fix_notifications_scopes_tests
Use match_array in notifications scopes tests
2025-10-22 15:01:36 +02:00
Javi Martín
4332637c0f Only access SAML single sign-on URL when necessary
We were calling `parse_remote_to_hash` in the Devise initializer, which
runs when the application starts.

That meant that, if we got an exception when calling that method, the
application wouldn't start. We got exceptions if the single sign-on
(SSO) URL isn't available or we aren't providing the right credentials.

So we're moving the call to `parse_remote_to_hash` to
`OmniauthTenantSetup`, which is only called when actually trying to sign
in with SAML.

Since we're moving the code there, we're also unifying the code so SAML
settings are configured the same way for the main tenant and other
tenants, like we did for OpenID Connect in commit c3b523290.

In order to keep the existing behavior, we're caching the result of
`parse_remote_to_hash` in an instance variable. Not sure about the
advantages and disadvantages of doing so over parsing the remote URL
metadata on every SAML-related request.

Note that the SAML tests in `OmniauthTenantSetup` use the `stub_secrets`
method. But this method is called after the application has started,
meaning it doesn't stub calls to `Rails.application.secrets` in
`config/initializers/`. So, before this commit, the code that parsed the
IDP metadata URL wasn't executed in the tests. Since now we've moved the
code but we don't want to depend on external URLs when running the
tests, we need to stub the call to the external URL. Since we're now
stubbing the call, we're adding expectations in the tests to check that
we correctly use the settings returned in that call.
2025-10-22 12:25:43 +02:00
Javi Martín
0cb5d253f8 Use match_array in notifications scopes tests
The scopes don't define the order in which the records are returned, so,
when using `eq`, the tests failed sometimes.
2025-10-22 12:18:37 +02:00
Javi Martín
75f6bebc30 Don't set issuer and idp_metadata in SAML settings
The `issuer` setting was renamed to `sp_entity_id` in omniauth-saml [1],
and it's been deprecated in ruby-saml since version 1.11.0, released on
July 24, 2019 [2].

The ruby-saml code currently uses:

```
      def sp_entity_id
        @sp_entity_id || @issuer
      end
```

So setting `issuer` to the same value as `sp_entity_id` if
`sp_entity_id` is present, as we were doing, has no effect.

On the other hand, neither omniauth-saml nor ruby-saml use the
`idp_metadata_url` and `idp_metadata` settings.

[1] https://github.com/omniauth/omniauth-saml/commit/74ed8dfb3aed
[2] https://github.com/SAML-Toolkits/ruby-saml/releases/tag/v1.11.0
2025-10-22 11:50:56 +02:00
taitus
5ffee66985 Update translations from Crowdin 2025-10-22 11:38:07 +02:00
Javi Martín
3ad47e4819 Merge pull request #6115 from consuldemocracy/update_rails_in_gemfile
Update Gemfile to show the right version of Rails
2025-10-21 15:20:06 +02:00
Javi Martín
3642759ac8 Update Gemfile to show the right version of Rails
The "~> 7.1.5.1" part made it harder to know that we're using version
7.1.5.2 since commit 4f4bd0f71.
2025-10-21 12:03:34 +02:00
Javi Martín
c98d328879 Merge pull request #6117 from consuldemocracy/node20.19.5
Update Node.js from 20.19.2 to 20.19.5
2025-10-21 12:03:22 +02:00
Javi Martín
7e9e13ee90 Merge pull request #6116 from consuldemocracy/ruby3.3.9
Upgrade Ruby to version 3.3.9
2025-10-21 12:02:13 +02:00
Javi Martín
ff9c4b93ae Update Node.js from 20.19.2 to 20.19.5
This is the latest 20.x release as of October 17, 2025.
2025-10-17 19:45:07 +02:00
Javi Martín
c29da86a9e Upgrade Ruby to version 3.3.9
We're also updating the parser gem so we don't get any warnings.
2025-10-17 18:13:14 +02:00
Javi Martín
3732443d1b Merge pull request #6112 from consuldemocracy/postgres14
Use postgreSQL 14 as postgres Docker image
2025-10-17 16:09:47 +02:00
Javi Martín
5e5a0c5f65 Update PostgreSQL dependency to version 13
Version 12 isn't maintained since November 2024, and earlier versions
aren't maintained since way before that. Furthermore, we no longer know
whether these versions still work with the latest version of Consul
Democracy.

So we're upgrading the requirements to a version that is still supported
and that's expected to work.
2025-10-17 15:54:42 +02:00
Javi Martín
210a91bd8f Use postgreSQL 14 as postgres Docker image
PostgreSQL 13 will reach its end-of-life on November 13, 2025. So we're
upgrading before that happens.

We're also upgrading to PostgreSQL 14 in our CI. In this case, we're
using the default distribution (Trixie, as of October 2025); it doesn't
affect the development or production environments, so it's OK if use the
default one.
2025-10-17 14:00:52 +02:00
Javi Martín
9533029eb9 Specify distribution in postrgres Docker image
Debian 13 (Trixie) has become the default distribution for postgres
Docker images. However, we're using Debian 12 (Bookworm) for our Ruby
image. While it isn't strictly necessary, it makes sense to use the same
distribution in the two Docker images we depend on.
2025-10-17 14:00:52 +02:00
Javi Martín
700719a66d Merge pull request #6083 from consuldemocracy/oidc_multitenancy
Fix multitenancy support for OpenID Connect
2025-10-17 14:00:35 +02:00
Anamika Aggarwal
86bbfcaa0c Automatically set the redirect URI in OIDC
When we first added OIDC support, we were configuring the redirect URI
in the devise initializer, just like we did for other providers.

Thanks to the changes in the previous commit, that code is no longer in
the devise initializer, which means we can use `url_helpers` to get the
redirect URI.

This means we no longer need to define this URI in the secrets. This is
particularly useful for multitenancy; previously, we had to define the
redirect URI for every tenant because different tenants use different
domains or different subdomains.
2025-10-17 13:46:46 +02:00
Anamika Aggarwal
c3b5232907 Use the same code to configure OIDC for all tenants
We were following the same pattern as we used for other providers like
twitter or facebook, but for OIDC we aren't passing the key and the
secret as separate attributes but only a hash of options. This means we
don't need to duplicate the same logic in the devise initializer and the
`OmniauthTenantSetup` class.

Thanks to these changes, we'll be able to introduce dynamic redirect
URLs for both the default tenant and the other tenants (see next commit).

Note that we could probably apply similar changes for the SAML provider.
We might do so in the future. For other providers, removing the
references to `Rails.application.secrets` broke their configuration when
we tested it back in 2022 as part of the multitenancy feature. We might
check whether that's no longer the case (or whether we made a mistake
during our tests in 2022) in the future.
2025-10-17 13:29:15 +02:00
Anamika Aggarwal
d9a0887dc9 Fix OIDC parameters for non-default tenants
We were using the `client_options` hash for the default tenant, defined
in the Devise initializer, but we forgot to include that key in the
multitenant code. This means OIDC wasn't working when different tenants
used different configurations.
2025-10-17 13:29:15 +02:00
Javi Martín
847d48d478 Merge pull request #6082 from consuldemocracy/bump_highline
Bump highline from 2.0.3 to 3.1.2
2025-10-16 16:08:54 +02:00
Javi Martín
e63d90a9ee Bump highline from 2.0.3 to 3.1.2
We were getting this warning when running i18n-tasks:

```
lib/ruby/gems/3.3.0/gems/highline-2.0.3/lib/highline/import.rb:10:
warning: abbrev was loaded from the standard library, but will no longer
be part of the default gems starting from Ruby 3.4.0
```

We're updating the highline gem so we don't get this warning.
2025-10-16 15:41:39 +02:00
Sebastia
a73c1184fa Merge pull request #6061 from consuldemocracy/poll_text_answers
Add support for essay poll questions
2025-10-16 15:30:22 +02:00
taitus
b1cb6f8372 Exclude open-ended questions from managing physical votes
Also make the :yes_no factory trait create a votation_type_unique
by default, since yes/no questions should always be unique.
2025-10-16 14:31:16 +02:00
taitus
f3050a1aa5 Manage correctly results and stats for open-ended questions
Note that we are not including Poll::PartialResults for open-ended
questions resutls. The reason is that we do not contemplate the
possibility of there being open questions in booths. Manually
counting and introducing the votes in the system is not feasible.
2025-10-16 14:26:30 +02:00
taitus
2a2edd17d1 Move results specs to Polls::ResultsComponent
Running tests at the component level is faster than at the system level,
so we move tests from system/polls/results_spec.rb to the component.

Note that moving these tests removes vote_for_poll_via_web and the visit
to results_poll_path, but both are already covered in other tests. We
also take the opportunity to reuse the method in another test where
it makes sense.

Additionally, the spec title has been reverted from "Results for polls
with questions but without options" to "renders results for polls with
questions but without answers", as it was before commit 8997ed316c.
2025-10-16 11:09:36 +02:00
taitus
5a69ffc619 Reduce duplicated code and simplify code related with link_to_poll method 2025-10-16 11:09:36 +02:00
taitus
5944bb85c5 Use a loop instead of with_collection to render questions
This is what we usually do in components.
2025-10-16 11:09:36 +02:00
taitus
83b206f0b7 Enable voting for open-ended questions in public section 2025-10-16 11:09:36 +02:00
taitus
62e1c13e7e Use option instead of answer text to find multiple answers 2025-10-16 11:09:36 +02:00
taitus
b4b00487cc Add validations for changing votation type 2025-10-16 11:09:34 +02:00
taitus
9ff167d040 Use option instead of answer when sampling question options
We were still assigning answer: question.question_options.sample.title,
which made sense before we introduced the option association.
2025-10-15 15:52:14 +02:00
taitus
b3f8ba819b Adapt 'show' view for open questions without options
- Prevent creating options for open questions
- Skip rendering the options table when none exist
2025-10-15 15:52:14 +02:00
taitus
d3f32978c8 Hide "Maximum number of votes" message for unique and open-ended questions
The "Maximum number of votes" text in poll question show was unnecessary.
It appeared for both unique and open-ended questions, but it only makes
sense for questions that allow multiple answers.
2025-10-15 15:52:14 +02:00
taitus
69eaf66b93 Remove redundant max_votes validation from Poll::Answer
Since commit 8deb1964b, the `WebVote` class enforces the maximum vote
validation, making the `max_votes` method in `Poll::Answer` redundant.
2025-10-15 15:52:14 +02:00
taitus
4e57e311dc Add support for open-ended questions in admin section
Introduce a new "open" votation type for poll questions in the admin
interface. This type allows open answers provided by the user.
2025-10-15 15:52:12 +02:00
Javi Martín
4698d9a703 Merge pull request #6110 from consuldemocracy/dependabot/bundler/rack-2.2.20
Bump rack from 2.2.19 to 2.2.20
2025-10-11 16:20:10 +02:00
dependabot[bot]
3e51f0f2ac Bump rack from 2.2.19 to 2.2.20
Bumps [rack](https://github.com/rack/rack) from 2.2.19 to 2.2.20.
- [Release notes](https://github.com/rack/rack/releases)
- [Changelog](https://github.com/rack/rack/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rack/rack/compare/v2.2.19...v2.2.20)

---
updated-dependencies:
- dependency-name: rack
  dependency-version: 2.2.20
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-10 19:08:55 +00:00
taitus
eb10a3135b Refactor vote type descriptions to use data attributes
This makes it easier to extend support for new types (e.g., 'open')
without adding more conditional logic to the JavaScript.
2025-10-10 13:20:49 +02:00
Javi Martín
088837720a Merge pull request #6076 from johanndev1208/adds-notifications-managment
Add setting to require consent for notifications
2025-10-09 15:36:27 +02:00
Javi Martín
80d6f9c9dc Merge pull request #6109 from consuldemocracy/dependabot/bundler/rack-2.2.19
Bump rack from 2.2.18 to 2.2.19
2025-10-09 12:05:30 +02:00
Javi Martín
6d30e2d34e Don't display public activity by default when requiring consent
Just as we mentioned in the previous commit, there are places where we
aren't sure whether explicit consent is strictly required. So, when the
"require consent" setting is enabled, we're taking the safe approach.
This means that, in this case, we're only displaying a user's activity
if they've given explicit consent.
2025-10-09 10:56:21 +02:00
Johann
92a76dd46e Disable recommendations by default when requiring consent
The GDPR is open for interpretation, and it isn't clear whether showing
users recommended proposals and debates while browsing the site is
considered a notification that needs to be explicitly accepted.

Since we aren't sure whether this is necessary, we're taking the safe
approach and disabling recommendations by default.
2025-10-09 10:54:36 +02:00
Javi Martín
a1714fea58 Use the "#" convention in user preferences methods tests
This is a convention we follow most of the time, particularly in the
last few years.
2025-10-09 10:53:04 +02:00
Johann
e7f2210380 Add setting to require consent for notifications
Ensure GDPR compliance by default (Article 25 GDPR – privacy by design
and by default). Under GDPR, consent must be freely given, specific,
informed and unambiguous [1]. We were subscribing users without
explicity consent, which goes against the "No pre-ticked boxes"
principle.

For compatibility with existing installations, we're using a setting,
disabled by default. Once we release version 2.4.0 we will enable it by
default, which won't affect existing installations but only new ones.

[1] https://gdprinfo.eu/best-gdpr-newsletter-consent-examples-a-complete-guide-to-compliant-email-marketing
2025-10-09 10:53:00 +02:00