Commit Graph

20245 Commits

Author SHA1 Message Date
Javi Martín
364fa2603c Raise exceptions when assigning to attr_readonly attributes
Since we don't use attr_readonly, this option doesn't really affect us.
So we're just using the new default value.
2025-05-20 15:38:52 +02:00
Javi Martín
a1ae4651ff Simplify the way to set the maximum log size
We can use the new configuration option in Rails 7.1, so we don't have
to configure it manually.
2025-05-20 15:38:52 +02:00
Javi Martín
5db773e44f Serialize message data and metadata together
This is the new default option, and its only dangerous when deploying to
applications with multiple servers. Since this isn't our case, we can
enable it.
2025-05-20 15:38:52 +02:00
Javi Martín
e08ba7efbe Use JSON to serialize messages
The new serializer can decrypt legacy messages using the `marshal`
serializer, so there's no risk of losing data when upgrading. Since we
aren't using applications with several servers, where upgrading some
servers might cause issues on the servers that aren't upgraded yet,
we're enabling the option.

[1] See comments in pull request 42846 in https://github.com/rails/rails
2025-05-20 15:38:52 +02:00
Javi Martín
36828ee86b Use SQLCommenter format to format tags in Query Logs
Don't really care about the format, so we'll use the new default one.
2025-05-20 15:38:52 +02:00
Javi Martín
9054d31ab3 Raise exceptions on invalid cache expiration time
It doesn't really affect us (unless some of our dependencies make this
mistake) because we only use `expires_in/expires_at` once and we do it
correctly, but it might be help us detect this issue if we ever
introduce it in the future.
2025-05-20 15:38:51 +02:00
Javi Martín
e45dc5d45a Use BigDecimal argument serializer in Active Job
This option won't even exist in Rails 7.2 [1], and the possibility to
disable it was only added to guarantee safe upgrades in Rails
applications with multiple replicas [2].

Since we don't have applications with multiple replicas, where one
replica could be using Active Job 7.0 and another one could be using
Active Job 7.1 while upgrading, we can enable this options.

[1] Commit 2a761d23d2 in https://github.com/rails/rails
[2] Commit bc1f323338 in https://github.com/rails/rails
2025-05-20 15:38:51 +02:00
Javi Martín
2bedfacf3b Disable deprecated singular association names
This doesn't affect us (since luckily we never use them), and, since
doing something like `Budget::Investment.where(budgets: 1)` would be
very confusing, getting an error when writing this code is IMHO better
than just getting a warning, which was the default before Rails 7.1 [1].

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-active-record-allow-deprecated-singular-associations-name
2025-05-20 15:38:51 +02:00
Javi Martín
c0bc9bd027 Use Rails 7.1 default options for SQLite
It doesn't really affect us because we don't use SQLite.
2025-05-20 15:38:51 +02:00
Javi Martín
6eebe4e984 Don't run commit callbacks on first saved instances in transaction
It probably doesn't directly affect us, since we don't use
`after_commit` callbacks, and, among our dependencies, AFAIK only the
Devise gem uses them, to send the email with confirmation/reconfirmation
instructions.

The reasons for this change are explained in the guide to configure
Rails [1], while the pull request introducing the change has a couple of
great examples in its description [2].

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-active-record-run-commit-callbacks-on-first-saved-instances-in-transaction
[2] Pull request 45280 in https://github.com/rails/rails
2025-05-20 15:38:51 +02:00
Javi Martín
fbb40d701b Encrypt Active Record data using SHA256
Since we weren't encrypting any data, we can disable the
support_sha1_for_non_deterministic_encryption option, which should only
be enabled on existing applications that were encrypting data using
SHA1 [1].

[1] https://guides.rubyonrails.org/v7.1/upgrading_ruby_on_rails.html#active-record-encryption-algorithm-changes
2025-05-20 15:38:51 +02:00
Javi Martín
994d86ce2c Don't make ActionController::Parameters equivalent to Hash
The comparison equality was supposed to be deprecated since 2016 [1],
and completely deprecated in Rails 7.1 [2]. This options won't even
exist in the next version of Rails [3].

