Commit Graph

323 Commits

Author SHA1 Message Date
Javi Martín
7f749bb9bb Add and apply Style/CollectionQuerying rubocop rule
This rule was added in rubocop 1.77. We were following it most of the
time. It makes the code more readable in my humble opinion.
2025-11-05 14:27:12 +01:00
dependabot[bot]
cc9f7904ac Bump rubocop-rspec_rails from 2.30.0 to 2.31.0
We're changing the `.rubocop.yml` file because we were getting a
warning:

```
rubocop-rspec_rails extension supports plugin, specify `plugins:
rubocop-rspec_rails` instead of `require: rubocop-rspec_rails` in
.rubocop.yml.  For more information, see
https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
```

Bumps [rubocop-rspec_rails](https://github.com/rubocop/rubocop-rspec_rails) from 2.30.0 to 2.31.0.
- [Release notes](https://github.com/rubocop/rubocop-rspec_rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec_rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec_rails/compare/v2.30.0...v2.31.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec_rails
  dependency-version: 2.31.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-05 14:16:06 +01:00
Javi Martín
0ca94e5443 Add and apply Rails/FindByOrAssignmentMemoization rule
This rule was added in rubocop-rails 2.33.

At first, I wasn't very fond of this rule. It made the code less
readable even if it improved performace in some cases.

Then I realized that in the `Admin::MachineLearning::SettingComponent`
we were using `find_by` when we should be using `find_by!` instead, and
we detected that thanks to this rule.

So, only for that reason, I'm adding this rule, but I'm fine if we
remove it.
2025-11-05 11:51:23 +01:00
Javi Martín
048bdb2e9e Add and apply Rails/OrderArguments rubocop rule
This rule was introduced in rubocop-rails 2.33. We were following it
most of the time.
2025-11-05 11:51:23 +01:00
dependabot[bot]
0c5dc24cc2 Bump rubocop-rails from 2.29.1 to 2.33.4
We're changing the `.rubocop.yml` file because we were getting a
warning:

```
rubocop-rails extension supports plugin, specify `plugins:
rubocop-rails` instead of `require: rubocop-rails` in .rubocop.yml. For
more information, see
https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
```

Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.29.1 to 2.33.4.
- [Release notes](https://github.com/rubocop/rubocop-rails/releases)
- [Changelog](https://github.com/rubocop/rubocop-rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rails/compare/v2.29.1...v2.33.4)

---
updated-dependencies:
- dependency-name: rubocop-rails
  dependency-version: 2.33.4
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-05 11:51:23 +01:00
Javi Martín
a3c25b5a2b Add Performance/ZipWithoutBlock rubocop rule
This rule was added in rubocop-performance 1.24.

We currently don't have code where it'd be relevant, but it's a nice
rule to have if we ever write `something.map { |element| [element] }`.
2025-11-05 11:44:27 +01:00
dependabot[bot]
42378285ac Bump rubocop-performance from 1.23.1 to 1.26.0
We're changing the `.rubocop.yml` file because we were getting a
warning:

```
rubocop-performance extension supports plugin, specify `plugins:
rubocop-performance` instead of `require: rubocop-performance` in
.rubocop.yml. For more information, see
https://docs.rubocop.org/rubocop/plugin_migration_guide.html
```

Bumps [rubocop-performance](https://github.com/rubocop/rubocop-performance) from 1.23.1 to 1.26.0.
- [Release notes](https://github.com/rubocop/rubocop-performance/releases)
- [Changelog](https://github.com/rubocop/rubocop-performance/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-performance/compare/v1.23.1...v1.26.0)

---
updated-dependencies:
- dependency-name: rubocop-performance
  dependency-version: 1.26.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-05 11:44:27 +01:00
dependabot[bot]
6bc24755bc Bump rubocop-capybara from 2.21.0 to 2.22.1
`Capybara/ClickLinkOrButtonStyle` is now deprecated, so we're replacing
it with `Capybara/AmbiguousClick`.

We're also changing the `.rubocop.yml` file because we were getting a
warning:

```
rubocop-capybara extension supports plugin, specify `plugins:
rubocop-capybara` instead of `require: rubocop-capybara` in
.rubocop.yml.  For more information, see
https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
```

Bumps [rubocop-capybara](https://github.com/rubocop/rubocop-capybara) from 2.21.0 to 2.22.1.
- [Release notes](https://github.com/rubocop/rubocop-capybara/releases)
- [Changelog](https://github.com/rubocop/rubocop-capybara/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-capybara/compare/v2.21.0...v2.22.1)

---
updated-dependencies:
- dependency-name: rubocop-capybara
  dependency-version: 2.22.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-05 11:29:28 +01:00
Javi Martín
4ec2e87c2c Add and apply RSpec/IncludeExamples rubocop rule
This rule was added in rubocop-rspec 3.6. We were already following it
most of the time.
2025-11-05 11:23:49 +01:00
dependabot[bot]
c1dd2a583a Bump rubocop-rspec from 3.4.0 to 3.7.0
We're changing the `.rubocop.yml` file because we were getting a
warning:

```
rubocop-rspec extension supports plugin, specify `plugins:
rubocop-rspec` instead of `require: rubocop-rspec` in .rubocop.yml. For
more information, see
https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
```

Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 3.4.0 to 3.7.0.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.4.0...v3.7.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-version: 3.7.0
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-05 11:23:49 +01:00
dependabot[bot]
6fa2946dd3 Bump rubocop-factory_bot from 2.26.1 to 2.27.1
We're changing the `.rubocop.yml` file because we were getting a
warning:

```
rubocop-factory_bot extension supports plugin, specify `plugins:
rubocop-factory_bot` instead of `require: rubocop-factory_bot` in
.rubocop.yml.  For more information, see
https://docs.rubocop.org/rubocop/plugin_migration_guide.html
```

---
updated-dependencies:
- dependency-name: rubocop-factory_bot
  dependency-version: 2.27.1
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-05 11:19:19 +01:00
Javi Martín
a7e1b42b6c Use checkboxes and radio buttons on poll forms
Our original interface to vote in a poll had a few issues:

* Since there was no button to send the form, it wasn't clear that
  selecting an option would automatically store it in the database.
* The interface was almost identical for single-choice questions and
  multiple-choice questions, which made it hard to know which type of
  question we were answering.
* Adding other type of questions, like open answers, was hard since we
  would have to add a different submit button for each answer.

So we're now using radio buttons for single-choice questions and
checkboxes for multiple-choice questions, which are the native controls
designed for these purposes, and a button to send the whole form.

Since we don't have a database table for poll ballots like we have for
budget ballots, we're adding a new `Poll::WebVote` model to manage poll
ballots. We're using WebVote instead of Ballot or Vote because they
could be mistaken with other vote classes.

Note that browsers don't allow removing answers with radio buttons, so
once somebody has voted in a single-choice question, they can't remove
the vote unless they manually edit their HTML. This is the same behavior
we had before commit 7df0e9a96.

As mentioned in c2010f975, we're now adding the `ChangeByZero` rubocop
rule, since we've removed the test that used `and change`.
2025-08-14 13:06:37 +02:00
taitus
13dbead27d Add Style/RedundantArrayFlatten Rubocop 1.76 rule
This rule was introduced in RuboCop 1.76.0 to avoid flattening arrays
when it has no effect.
2025-06-16 16:22:43 +02:00
taitus
9763799a8c Add Style/EmptyStringInsideInterpolation Rubocop 1.76 rule
This rule was introduced in RuboCop 1.76.0 to avoid unnecessary interpolation
of empty strings.
2025-06-16 16:07:35 +02:00
taitus
b9bffeb321 Add and apply Naming/PredicateMethod RuboCop 1.76 rule
This rule was introduced in RuboCop 1.76.0 to ensure methods ending
in '?' return boolean.

This commit applies suggested renames and code cleanup:
- Renames 'is_active?' to 'active_class' since it returns a string
- Renames 'parsed_value' to 'in_favor?' and 'is_request_active' to end with '?'
  for boolean semantics
- Skips false positives like 'save', 'auto_labels' or 'save_requiring_finish_signup',
  which are not predicate methods.
2025-06-16 16:07:35 +02:00
taitus
d123297ba6 Add and apply Style/ComparableBetween RuboCop rule
This rule was introduced in RuboCop 1.74 to prefer using between?
over chained comparison operators.
2025-06-16 16:07:35 +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
taitus
202ba3a5f8 Enable new rule from RuboCop 1.71 2025-03-05 11:43:46 +01:00
taitus
ba22d7fdf7 Enable new rules from RuboCop 1.70 2025-03-05 11:43:46 +01:00
taitus
f4ffee3700 Add and apply Lint/RedundantSafeNavigation RuboCop rule
We've tested the updated behavior in RuboCop 1.69, found a new offense, and corrected it.
2025-03-05 11:43:44 +01:00
taitus
4c7fe8a5d9 Enable new rules from RuboCop 1.69 2025-03-05 11:42:47 +01:00
taitus
9081174dd7 Add and apply Style/KeywordArgumentsMerging rubocop rule
This rule was introduced in RuboCop 1.68 to encourage passing
additional keyword arguments directly instead of using merge.
2025-03-05 11:42:47 +01:00
taitus
ada35f51f2 Remove unnecessary EnforcedShorthandSyntax definition
Rubocop 1.67.0 sets EnforcedShorthandSyntax to "either" by default,
so explicitly defining it is no longer necessary.
2025-03-05 11:42:47 +01:00
dependabot[bot]
203b659de8 Bump rubocop-rspec from 3.1.0 to 3.4.0
Note we're renaming the RSpec/StringAsInstanceDoubleConstant rule to
RSpec/VerifiedDoubleReference because its name changed in version 3.4.0

Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 3.1.0 to 3.4.0.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v3.1.0...v3.4.0)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-04 17:38:40 +01:00
Javi Martín
8d1a848e60 Remove code to rotate non-SHA256 cookies
This code was added in commit b3f570512 in order to rotate existing
cookies used by Consul Democracy 2.1 and earlier. Since the code was
included in Consul Democracy 2.2, existing installation using Consul
Democracy 2.2 will have already rotated the old cookies, which means we
don't need the cookie rotator anymore.
2025-01-08 16:47:57 +01:00
taitus
add50d68f6 Extract proposal new from shared nested imageable specs to system specs
Make `path`, `fill_resource_method_name`, `submit_button`, and
`imageable_success_notice` dynamic based on the factory.

Also adjusted the user. The proposals no longer require the user to be an
administrator but do require them to be a level 2 user.

Note that we are adding the Style/CaseLikeIf rubocop rule.
2024-11-26 17:57:01 +01:00
Javi Martín
07202fea10 Add and apply Style/RedundantBegin rubocop rule
We're about to add code which might fall into the `RedundantBegin`
category, so we're adding the rule in order to prevent that.
2024-10-30 15:57:44 +01:00
Sebastia
d3a039040c Merge pull request #5722 from consuldemocracy/dependabot/bundler/rubocop-rails-2.26.2
Bump rubocop-rails from 2.25.1 to 2.26.2
2024-10-10 15:03:08 +02:00
Sebastia
c529fec80f Merge pull request #5705 from consuldemocracy/dependabot/bundler/rubocop-1.66.1
Bump rubocop from 1.64.1 to 1.66.1
2024-10-10 15:01:56 +02:00
taitus
29df39b2fa Add an apply Rails/CompactBlank rubocop rule
In rubocop-rails 2.26.0, the Rails/CompactBlank rule was modified to handle
cases where select(&:present?) is used. After identifying three occurrences
in our code, we've decided to apply this rule as it encourages the use of the
more efficient and clearer method, compact_blank.

By using compact_blank, we improve code clarity and performance, as this method performs the same operation but in a more optimized way.
2024-10-10 10:02:22 +02:00
taitus
c50452aec6 Add and apply Rails/EnumHash rubocop rule
In rubocop-rails 2.26.0, support was added for Rails 7 syntax in the
Rails/EnumHash rule. We took this opportunity to ensure consistency
by converting all enums to hash with integer values. This format minimizes
the risk of data consistency issues in the database when adding new values.
2024-10-10 09:56:44 +02:00
taitus
3d4f78a424 Add an apply Rails/EnumSyntax rubocop rule
This rule was added in rubocop-rails 2.26.0. Applying it allows
us to anticipate the deprecation of the current enum syntax
using keyword arguments, which is set to be removed in Rails
8.0, as mentioned in the rule's own documentation:

https://docs.rubocop.org/rubocop-rails/cops_rails.html#railsenumsyntax
2024-10-10 09:55:48 +02:00
taitus
4dcac5bed5 Add and apply Naming/RescuedExceptionsVariableName rubocop rule
This rule was introduced in RuboCop 0.67.2, but now after seeing a fix in version 1.65.1,
we have decided to add it. The reason for adding it is to ensure consistency in how we
reference exceptions throughout the project, by following a standard naming convention
for exception variables.
2024-10-10 09:47:47 +02:00
taitus
6b15a073a2 Add and apply Style/RedundantRegexpArgument RuboCop rule
This rule was introduced in RuboCop 1.53.0. After adding the
Style/RedundantRegexpCharacterClass rule in the previous commit,
RuboCop started detecting redundant regular expression arguments.
Therefore, we apply this rule to remove them and prevent future
occurrences.
2024-10-10 09:47:47 +02:00
taitus
d94eed8628 Add and apply Style/RedundantRegexpCharacterClass rubocop rule
This rule was introduced in RuboCop 0.93.0, but now after seeing a fix in version 1.65,
we have decided to add it. The reason for adding it is to simplify our regular
expressions. This enforcement will help us maintain better regular expression
practices across the project.
2024-10-09 09:33:35 +02:00
taitus
9300fe5a58 Add an apply RSpec/StringAsInstanceDoubleConstant rubocop rule
This rule was added in 3.1.0. Applying it allows you to start defining a way of doing
this in the project, helping to maintain consistency.
2024-10-08 18:43:07 +02:00
Javi Martín
140ca2feb9 Add RSpec/MissingExpectationTargetMethod rule
This rule was introduced in rubocop-rspec 3.0.0. We were already
following it. It might be helpful because during development I've made
typos prevented by this rule a couple of times.
2024-07-21 22:25:45 +02:00
Javi Martín
04eaa802cc Add RSpec/ExpectInLet rubocop rule
This rule was added in rubocop-rspec 2.30.0. We were already following
it. It might be useful to detect typos during development.
2024-07-21 22:25:45 +02:00
Javi Martín
d90b799342 Add RSpec/UndescriptiveLiteralsDescription rule
This rule was added in rubocop-rspec 2.29.0. We were already following
it.
2024-07-21 22:25:45 +02:00
Javi Martín
dea317c614 Add RSpec/EmptyOutput rubocop rule
This rule was added in rubocop-rspec 2.29.0. While we never use the
`output` matcher, it might actually be a good idea to use it in tests of
take tasks, to check the logger output.
2024-07-21 22:25:45 +02:00
dependabot[bot]
cb227e41dc Bump rubocop-rspec from 2.27.0 to 3.0.1
In this version, the RSpec Rails cops have been extracted to a new
`rubocop-rspec_rails` gem [1], and the `RSpec/Capybara/FeatureMethods`
has been removed in favor of the `RSpec/Dialect` cop.

Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.27.0 to 3.0.1.
- [Release notes](https://github.com/rubocop/rubocop-rspec/releases)
- [Changelog](https://github.com/rubocop/rubocop-rspec/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-rspec/compare/v2.27.0...v3.0.1)

---
updated-dependencies:
- dependency-name: rubocop-rspec
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

[1] https://docs.rubocop.org/rubocop-rspec/upgrade_to_version_3.html
[2] https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecdialect
2024-07-21 22:25:43 +02:00
Javi Martín
16315e14d2 Add and apply Style/SuperArguments rubocop rule
This rule was added in rubocop 1.64.0.

For clarity, in order to make it obvious that we're modifying the object
we received, we're excluding the Ahoy initializer, whose code was copied
from the Ahoy documentation.

We're also changing the `Types::BaseObject` class so we don't use a
variable with the same name as the parameter and we don't get a false
positive for this rule.
2024-07-09 11:23:02 +02:00
Javi Martín
46dc4a3163 Add and apply Style/MapIntoArray rubocop rule
This rule was added in rubocop 1.63.0.
2024-07-09 11:23:02 +02:00
Javi Martín
fb0c087f95 Add and apply Rails/WhereRange rubocop rule
This rule was added in rubocop-rails 2.25.0. Applying it allows us to
simplify the code a little bit. For example, now there's no need to
specify the `proposals` table in proposal scopes, which was actually
causing a bug in the `Legislation::Proposal` model, which was using the
`proposals` table instead of the `legislation_proposals` table (but,
since we don't use this scope, it didn't affect the application).
2024-07-05 17:11:29 +02:00
Javi Martín
995f7036de Run every linter separately in Github Actions
The main reason for this change is that Pronto doesn't run in pull
requests opened by external contributors, and we haven't found how to
fix this issue.

Another reason is that Pronto only detects issues in the lines where the
changes are done, but sometimes we introduce issues related to other
lines and those aren't detected by Pronto. Also, when adding or changing
Rubocop rules, or when we update Rubocop, Pronto doesn't check whether
those rules are applied in every Ruby and ERB file, and we sometimes
forget to do so (particularly in ERB files).

So, from now, the linters will check all the code in every pull request.

Note we're now excluding the `vendor` folder in our linters because the
`setup-ruby` action actions generates a `vendor/bundle/` folder with all
our gem dependencies, and we don't want to check those files.
2024-06-18 19:11:55 +02:00
Javi Martín
647121d13e Allow different locales per tenant
Note that, currently, we take these settings from the database but we
don't provide a way to edit them through the admin interface, so the
locales must be manually introduced through a Rails console.

While we did consider using a comma-separated list, we're using spaces
in order to be consistent with the way we store the allowed content
types settings.

The `enabled_locales` nomenclature, which contrasts with
`available_locales`, is probably subconsciously based on similar
patterns like the one Nginx uses to enable sites.

Note that we aren't using `Setting.enabled_locales` in the globalize
initializer when setting the fallbacks. This means the following test
(which we could add to the shared globalizable examples) would fail:

```
it "Falls back to an enabled locale if the fallback is not enabled" do
  Setting["locales.default"] = "en"
  Setting["locales.enabled"] = "fr en"
  allow(I18n.fallbacks).to receive(:[]).and_return([:fr, :es])
  Globalize.set_fallbacks_to_all_available_locales

  I18n.with_locale(:fr) do
    expect(record.send(attribute)).to eq "In English"
  end
end
```

The reason is that the code making this test pass could be:

```
def Globalize.set_fallbacks_to_all_available_locales
  Globalize.fallbacks = I18n.available_locales.index_with do |locale|
    ((I18n.fallbacks[locale] & Setting.enabled_locales) + Setting.enabled_locales).uniq
  end
end
```

However, this would make it impossible to run `rake db:migrate` on new
applications because the initializer would try to load the `Setting`
model but the `settings` table wouldn't exist at that point.

Besides, this is a really rare case that IMHO we don't need to support.
For this scenario, an installation would have to enable a locale, create
records with contents in that locale, then disable that locale and have
that locale as a fallback for a language where content for that record
wasn't created. If that happened, it would be solved by creating content
for that record in every enabled language.
2024-06-05 16:10:56 +02:00
Javi Martín
96ae69fe93 Use a GDPR-compliant configuration for Ahoy
As mentioned in Ahoy's README [1]:

> Ahoy provides a number of options to help with GDPR compliance.
> Update config/initializers/ahoy.rb with:
>
> class Ahoy::Store < Ahoy::DatabaseStore
>   def authenticate(data)
>     # disables automatic linking of visits and users
>   end
> end
>
> Ahoy.mask_ips = true
> Ahoy.cookies = :none

As also mentioned in the README:

> If Ahoy was installed before v5, add an index before making this
> change.
> (...)
> For Active Record, create a migration with:
> add_index :ahoy_visits, [:visitor_token, :started_at]

However, the `visitor_token` doesn't exist in our table, since we
generated the `visits` table when Ahoy used the `visitor_id` column. So
we're using this column for the index.

Note we also need to change the `visit` method, since otherwise we get
an exception [2]. As mentioned on the issue reporting the exception:

> you'll need to copy the latest version of that method and adapt it to
> your model. I believe you'll want to replace:
>
> where(visit_token: ahoy.visit_token) with
> where(id: ensure_uuid(ahoy.visit_token))
>
> where(visitor_token: ahoy.visitor_token) with
> where(visitor_id: ensure_uuid(ahoy.visitor_token))

So we're copying the latest version of that method and changing it
accordingly.

[1] https://github.com/ankane/ahoy/blob/v5.0.2/README.md
[2] Issue 549 in https://github.com/ankane/ahoy
2024-05-09 14:56:25 +02:00
Javi Martín
6502852743 Update initializer reference in rubocop config file
We renamed the initializer in commit 528e59ce2.
2024-04-26 03:26:10 +02:00
Javi Martín
b3f5705121 Use SHA256 to encrypt messages and cookies
Note that enabling this options means all encrypted messages and cookies
generated the application become invalid, so we're adding a cookie
rotator in order to keep sessions from expiring when upgrading the
application, as recommended in the "Upgrading Ruby on Rails" guideline
[1].

Since we haven't seen any Consul Democracy applications using encrypted
messages and these messages become invalid with this change, we're also
removing the pre-Rails 5.2 encryption to authenticate messages
(AES-256-CBC) and switching to the default one since Rails 5.2
(AES-256-GCM). Since the configured encryption is used by the cookie
rotator initializer (through the ActiveSupport::MessageEncryptor.key_len
method), at first I thought this might affect the cookie rotator, but it
doesn't: upgrading works as expected, and existing sessions are still
active.

I'm adding a comment to remove the initializer once all cookies have
been migrated. I've added "Rails 7.1" in the comment because we usually
check for these comments when upgrading Rails, but we rarely check for
them when after releasing new versions of Consul Democracy.

[1] https://guides.rubyonrails.org/v7.0/upgrading_ruby_on_rails.html#key-generator-digest-class-changing-to-use-sha256
2024-04-15 15:39:28 +02:00