Commit Graph

20144 Commits

Author SHA1 Message Date
Javi Martín
f05785a8f8 Merge pull request #5152 from consuldemocracy/remove_ie8_warning
Remove alert for Internet Explorer 8 and below
2023-09-11 16:36:35 +02:00
dependabot[bot]
90e726378a Bump web-console from 4.2.0 to 4.2.1
Bumps [web-console](https://github.com/rails/web-console) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/rails/web-console/releases)
- [Changelog](https://github.com/rails/web-console/blob/main/CHANGELOG.markdown)
- [Commits](https://github.com/rails/web-console/compare/v4.2.0...v4.2.1)

---
updated-dependencies:
- dependency-name: web-console
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-11 12:40:39 +00:00
Javi Martín
bc4be187d9 Merge pull request #5241 from consuldemocracy/dependabot/bundler/rubocop-rspec-2.23.2
Bump rubocop-rspec from 2.17.1 to 2.23.2
2023-09-11 14:39:36 +02:00
Javi Martín
ea913f9332 Use Capybara methods to find/click/check links
We applied the Capybara/SpecificMatcher in commit f52a86b46.  However,
this rule doesn't convert methods finding <a> tags to methods finding
links because <a> tags only count as links when they've got the `href`
attribute. For instance, in the `xss_spec.rb` file we check what happens
when clicking on an anchor tag because we're testing that the `href`
attribute has been removed and so we can't use `click_link`.

So, basically, we can't enable a rule to automatically detect when we're
using `have_css` instead of `have_link`, but we should still do it
because `have_link` adds an extra check which affects accessibility
since it makes sure the tag has the `href` attribute and so it's
recognizable as a link by screen readers.
2023-09-11 14:10:41 +02:00
Javi Martín
614b4fbe4c Add and apply FactoryBot/AssociationStyle rule
This rule was added in rubocop-factory_bot 2.23.0. We were following it
sometimes, and sometimes we were not.
2023-09-08 13:52:54 +02:00
Javi Martín
b88a01f641 Add and apply FactoryBot/RedundantFactoryOption rule
This rule was added in rubocop-factory_bot 2.23.0.
2023-09-08 13:39:26 +02:00
Javi Martín
3b2484af77 Add FactoryBot/FactoryAssociationWithStrategy rule
This rule was added in rubocop-factory_bot 2.23.0. Even if we always
follow it, it's a mistake that we've accidentally made in the past
during development.
2023-09-08 13:37:38 +02:00
Javi Martín
1d5f03be8c Add and apply RSpec/ReceiveMessages rubocop rule
This rule was added in rubocop-rspec 2.23.0. I didn't know this method
existed, and it makes the code more readable in some cases.
2023-09-08 13:31:42 +02:00
Javi Martín
9bb2bfdd06 Add and apply RSpec/Rails/NegationBeValid rule
This rule was added in rubocop-rspec 2.23.0. We were already applying it
most of the time.
2023-09-08 13:24:46 +02:00
Javi Martín
fc0511f4d3 Add and appy RSpec/Rails/TravelAround rubocop rule
This rule was added in rubocop-rspec 2.19.0.

When freezing time in a test, `travel_back` is called automatically when
the test finishes, so we can do it in a `before` block instead of an
`around` block.

Note this rule didn't detect our usage of `freeze_time` because we were
using it on cops with a certain tag, but I expect the rule to be able to
detect this usage in the future.
2023-09-08 13:16:24 +02:00
dependabot[bot]
aef78ee6f6 Bump rubocop-rspec from 2.17.1 to 2.23.2
Note that in rubocop-rspec 2.18.0, most Capybara cops were extracted to
a different gem, and the sam happened in rubocop-rspec 2.22.0 with
FactoryBot cops.

So we're adding both rubocop-capybara and rubocop-factory_bot as
dependencies.

Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.17.1 to 2.23.2.
- [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.17.1...v2.23.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-08 12:46:41 +02:00
Javi Martín
49218118f2 Merge pull request #5240 from consuldemocracy/fix_erblint
Apply Style/InvertibleUnlessCondition rule to ERB files
2023-09-07 20:21:52 +02:00
Javi Martín
0b03c40b95 Apply Style/InvertibleUnlessCondition rule to ERB files
We forgot to do so in commit 28aafbd4b.
2023-09-07 19:49:45 +02:00
Javi Martín
21a268ab96 Remove alert for Internet Explorer 8 and below
Internet Explorer 8 was released in 2009 and people using it already
know that most web pages look broken on it, so we don't need to warn
them.

Removing it makes our application layout file much easier to read and
modify.
2023-09-07 19:44:54 +02:00
Javi Martín
caf7387f27 Merge pull request #5195 from consuldemocracy/dependabot/bundler/rubocop-1.56.2
Bump rubocop from 1.35.1 to 1.56.2
2023-09-07 19:42:21 +02:00
Javi Martín
28aafbd4bc Add and apply Style/InvertibleUnlessCondition rule
This rule was added in rubocop 1.44.0. It's useful to avoid accidental
`unless !condition` clauses.

Note we aren't replacing `unless zero?` with `if nonzero?` because we
never use `nonzero?`; using it sounds like `if !zero?`.

Replacing `unless any?` with `if none?` is only consistent if we also replace
`unless present?` with `if blank?`, so we're also adding this case. For
consistency, we're also replacing `unless blank?` with `if present?`.

We're also simplifying code dealing with `> 0` conditions in order to
make the code (hopefully) easier to understand.

Also for consistency, we're enabling the `Style/InverseMethods` rule,
which follows a similar idea.
2023-09-07 19:14:03 +02:00
Javi Martín
21ca96ae1c Fix conflictive debates with no votes
We originally added the `cached_votes_up > 0` in commit 4ce95e273
because back then `cached_votes_up` was used in the denominator. That's
no longer the case, and it doesn't make sense to mark a debate with 1
vote and 10 flags as conflictive but not doing it when the debate has no
votes and 1000 flags.

We're fixing the bug right now because we're about to change the
affected line in order to apply a new rubocop rule.
2023-09-07 19:08:36 +02:00
Javi Martín
e2542eed22 Merge pull request #5105 from consuldemocracy/rotate_logger
Rotate logs on production
2023-09-07 16:31:29 +02:00
Javi Martín
e077c7e890 Rotate log files on production and staging
The code based on the logger Rails uses by default; as mentioned in the
Rails configuration guide:

> [the logger] defaults to an instance of ActiveSupport::TaggedLogging
> that wraps an instance of ActiveSupport::Logger which outputs a log to
> the log/ directory. You can supply a custom logger, to get full
> compatibility you must follow these guidelines:
>
> * To support a formatter, you must manually assign a formatter from
>   the config.log_formatter value to the logger.
> * To support tagged logs, the log instance must be wrapped with
>   ActiveSupport::TaggedLogging.
> * To support silencing, the logger must include
>   ActiveSupport::LoggerSilence module. The ActiveSupport::Logger class
>   already includes these modules.
2023-09-07 15:58:16 +02:00
Javi Martín
11b962da8f Add and apply Style/MinMaxComparison rubocop rule
This rule was added in rubocop 1.42.0.
2023-09-07 13:09:11 +02:00
Javi Martín
daa35845da Add and apply Style/RedundantStringEscape rule
This rule was added in rubocop 1.37.0. It's particularly useful in the
background image spec, since now there's one less backslash to decipher
when reading the code :).
2023-09-07 13:09:11 +02:00
dependabot[bot]
ff04009e4a Bump rubocop from 1.35.1 to 1.56.2
Among many things, this version includes updates in the
`Layout/ExtraSpacing`, `Layout/SpaceAroundOperators` and
`Style/RedundantReturn` rules, which means we need to update the code in
some places in order to follow these rules.

Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.35.1 to 1.56.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.35.1...v1.56.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-07 13:09:11 +02:00
Javi Martín
c3d666ddce Merge pull request #5188 from consuldemocracy/dependabot/bundler/rubocop-rspec-2.17.1
Bump rubocop-rspec from 2.4.0 to 2.17.1
2023-09-07 13:08:22 +02:00
Javi Martín
d729e6c05d Merge pull request #5221 from consuldemocracy/dependabot/bundler/rubocop-rails-2.20.2
Bump rubocop-rails from 2.15.2 to 2.20.2
2023-09-07 13:00:24 +02:00
Javi Martín
a796e450b7 Add RSpec/Capybara/SpecificActions rubocop rule
This rule was added in rubocop-rspec 2.14.0. Even though we always
follow this rule, we haven't always done so in the past. Now we're
making sure we'll keep following this rule.
2023-09-06 19:00:56 +02:00
Javi Martín
05757c7f02 Add and apply RSpec/Rails/InferredSpecType rule
This rule was added in rubocop-rspec 2.14.0.
2023-09-06 19:00:56 +02:00
Javi Martín
8e276e2891 Add FactoryBot/ConsistentParenthesesStyle rule
This rule was added in rubocop-rspec 2.14.0. We were already applying it
most of the time.
2023-09-06 19:00:56 +02:00
Javi Martín
2d4ff86837 Add and apply Capybara/NegationMatcher rubocop rule
This rule was added in rubocop-rspec 2.14.0. We were already following
it most of the time.
2023-09-06 19:00:56 +02:00
Javi Martín
c4e32ea528 Add and apply HaveHttpStatus rubocop rule
This rule was added in rubocop-rspec 2.12.0. We were already applying it
most of the time.
2023-09-06 19:00:56 +02:00
Javi Martín
f52a86b465 Apply (but don't add) Capybara/SpecificMatcher rule
This rule was added in rubocop-rspec 2.12.0, and we were already
following it most of the time.

However, the rule isn't working correctly in some cases, such as input
selectors, so we aren't enabling it.
2023-09-06 19:00:56 +02:00
Javi Martín
c2010f9756 Apply (but don't add) ChangeByZero rubocop rule
This rule was added in rubocop-rspec 2.11.0. We aren't adding it
because, out of 3 offenses, this cop can only correct 2 automatically.
Not sure how to correct the other one since it uses `.and change`.
2023-09-06 19:00:56 +02:00
Javi Martín
f79a21f071 Add and apply RSpec/BeEq rubocop rule
This rule was added in rubocop-rspec 2.9.0. Once again, we were applying
it about 50% of the time.
2023-09-06 19:00:56 +02:00
Javi Martín
6268ae9274 Add and apply RSpec/BeNil rubocop rule
This rule was added in rubocop-rspec 2.9.0.

We were using `be_nil` 50% of the time, and `be nil` the rest of the
time. No strong preference for either one, but IMHO we don't lose
anything be being consistent.
2023-09-06 19:00:56 +02:00
Javi Martín
4fc4afa3a7 Add RSpec/ExcessiveDocstringSpacing rubocop rule
This rule was added in rubocop-rspec 2.5.0.
2023-09-06 19:00:56 +02:00
dependabot[bot]
a12cf85423 Bump rubocop-rspec from 2.4.0 to 2.17.1
Bumps [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) from 2.4.0 to 2.17.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.4.0...v2.17.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-06 19:00:56 +02:00
Javi Martín
2951d0fdf8 Add and apply Rails/ResponseParsedBody rubocop rule
This rule was introduced in rubocop-rails 2.18.0.

Since using `response.parsed_body` is shorter than using
`JSON.parse(response.body)`, this also means we can group some lines in
one.
2023-09-06 19:00:39 +02:00
Javi Martín
cb32d19f5e Add Rails/WhereNotWithMultipleConditions rule
This rule was introduced in rubocop-rails 2.17.0.

We don't use `where.not` with multiple conditions anywhere, but if we
did, it would indeed be very confusing, so we're adding a rule to avoid
that scenario.
2023-09-06 19:00:39 +02:00
Javi Martín
58a9e6c76e Add Rails/ActionControllerFlashBeforeRender rule
This rule was added in rubocop-rails 2.16.0. Even if we always follow
it, sometimes developers don't realize about this mistake immediately,
so it's good to have a rule to guarantee it won't happen.
2023-09-06 19:00:36 +02:00
dependabot[bot]
700ec6d0c0 Bump rubocop-rails from 2.15.2 to 2.20.2
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails) from 2.15.2 to 2.20.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.15.2...v2.20.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>
2023-09-06 14:54:21 +02:00
Javi Martín
b23ea25367 Apply Performance/CompareWithBlock rule to sort!
We should have applied this change in commit a78a8d592, since it was
added in rubocop-performance 1.18.0, but forgot to do so.
2023-09-06 14:54:21 +02:00
Javi Martín
7433c6b91e Merge pull request #5236 from consuldemocracy/revert_pg-1.5.4
Revert "Bump pg from 1.4.3 to 1.5.4"
2023-09-06 13:43:48 +02:00
Javi Martín
302d35ac47 Revert "Bump pg from 1.4.3 to 1.5.4"
We were getting warnings due to an incompatibility between pg 1.5.x and
Active Record. I thought it was fixed in Active Record 6.1.x, but it
isn't, so we're using pg 1.4.x until we upgrade to Rails 7.

The warning was:

```
PG::Coder.new(hash) is deprecated. Please use keyword arguments instead!
Called from
activerecord-6.0.6.1/lib/active_record/connection_adapters/postgresql_adapter.rb:883:in
`new'
```

This reverts commit c03f4243f.
2023-09-06 13:21:32 +02:00
Javi Martín
6821a59758 Merge pull request #5214 from consuldemocracy/dependabot/bundler/knapsack_pro-5.6.0
Bump knapsack_pro from 3.3.1 to 5.6.0
2023-09-06 13:18:14 +02:00
dependabot[bot]
dc1e0209ac Bump knapsack_pro from 3.3.1 to 5.6.0
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 3.3.1 to 5.6.0.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v3.3.1...v5.6.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-06 12:58:12 +02:00
Javi Martín
10e06aee89 Merge pull request #5203 from consuldemocracy/dependabot/bundler/ahoy_matey-4.2.1
Bump ahoy_matey from 4.1.0 to 4.2.1
2023-09-05 15:41:09 +02:00
dependabot[bot]
d8f8a94a26 Bump ahoy_matey from 4.1.0 to 4.2.1
Bumps [ahoy_matey](https://github.com/ankane/ahoy) from 4.1.0 to 4.2.1.
- [Changelog](https://github.com/ankane/ahoy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ankane/ahoy/compare/v4.1.0...v4.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 13:18:37 +00:00
Javi Martín
c956c64913 Merge pull request #5223 from consuldemocracy/dependabot/bundler/sprockets-4.2.0
Bump sprockets from 4.1.1 to 4.2.0
2023-09-05 15:16:55 +02:00
Senén Rodero Rodríguez
d0fb228f96 Make model concerns customization easier 2023-09-05 14:55:06 +02:00
dependabot[bot]
c0823a468c Bump sprockets from 4.1.1 to 4.2.0
Bumps [sprockets](https://github.com/rails/sprockets) from 4.1.1 to 4.2.0.
- [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.1.1...v4.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-05 12:53:50 +00:00
Javi Martín
437985cccf Merge pull request #5199 from consuldemocracy/dependabot/bundler/view_component-3.5.0
Bump view_component from 2.78.0 to 3.5.0
2023-09-05 14:40:07 +02:00