[1] Pull request 23733 in https://github.com/rails/rails
[2] Pull request 44812 in https://github.com/rails/rails
[3] https://github.com/rails/rails/commit/43e42c1ea
2025-05-20 15:38:51 +02:00
Javi Martín
402b64291c Use the new default headers
The only change between these headers and the ones sent by Rails 7.0
application is that the `"X-Download-Options" => "noopen"` is no longer
sent. Only Internet Explorer used that header, and uploading, previewing
and downloading attachments still works fine on Internet Explorer 11
after this change.

[1] Pull request 43968 in https://github.com/rails/rails
2025-05-20 15:38:51 +02:00
Javi Martín
77d113d640 Don't add autoload_paths to load_path
Quoting the Rails configuration guide [1]:

> applications running in :zeitwerk mode do not need require_dependency,
> so models, controllers, jobs, etc. do not need to be in $LOAD_PATH.
> Setting this to false saves Ruby from checking these directories when
> resolving require calls with relative paths, and saves Bootsnap work
> and RAM, since it does not need to build an index for them.

[1] https://guides.rubyonrails.org/v7.1/configuring.html#config-add-autoload-paths-to-load-path
2025-05-20 15:38:51 +02:00
Javi Martín
321409ab0a Use fixture_paths instead of fixture_path
We were getting a warning since we upgraded to Rails 7.1:

> Rails 7.1 has deprecated the singular fixture_path in favour of an
> array.You should migrate to plural:
2025-05-20 15:38:51 +02:00
Javi Martín
24a77c6437 Remove references to ActionDispatch::IllegalStateError
We were getting a warning after upgrading to Rails 7.1:

```
DEPRECATION WARNING: ActionDispatch::IllegalStateError is deprecated
without replacement.
```
2025-05-20 15:38:51 +02:00
Javi Martín
f5221536a9 Update show_exceptions options in system tests
We were getting a deprecation warning after upgrading to Rails 7.1:

```
DEPRECATION WARNING: Setting action_dispatch.show_exceptions to true is
deprecated. Set to :all instead.
```

So we're passing `:all`.

I've checked whether we can remove the `:show_exceptions` tag completely
now that the new default option is `:rescuable`. The answer is "no" ;).
Removing the `:show_exceptions` tag makes the tests fail.
2025-05-20 15:38:51 +02:00
Javi Martín
931ccc04fb Pass a keyword argument to the serialize method
We were getting the following warning after upgrading to Rails 7.1:

```
Rendered shared/_social_media_meta_tags.html.erb
DEPRECATION WARNING: Passing the class as positional argument is
deprecated and will be removed in Rails 7.2.
Please pass the class as a keyword argument:
  serialize :metadata, type: Object
```
2025-05-20 15:38:51 +02:00
Javi Martín
65e4a64084 Use preview_paths instead of preview_path
We were getting a deprecation warning in the logs after upgrading to
Rails 7.1:

```
DEPRECATION WARNING: Using preview_path= option is deprecated and will
be removed in Rails 7.2. Please use preview_paths= instead.
```

So we're appending a path to the `preview_paths`, as recommended in the
guide to upgrade to Rails 7.1 [1].

[1] https://guides.rubyonrails.org/v7.1/upgrading_ruby_on_rails.html#support-multiple-preview-paths-for-actionmailer-preview
2025-05-20 15:38:51 +02:00
Javi Martín
ce62da1f88 Silence deprecation warnings in secrets
We were getting a ton of deprecation warnings:

```
DEPRECATION WARNING: `Rails.application.secrets` is deprecated in favor
of `Rails.application.credentials` and will be removed in Rails 7.2
```

However, we don't plan to replace the secrets with credentials in the
foreseeable future because it would affect existing Consul Democracy
installations, so for now we're simply silencing the warnings.
2025-05-20 15:38:51 +02:00
Javi Martín
3d11aa86ce Fix ActiveStorage::IntegrityError when attaching PDFs
This is an error we've only been able to reproduce on one specific
machine and only when using the development environment.

