Commit Graph

17550 Commits

Author SHA1 Message Date
Javi Martín
c8270d58bd Add and apply Rails/DurationArithmetic rubocop rule
This rule was added in rubocop-rails 2.13.0. We were already applying it
most of the time.
2022-08-24 23:24:36 +02:00
Javi Martín
68899c80b6 Add Rails/RedundantTravelBack rubocop rule
This rule was added in rubocop-rails 2.12.0. It doesn't catch the case
we've seen the most in the past, though: using `travel_back` to finish
the test will not raise an offense.

However, it does detect a useless `travel_back` call in `after` blocks,
so I guess it's better than nothing.
2022-08-24 23:24:23 +02:00
Javi Martín
fc757428ef Bump rubocop-rails from 2.11.3 to 2.15.2
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.11.3 to 2.15.2.
- [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.11.3...v2.15.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 22:11:47 +02:00
Javi Martín
0cb7d5c81e Merge pull request #4909 from consul/dependabot/bundler/master/wicked_pdf-2.6.3
Bump wicked_pdf from 2.1.0 to 2.6.3
2022-08-24 21:54:22 +02:00
dependabot[bot]
57a2566594 Bump wicked_pdf from 2.1.0 to 2.6.3
Bumps [wicked_pdf](https://github.com/mileszs/wicked_pdf) from 2.1.0 to 2.6.3.
- [Release notes](https://github.com/mileszs/wicked_pdf/releases)
- [Changelog](https://github.com/mileszs/wicked_pdf/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mileszs/wicked_pdf/compare/2.1.0...2.6.3)

---
updated-dependencies:
- dependency-name: wicked_pdf
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 21:35:54 +02:00
Javi Martín
eec34ebd3b Merge pull request #4910 from consul/dependabot/bundler/master/sitemap_generator-6.3.0
Bump sitemap_generator from 6.1.2 to 6.3.0
2022-08-24 21:35:20 +02:00
dependabot[bot]
cb72c00b43 Bump sitemap_generator from 6.1.2 to 6.3.0
Bumps [sitemap_generator](https://github.com/kjvarga/sitemap_generator) from 6.1.2 to 6.3.0.
- [Release notes](https://github.com/kjvarga/sitemap_generator/releases)
- [Changelog](https://github.com/kjvarga/sitemap_generator/blob/master/CHANGES.md)
- [Commits](https://github.com/kjvarga/sitemap_generator/compare/v6.1.2...v6.3.0)

---
updated-dependencies:
- dependency-name: sitemap_generator
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 21:19:37 +02:00
Javi Martín
6e0e174df2 Merge pull request #4908 from consul/dependabot/bundler/master/caxlsx-3.2.0
Bump caxlsx from 3.1.0 to 3.2.0
2022-08-24 21:17:44 +02:00
dependabot[bot]
3bd6e6da50 Bump caxlsx from 3.1.0 to 3.2.0
Bumps [caxlsx](https://github.com/caxlsx/caxlsx) from 3.1.0 to 3.2.0.
- [Release notes](https://github.com/caxlsx/caxlsx/releases)
- [Changelog](https://github.com/caxlsx/caxlsx/blob/master/CHANGELOG.md)
- [Commits](https://github.com/caxlsx/caxlsx/compare/v3.1.0...v3.2.0)

---
updated-dependencies:
- dependency-name: caxlsx
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 20:58:56 +02:00
Javi Martín
f620f1a385 Merge pull request #4912 from consul/dependabot/bundler/master/daemons-1.4.1
Bump daemons from 1.4.0 to 1.4.1
2022-08-24 20:56:30 +02:00
Javi Martín
2f71f8f3fc Merge pull request #4913 from consul/dependabot/bundler/master/caxlsx_rails-0.6.3
Bump caxlsx_rails from 0.6.2 to 0.6.3
2022-08-24 20:42:21 +02:00
dependabot[bot]
1149d276e5 Bump daemons from 1.4.0 to 1.4.1
Bumps [daemons](https://github.com/thuehlinger/daemons) from 1.4.0 to 1.4.1.
- [Release notes](https://github.com/thuehlinger/daemons/releases)
- [Changelog](https://github.com/thuehlinger/daemons/blob/master/Releases)
- [Commits](https://github.com/thuehlinger/daemons/compare/v1.4.0...v1.4.1)

---
updated-dependencies:
- dependency-name: daemons
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 20:38:09 +02:00
dependabot[bot]
6a6ad9ee75 Bump caxlsx_rails from 0.6.2 to 0.6.3
Bumps [caxlsx_rails](https://github.com/caxlsx/caxlsx_rails) from 0.6.2 to 0.6.3.
- [Release notes](https://github.com/caxlsx/caxlsx_rails/releases)
- [Changelog](https://github.com/caxlsx/caxlsx_rails/blob/master/CHANGELOG.md)
- [Commits](https://github.com/caxlsx/caxlsx_rails/compare/v0.6.2...v0.6.3)

---
updated-dependencies:
- dependency-name: caxlsx_rails
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 20:11:46 +02:00
Javi Martín
57b3ec93e5 Merge pull request #4917 from consul/dependabot/bundler/master/capistrano3-puma-5.2.0
Bump capistrano3-puma from 5.0.4 to 5.2.0
2022-08-24 20:09:33 +02:00
Javi Martín
739f23ea54 Merge pull request #4915 from consul/dependabot/bundler/master/capistrano-rails-1.6.2
Bump capistrano-rails from 1.6.1 to 1.6.2
2022-08-24 19:56:45 +02:00
dependabot[bot]
c1a6345f06 Bump capistrano3-puma from 5.0.4 to 5.2.0
Bumps [capistrano3-puma](https://github.com/seuros/capistrano-puma) from 5.0.4 to 5.2.0.
- [Release notes](https://github.com/seuros/capistrano-puma/releases)
- [Changelog](https://github.com/seuros/capistrano-puma/blob/master/CHANGELOG.md)
- [Commits](https://github.com/seuros/capistrano-puma/compare/v5.0.4...v5.2.0)

---
updated-dependencies:
- dependency-name: capistrano3-puma
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 19:45:07 +02:00
Javi Martín
8b745a2389 Merge pull request #4914 from consul/dependabot/bundler/master/sprockets-4.1.1
Bump sprockets from 4.0.2 to 4.1.1
2022-08-24 19:42:21 +02:00
dependabot[bot]
3b8d990ade Bump capistrano-rails from 1.6.1 to 1.6.2
Bumps [capistrano-rails](https://github.com/capistrano/rails) from 1.6.1 to 1.6.2.
- [Release notes](https://github.com/capistrano/rails/releases)
- [Commits](https://github.com/capistrano/rails/compare/v1.6.1...v1.6.2)

---
updated-dependencies:
- dependency-name: capistrano-rails
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 19:40:43 +02:00
dependabot[bot]
809fbb3000 Bump sprockets from 4.0.2 to 4.1.1
Bumps [sprockets](https://github.com/rails/sprockets) from 4.0.2 to 4.1.1.
- [Release notes](https://github.com/rails/sprockets/releases)
- [Changelog](https://github.com/rails/sprockets/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rails/sprockets/compare/v4.0.2...v4.1.1)

---
updated-dependencies:
- dependency-name: sprockets
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-08-24 19:23:08 +02:00
Javi Martín
200e8fb05d Merge pull request #4881 from consul/rails_6.0_methods
Use Rails 6.0 methods to simplify code
2022-08-24 18:35:17 +02:00
Javi Martín
5b844bf231 Use index_with to simplify hash generation
This method was introduced in Rails 6.0. It can be used to take an array
and create a hash where the elements of the array are the indexes of the
hash.
2022-08-24 18:19:02 +02:00
Javi Martín
eca1714a26 Use Rails native attachment validations
They were introduced in Rails 6.0.
2022-08-24 18:11:56 +02:00
Javi Martín
c97e7852a4 Use "excluding" instead of "reject"
This method was already available as #without, but we didn't know about
it.
2022-08-24 18:11:56 +02:00
Javi Martín
b59e2b31d3 Use unfreeze_time instead of travel_back
This is consistent with `with_frozen_time`.
2022-08-24 18:11:56 +02:00
Javi Martín
ea3abd6317 Add and apply Rails/Pick rubocop rule
The `pick` method was added in Rails 6.0.
2022-08-24 18:11:56 +02:00
Javi Martín
480ab6a9da Use truncate_all instead of DatabaseCleaner
Performance tests show both methods of truncating the database take
about the same time, so we can remove one dependency and we don't lose
anything in the process.
2022-08-24 18:11:56 +02:00
Javi Martín
f8ec98c2a6 Merge pull request #4919 from consul/relations_search_spec
Add more expectations in SDG Management search spec
2022-08-24 17:32:29 +02:00
Javi Martín
3d95f762af Add more expectations in SDG Management search spec
We've had some tests fail after this test was executed in our CI, and
one possible reason could be that sometimes this test finished before
all its requests had finished. This could be the case with the following
code:

```
visit sdg_management_proposals_path(filter: "pending_sdg_review")

click_button "Search"

expect(page).to have_css "li.is-active h2", exact_text: "Pending"
```

Before clicking the "Search" button, the expectation is already true, so
there's a chance that the expectation is evaluated as true before the
request has finished. That might result in requests and session data
leaking between tests.

So we're adding more expectations in order to make sure that the
requests have finished before evaluating the expectations associated to
them.
2022-08-24 17:09:12 +02:00
Javi Martín
2bf9433089 Merge pull request #4874 from consul/rails_6.0
Upgrade to Rails 6.0
2022-08-24 16:06:07 +02:00
Javi Martín
790170a27c Use keyword arguments in tag methods
The interface of this method has changed and uses keyword arguments
instead of a hash of options. This change will be particularly
significant when upgrading to Ruby 3.
2022-08-24 15:10:36 +02:00
Javi Martín
0b613158da Update TranslationHelper monkey-patch
The `translate` method now receives keyword arguments instead of a hash
of options.
2022-08-24 14:36:49 +02:00
Javi Martín
4732a6b22d Bump web-console from 3.7.0 to 4.0.4
We were getting a warning after upgrading to Rails 6:

DEPRECATION WARNING: ActionView::Base instances should be constructed
with a lookup context, assignments, and a controller.

We didn't upgrade web-console earlier because version 4.x isn't
compatible with Rails 5.
2022-08-24 14:36:49 +02:00
Javi Martín
a72572eb64 Add image_processing gem dependency
It's now used by default to handle image variants. We were getting a
warning:

DEPRECATION WARNING: Generating image variants will require the
image_processing gem in Rails 6.1. Please add `gem 'image_processing',
'~> 1.2'` to your Gemfile.

Note `mini_magick` is required in order to use the `analyze` method [1].
Since we use it in our image (and site customization image) validations,
we're still keeping the explicit dependency in our Gemfile.

[1] https://guides.rubyonrails.org/v6.0/active_storage_overview.html#analyzing-files
2022-08-24 14:36:49 +02:00
Javi Martín
19da667478 Include default locale in fallbacks explicitly
We were getting a warning because it won't be included by default in
Rails 6.1:

DEPRECATION WARNING: Using I18n fallbacks with an empty `defaults` sets
the defaults to include the `default_locale`. This behavior will change
in Rails 6.1 . If you desire the default locale to be included in the
defaults, please explicitly configure it with
`config.i18n.fallbacks.defaults = [I18n.default_locale]` or
`config.i18n.fallbacks = [I18n.default_locale, {...}]`. If you want to
opt-in to the new behavior, use `config.i18n.fallbacks.defaults = [nil,
{...}] `.
2022-08-24 14:36:49 +02:00
Javi Martín
7c8e3788ec Use new module_parent and module_parents methods
We were getting some deprecation warnings:

DEPRECATION WARNING: `Module#parent` has been renamed to
`module_parent`. `parent` is deprecated and will be removed in Rails
6.1.

DEPRECATION WARNING: `Module#parents` has been renamed to
`module_parents`. `parents` is deprecated and will be removed in Rails
6.1.
2022-08-24 14:36:49 +02:00
Javi Martín
7fe2309762 Use Rails 6.0 defaults and overwrite them
We can remove the `new_framework_defaults_6_0` file by using Rails 6.0
default options and overwriting the ones we haven't enabled.

We're still using the classic autoloader because we still haven't
checked how switching to zeitwerk will affect the way CONSUL
installations customize their code.

And we're using the default queues for Active Storage because we were
already using them and that will be the default option in Rails 6.1.
2022-08-24 14:36:49 +02:00
Javi Martín
1ea4988e52 Enable collection cache versioning
Similar to the way we enabled cache versioning in commit e01a94d7b. This
only affects caching `ActiveRecord::Relation` objects. I'm not even sure
we cache these objects, though, so we're just enabling the option
because it's the default one in Rails 6.0.
2022-08-24 14:36:49 +02:00
Javi Martín
af1244654c Use MailDeliveryJob to send mail in the background
The default delivery job class in Rails 5.2 (ActionMailer::DeliveryJob)
is deprecated.

This option wasn't already enabled in order to ease the upgrade, since
after upgrading with Rails 6 `MailDeliveryJob`, it won't be possible to
downgrade to Rails 5.2 without risking some crashes in background jobs.
2022-08-24 14:36:49 +02:00
Javi Martín
390a82ff8e Use Rails 6 attachments defaults in Active Storage
In Active Storage 5.2 there was an unexpected behavior: assigning a
collection appended records to the existing collection, instead of
replacing them as it's done in Active Record associations.

It doesn't really affect us, though, since we don't use
`has_many_attached` anywhere.
2022-08-24 14:36:49 +02:00
Javi Martín
3302f8c64d Return false on aborted enqueue in Active Job
In order to prevent a warning:

```
Rails 6.1 will return false when the enqueuing is aborted. Make sure
your code doesn't depend on it returning the instance of the job and set
`config.active_job.return_false_on_aborted_enqueue = true` to remove the
deprecations.
```
2022-08-24 14:36:49 +02:00
Javi Martín
8d7ce6f428 Return content-type header without modification
This is the default in Rails 6.0. I don't think it affects us, though.
2022-08-24 14:36:49 +02:00
Javi Martín
55d4d3cd5c Enable cookies with metadata
This is the default encryption for cookies in Rails 6.0 applications.
The reason it isn't enabled automatically for existing applications is
these cookies are not compatible with running the application with Rails
5. Since this isn't our case, and existing cookies are still read
correctly, we can safely enable it.
2022-08-24 14:36:48 +02:00
Javi Martín
7f7195ac0d Remove hidden UTF input in forms
This feature was kept in Rails mainly for Internet Explorer 8 and
earlier. But those browsers are now used by less than 0.1% of the
population, and we already display an alert for people using that
browser, warning we don't support it.
2022-08-24 14:36:48 +02:00
Javi Martín
ffc14e499a Upgrade to Rails 6.0
All the code in the `bin/` and the `config/` folders has been generated
running `rake app:update`. The only exception is the code in
`config/application.rb` where we've excluded the engines that Rails 6.0
has added, since we don't use them.

There are a few changes in Active Storage which aren't compatible with
the code we were using until now.

Since the method to assign an attachment in ActiveStorage has changed
and is incompatible with the hack we used to allow assigning `nil`
attachments, and since ActiveStorage now supports assigning `nil`
attachments, we're removing the mentioned hack. This makes the
HasAttachment module redundant, so we're removing it.

Another change in ActiveStorage is files are no longer saved before
saving the `ActiveStorage::Attachment` record. This means we need to
manually upload the file when using direct uploads. We also have to
change the width and height validations we used for images; however,
doing so results in very complex code, and we currently have to write
that code for both images and site customization images.

So, for now, we're just uploading the file before checking its
dimensions. Not ideal, though. We might use active_storage_validations
in the future to fix this issue (when they support a proc/lambda, as
mentioned in commit 600f5c35e).

We also need to update a couple of tests due to a small change in
response headers. Now the content disposition returns something like:

```
attachment; filename="budget_investments.csv"; filename*=UTF-8''budget_investments.csv
```

So we're updating regular expression we use to check the filename.

Finally, Rails 6.0.1 changed the way the host is set in integration
tests [1] and so both `Capybara.app_host` and `Capybara.default_host`
were ignored when generating URLs in the relationable examples. The only
way I've found to make it work is to explicitely assign the host to the
integration session. Rails 6.1 will change this setup again, so maybe
then we can remove this hack.

[1] https://github.com/rails/rails/pull/36283/commits/fe00711e9
2022-08-24 14:33:02 +02:00
Javi Martín
a4b9d88b44 Merge pull request #3392 from Jacek-202/issue-3183
Add search form on admin moderated content
2022-08-23 15:42:17 +02:00
Javi Martín
92941d3304 Keep filters in admin search
While this bug was already present in the general admin search, the
combination of both search and filters was very uncommon. I've only
found this combinations in the users section, where you've got the
"erased" filter, but in this case searching for erased users doesn't
really make sense since their username and email have been deleted and
so there's nothing to find.

So the hidden content seemed to be the only affected section. However,
we're adding the field to every section so we don't have to make sure we
add it when we need it (like we did in the SDGManagement section).
2022-08-23 14:33:55 +02:00
Jacek Skrzypacz
2af7e32415 Add search form for hidden content
Added search for comments and proposal_notifications, added tsv column
for search and rake tasks to update/create tsv vector.
2022-08-23 14:30:38 +02:00
Javi Martín
e66b9687a2 Fix calculating tsvector on hidden records
We introduced this bug in commit 55d339572, since we didn't take hidden
records into consideration.

I've tried to use `update_column` to simplify the code, but got a syntax
error `unnamed portal parameter` and didn't find how to fix it.
2022-08-23 14:30:38 +02:00
Javi Martín
f6fefde91d Extract concern to share hidden content code 2022-08-23 14:30:38 +02:00
Javi Martín
3e50b7ccaf Order filters the same way in all hidden content
We were doing it differently for investments.
2022-08-23 14:30:38 +02:00