It looks like Rails 7.1.5.1 uses `ActiveStorage::PreviewImageJob` when
we attach a PDF. However, that raises an IntegrityError because we're
removing the metadata from PDFs. That is, the final PDF is no longer the
same PDF that was uploaded.

This issue wasn't present in the original Rails 7.1.0 release, but was
introduced in Rails 7.1.4 [1] and has already been fixed in Rails 7.2.0
[2].

So we're applying the same solution that was applied in Rails 7.2.0:
disabling automatic previews for PDFs when no variants require them by
changing a method in `ActiveStorage::Attachment`.

[1] See commit 6f729dd39 in https://github.com/rails/rails/
[2] See pull request 51351 in https://github.com/rails/rails/
2025-05-20 15:38:47 +02:00
Javi Martín
0b1cfcd5da Upgrade to Rails 7.1
We're disabling `action_controller.raise_on_missing_callback_actions`
because sometimes we include `before_action :something, only: actions`
in concerns, and we include these concerns in controllers that don't
have all these actions.

Note that Rails 7.1 logs to STDOUT by default [1]; we're re-adding the
condition `if ENV["RAILS_LOG_TO_STDOUT"].present?` because we're still
using files and we're rotating the logs to avoid running out of space.

Also note that the GraphQL controller test (which is actually a request
test, since it's got `type: :request`) that was raising an exception no
longer does it thanks to the new default value for the
`config.action_dispatch.show_exceptions` configuration option. So we're
updating the test accordingly. This option doesn't affect regular
controller tests (without the `type: :request` option), so in other
tests we're still checking exceptions.

[1] Pull request 47138 in https://github.com/rails/rails
2025-05-20 13:12:29 +02:00
Javi Martín
3eaa40892d Extract method in GraphQL controller test
This way we remove a bit of duplication and it makes it easier to add
proper requests to other tests, which we're about to do.
2025-05-20 13:12:29 +02:00
Javi Martín
6288450ab4 Use a real browser in disabled features multitenancy test
We were using a rack browser and testing the
`FeatureFlags::FeatureDisabled` exception was raised. However, we don't
test this exception in any other system tests; we only check it in
controller tests.

So we're using a real browser for consistency and because in Rails 7.1
this test is failing when enabling the new default option
`config.action_dispatch.show_exceptions = :rescuable` in the test
environment.
2025-05-20 13:12:29 +02:00
Javi Martín
bd4fdff3d4 Avoid executing .includes(...).order("ids.ordering").ids
Apparently, the `ids` method, which originally was implemented as
`pluck(:id)`, sometimes returned duplicate ids [1]. Fixing that issue
generated another issue [2] when combining `.includes` and `order`.
There was an attempt to fix it [3], but it still doesn't fix the case
where the ordering column belongs to an association [4].

This means that, when upgrading to Rails 7.1, calling `.ids` on
`budget.investments.includes(:heading).sort_by_random.for_render`
results in an invalid SQL statement:

```
ActiveRecord::StatementInvalid:
PG::GroupingError: ERROR:  column "ids.ordering" must appear in
the GROUP BY clause or be used in an aggregate function
  LINE 1: ... = $4 GROUP BY "budget_investments"."id" ORDER BY
  ids.orderi...
```

To solve it, we could once again use `.pluck(:id)` instead of `ids`, but
I'm not sure whether there would be a risk to get duplicate IDs in some
cases. We cannot call `.reorder` or `.unscope(:order)` either because we
need the IDs to be ordered randomly.

So we're removing the `includes(:heading)` part when getting the IDs.
Since using `includes` generates a separate query that doesn't affect
the query to get the IDs, removing it makes no difference.

Another option would be to remove the `for_render` call, since we're
including the headings to avoid the N+1 queries problem, but we're doing
so without benchmarks showing that it does actually make a difference.

[1] Issue 46455 in https://github.com/rails/rails
[2] Issue 48080 in https://github.com/rails/rails
[3] Pull request 48101 in https://github.com/rails/rails
[4] Issue 50263 in https://github.com/rails/rails
2025-05-20 13:12:29 +02:00
Sebastia
40625e9455 Merge pull request #5984 from consuldemocracy/dependabot/bundler/rack-2.2.14
Bump rack from 2.2.13 to 2.2.14
2025-05-09 10:23:43 +02:00
dependabot[bot]
60e6f6a3b0 Bump rack from 2.2.13 to 2.2.14
Bumps [rack](https://github.com/rack/rack) from 2.2.13 to 2.2.14.
- [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.13...v2.2.14)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-08 19:25:00 +00:00
Sebastia
d9271c9a43 Merge pull request #5966 from consuldemocracy/remove-foundation-rails-helper
Vendor foundation_rails_helper/form_builder.rb to drop gem dependency
2025-05-06 18:02:13 +02:00
taitus
e662c704ac Vendor Foundation form builder to remove gem dependency
The "foundation_rails_helper" gem is no longer maintained and is
incompatible with Rails 7.1. To avoid blocking the upgrade, we've vendored
the vendor/foundation_rails_helper/form_builder.rb as a copy of the
original FormBuilder class.

To mantain compatibility with auto_labels and button_class variables, that
are used in the original builder, we are overwriting in the foundation
form builder initializer.

The gem has been removed from the Gemfile and replaced with this vendored
fallback. This workaround is safe to remove once legacy Foundation CSS
support is dropped.

All vendored code retains the original MIT license and attribution.
2025-05-06 17:07:08 +02:00
Sebastia
e93d303b1e Merge pull request #5867 from consuldemocracy/dependabot/bundler/ros-apartment-3.2.0
Bump ros-apartment from 2.11.0 to 3.2.0
2025-05-05 16:42:04 +02:00
Javi Martín
2ed07ded67 Merge pull request #5969 from consuldemocracy/dependabot/bundler/nokogiri-1.18.8
Bump nokogiri from 1.18.4 to 1.18.8
2025-05-05 15:18:24 +02:00
Javi Martín
b2a81a8784 Merge pull request #5971 from consuldemocracy/dependabot/bundler/net-imap-0.5.7
Bump net-imap from 0.5.6 to 0.5.7
2025-05-05 15:15:43 +02:00
Sebastia
391d924ec0 Merge pull request #5830 from consuldemocracy/dependabot/bundler/globalize-7.0.0
Bump globalize from 6.3.0 to 7.0.0
2025-04-30 14:45:28 +02:00
dependabot[bot]
efd7317adb Bump net-imap from 0.5.6 to 0.5.7
Bumps [net-imap](https://github.com/ruby/net-imap) from 0.5.6 to 0.5.7.
- [Release notes](https://github.com/ruby/net-imap/releases)
- [Commits](https://github.com/ruby/net-imap/compare/v0.5.6...v0.5.7)

---
updated-dependencies:
- dependency-name: net-imap
  dependency-version: 0.5.7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-29 01:54:51 +00:00
dependabot[bot]
b02bd9b117 Bump nokogiri from 1.18.4 to 1.18.8
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.18.4 to 1.18.8.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.18.4...v1.18.8)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-version: 1.18.8
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-22 04:55:49 +00:00
taitus
b07e429356 Remove monkey patch for connected_to in Rails 7
ros-apartment 3.0.0+ includes official support for connection handling in Rails 7,
so we no longer need to override `ActiveRecord::ConnectionHandling#connected_to`.

References: PR #194 and #243 in ros-apartment
2025-04-11 15:41:59 +02:00
dependabot[bot]
4d256b8a4e Bump ros-apartment from 2.11.0 to 3.2.0
Note we aren't updating concurrent-ruby (which Dependabot would have
updated) due to an incompatibility with Rails 7.0.

Bumps [ros-apartment](https://github.com/rails-on-services/apartment) from 2.11.0 to 3.2.0.
- [Release notes](https://github.com/rails-on-services/apartment/releases)
- [Changelog](https://github.com/rails-on-services/apartment/blob/development/legacy_CHANGELOG.md)
- [Commits](https://github.com/rails-on-services/apartment/compare/2.11.0...v3.2.0)

---
updated-dependencies:
- dependency-name: ros-apartment
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-11 15:41:45 +02:00
dependabot[bot]
6e90b0cdf4 Bump globalize from 6.3.0 to 7.0.0
Note we aren't updating concurrent-ruby (which Dependabot would have
updated) due to an incompatibility with Rails 7.0.

Bumps [globalize](https://github.com/globalize/globalize) from 6.3.0 to 7.0.0.
- [Release notes](https://github.com/globalize/globalize/releases)
- [Changelog](https://github.com/globalize/globalize/blob/main/CHANGELOG.md)
- [Commits](https://github.com/globalize/globalize/compare/v6.3.0...v7.0.0)

---
updated-dependencies:
- dependency-name: globalize
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-11 15:20:37 +02:00
Sebastia
7aeae565df Merge pull request #5949 from consuldemocracy/release_2.3.1
Release version 2.3.1
2025-04-08 16:54:54 +02:00
taitus
bd0c880331 Release version 2.3.1 2025-04-08 16:41:48 +02:00
Sebastia
293f6974bb Merge pull request #5956 from consuldemocracy/i18n_crowdin
Update translations from Crowdin
2025-04-07 15:55:27 +02:00
taitus
30da0bc626 Update translations from Crowdin 2025-04-07 15:41:49 +02:00
Javi Martín
77c78d0507 Merge pull request #5954 from consuldemocracy/fix_crowdin_excluded_language
Fix language code for Spanish in Crowdin config
2025-04-04 12:32:15 +02:00
Javi Martín
715bc5ef05 Fix language code for Spanish in Crowdin config
We were using `es`, which is the code we use in `config/locales/`, but
Crowdin actually uses `es-ES`.
2025-04-04 12:22:52 +02:00
Javi Martín
3f9ae66e94 Merge pull request #5951 from consuldemocracy/labels_instead_of_placeholders
Reduce the number of fields with placeholders
2025-04-03 15:33:17 +02:00
Javi Martín
9dee0d9824 Use a hint instead of a placeholder in retire explanation
A hint is much easier to read than a placeholder.
2025-04-03 15:01:01 +02:00
Javi Martín
50e8153583 Use a legend instead of a label to group option fields
Using a label for a non-existent element ID was invalid HTML.
2025-04-03 15:01:01 +02:00
Javi Martín
c6f1974c45 Use labels in nested option fields
We were using a placeholder, which is way less accessible than a label.

One issue here (which also happened before, but is now more obvious) is
that, when adding several options, there will be many fields with the
same label.

Another issue is that, for some languages, we're using texts like "Add a
closed answer", which might be confusing because we might be editing an
existing answer. The proper solution would probably be using the text
"Option 1", "Option 2", ... I'm not doing so right now because I'm not
sure that's a good option and because changing the text would mean
losing the existing translations.
2025-04-03 15:01:01 +02:00
Javi Martín
9308189a00 Use number fields to enter number of votes
This way the fields are easier to use, and we can get rid of the
placeholders.

Note we're simplifying the `answer_result_value` in order to make it
easier to return `0` instead of `nil` when the field is empty.

Also note there's a small change of behavior here; previously, these
fields were empty by default, and now their value is `0` by default, so
blindly clicking the "Save" button would send `0` instead of an empty
value. I don't think it's a big deal, though, but we need to keep that
in mind.
2025-04-03 15:01:01 +02:00
Javi Martín
ff3ada780d Use fieldsets and legends in officing results form
We were using <h3> tags instead of a combination of <fieldset> and
<legend> tags to group fields together.
2025-04-03 15:01:01 +02:00