Commit Graph

16780 Commits

Author SHA1 Message Date
Javi Martín
1b19e33e55 Add and apply Naming/VariableName rubocop rule
We forgot to use it in one place, and we've found out other institutions
using CONSUL whose developers aren't so familiar with Ruby also break
this rule, so it might be better to add it explicitly.
2021-09-03 11:49:53 +02:00
Javi Martín
bbc3c2d7e7 Add and apply Style/SingleLineMethods rubocop rule
Single line methods are hard to read, at least with this syntax. The
syntax used in Ruby 3.0 is accepted since Rubocop 1.7.0.
2021-09-03 11:49:53 +02:00
Javi Martín
48672a3f35 Add and apply Style/SoleNestedConditional rule
We were already applying it in most places.
2021-09-03 11:49:53 +02:00
Javi Martín
aef1e4660f Add and apply Style/RedundantArgument rubocop rule
This rule was added in rubocop 1.4.0.
2021-09-03 11:49:53 +02:00
Javi Martín
f90c23ca88 Add and apply Lint/DuplicateBranch rubocop rule
This rule was introduced in rubocop 1.3.0.
2021-09-03 11:49:53 +02:00
Javi Martín
2c76f265f8 Add and apply Style/NegatedIfElseCondition rule
This rule was added in Rubocop 1.2.0, and will make developers who hate
negative conditions particularly happy.
2021-09-03 11:49:53 +02:00
Javi Martín
9b61945ee4 Add and apply Lint/EmptyBlock rubocop rule
It was introduced in Rubocop 1.1.0.
2021-09-03 11:49:53 +02:00
Javi Martín
adba81ea89 Add and apply Style/RedundantSelf rubocop rule 2021-09-03 11:49:53 +02:00
Javi Martín
a93384a2e1 Fix non-localized date in community poll
We've found this issue thanks to the `Style/RedundantParentheses`
rubocop rule.
2021-09-03 11:49:53 +02:00
Javi Martín
0be6eb9512 Add and apply Style/RedundantParentheses rule
Parentheses make the code harder to read in these cases.
2021-09-03 11:49:52 +02:00
Javi Martín
5abd0466e2 Add Rails/AddColumnIndex rubocop rule
The `column` method in ActiveRecord::ConnectionAdapters::TableDefinition
supports adding the `index:` option. The documentation says:

> Instantiates a new column for the table. See connection.add_column for
> available options.
>
> Additional options are:
>
> :index - Create an index for the column. Can be either true or an
> options hash.

So basically the `connection.add_column` method silently ignores the
`index:` option, and whenever we intended to create an index this way,
we didn't.

We're creating a new migration where we properly add the indexes that
weren't added when we intended to.

Thanks to the rubocop-rails team, who added this cop in version 2.11.0
and helped us notice this bug.
2021-09-03 11:49:52 +02:00
Javi Martín
5b6dc9d7ff Fix enforce_available_locales leak between tests
Even if it doesn't seem to have consequences right now, we certainly
prefer other tests to use the default value.
2021-09-03 11:49:52 +02:00
Javi Martín
071bcb7023 Add and apply Rails/I18nLocaleAssignment rule
This rule was added in rubocop-rails 2.11.0.

Although we prevent I18n locale leaking between tests by setting it
before each test, the `with_locale` method makes the scope of the locale
change more obvious.
2021-09-03 11:49:52 +02:00
Javi Martín
2bfa9068f1 Add and apply Rails/HttpStatus rubocop rule
We were already using it in most places. Since rubocop-rails 2.11.0,
this rule also detects offenses when using the `head` method, which we
were using with a plain `404`.
2021-09-03 11:49:52 +02:00
Javi Martín
591b09d6ea Update Capybara and FactoryBot rubocop namespaces
They changed in rubocop-rspec 2.0.0.pre.
2021-09-03 11:49:52 +02:00
dependabot[bot]
632a650161 Bump rubocop-rails, rubocop-performance, rubocop-rspec and rubocop
Bumps [rubocop-rails](https://github.com/rubocop/rubocop-rails), [rubocop-performance](https://github.com/rubocop/rubocop-performance), [rubocop-rspec](https://github.com/rubocop/rubocop-rspec) and [rubocop](https://github.com/rubocop/rubocop). These dependencies needed to be updated together.

Updates `rubocop-rails` from 2.9.1 to 2.11.3
- [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.9.1...v2.11.3)

Updates `rubocop-performance` from 1.10.2 to 1.11.4
- [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.10.2...v1.11.4)

Updates `rubocop-rspec` from 1.44.1 to 2.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/v1.44.1...v2.4.0)

Updates `rubocop` from 0.93.1 to 1.18.4
- [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/v0.93.1...v1.18.4)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-03 11:49:52 +02:00
Javi Martín
df623f39b9 Merge pull request #4682 from consul/flaky_drafting_spec
Fix flaky legislation draft version spec
2021-09-03 11:46:39 +02:00
Javi Martín
39a0679a71 Merge pull request #4669 from consul/fix_investment_spec
Fix flaky investments order spec
2021-09-03 11:46:06 +02:00
Javi Martín
ed3ad35142 Fix flaky investments order spec
We were clicking links and visiting pages without checking the previous
request had already finished. This might cause concurrent requests,
leading to unpredictable results.

It might be the reason why this test failed once when running our
continuous integration [1].

[1] https://github.com/consul/consul/runs/3295502777
2021-09-01 23:10:52 +02:00
Javi Martín
40e339d23d Fix flaky legislation draft version spec
The test was failing sometimes, probably because the "Edit" link within
the "An example legislation process" row is already present before
clicking the "All" link. This can lead to simultaneous requests.

Just removing the unnecessary click on the "All" link solves the issue.
2021-08-29 02:43:42 +02:00
efgalvao
713ae540b0 Add length validation for debate description
Fixes issue #4013.
2021-08-29 01:13:48 +02:00
Javi Martín
d32e2f9d77 Merge pull request #4647 from consul/rtl
Improve support for RTL languages
2021-08-18 15:14:10 +02:00
Javi Martín
8fdbd36741 Merge pull request #4664 from consul/fix_dockerfile
Explicitely use Debian Buster in Dockerfile
2021-08-18 13:30:45 +02:00
Javi Martín
05869bf465 Merge pull request #4663 from consul/revert-4538-notificationTranslation
Fix tests after replacing message with notification
2021-08-17 14:39:48 +02:00
Javi Martín
2c84f775d7 Explicitely use Debian Buster in Dockerfile
Debian Bullseye was released two days ago, and is now the default
distribution for the Docker image.

Our image isn't compatible with Debian Bullseye right now, and we
haven't done any testing with it, so for now we're staying with Buster.
2021-08-17 14:37:58 +02:00
Javi Martín
d5d9eb5093 Fix tests after replacing message with notification
Looks like our test suite wasn't executed in commit 4dbc027e5, and so we
weren't notified of these failures.
2021-08-17 14:23:24 +02:00
Javi Martín
9c8ee576a2 Merge pull request #4538 from andyjdavis/notificationTranslation
replace the word message with notification on proposal notification s…
2021-08-17 14:04:47 +02:00
Javi Martín
d827768c07 Set HTML dir attribute in RTL languages
This way properties flex layouts text direction will work properly.
2021-08-16 17:47:34 +02:00
Javi Martín
a868a5ff35 Change Foundation text direction in RTL languages
This way, when the language is written form right-to-left, elements
using Foundation mixins/classes will float to the opposite direction as
they do in left-to-right languages. The same will apply to text
alignment.

To offer full support for RTL languages, we need to change every single
reference to `float: left`, `float: right`, `text-align: left`,
`text-align: right`, and possible adjust other properties like `left`,
`margin-left`, `padding-left` or `border-left`. In the meantime, we at
least partially support these languages.

Replacing `float` with `flex` when possible would also improve RTL
support.
2021-08-16 17:47:33 +02:00
Javi Martín
8991d93bd1 Merge pull request #4585 from consul/experimental_machine_learning
Add experimental machine learning
2021-08-16 17:04:42 +02:00
Machine Learning
4d27bbebad Add experimental machine learning 2021-08-16 16:31:04 +02:00
Javi Martín
c8d8fae98d Move related list partial to a component
This way the code is easier to follow; the code checking whether the
list has contents is in the partial rendering the list.

We also remove some duplication setting up related content in the
controllers.

For some reason, we have to manually ignore i18n keys which were
automatically ignored when the code was in the view.
2021-08-16 16:30:13 +02:00
Javi Martín
89436b528f Extract component to render a date range
Note we're using the `call` method (which is equivalent to adding an ERB
file) because we were getting an error calling `render` from the `dates`
method:

```
ActionView::Base#lookup_context delegated to
view_renderer.lookup_context, but view_renderer is nil:
```

It might be because we aren't rendering the
`Adming::Budgets::DurationComponent` but just calling one method, and so
there's no view context in this case.
2021-08-16 16:30:13 +02:00
Javi Martín
e7da2cb0f3 Merge pull request #4641 from consul/dependabot/bundler/master/globalize-6.0.1
Bump globalize from 5.3.1 to 6.0.1
2021-08-16 02:33:48 +02:00
dependabot[bot]
6072372c9d Bump globalize from 5.3.1 to 6.0.1
Bumps [globalize](https://github.com/globalize/globalize) from 5.3.1 to 6.0.1.
- [Release notes](https://github.com/globalize/globalize/releases)
- [Changelog](https://github.com/globalize/globalize/blob/master/CHANGELOG.md)
- [Commits](https://github.com/globalize/globalize/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-15 20:23:21 +00:00
Javi Martín
0ee0388111 Merge pull request #4636 from consul/dependabot/bundler/master/dalli-2.7.11
Bump dalli from 2.7.10 to 2.7.11
2021-08-15 20:02:45 +02:00
Javi Martín
e01a94d7bd Use mem_cache_store instead of dalli_store
`dalli_store` is deprecated since dalli 2.7.11.

We can now enable cache_versioning. We didn't enable it when upgrading
to Rails 5.2 because of possible incompatibility with `dalli_store` [1],
even though apparently some the issues were fixed in dalli 2.7.9 and
dalli 2.7.10 [2].

Since using cache versioning makes cache expiration more efficient, and
I'm not sure whether the options we were passing to the dalli store are
valid with memcache store (documentation here is a bit lacking), I'm
just removing the option we used to double the default cache size on
production.

[1] https://www.schneems.com/2018/10/17/cache-invalidation-complexity-rails-52-and-dalli-cache-store
[2] https://github.com/petergoldstein/dalli/blob/master/History.md
2021-08-15 19:42:22 +02:00
dependabot[bot]
1d594d1622 Bump dalli from 2.7.10 to 2.7.11
Bumps [dalli](https://github.com/petergoldstein/dalli) from 2.7.10 to 2.7.11.
- [Release notes](https://github.com/petergoldstein/dalli/releases)
- [Changelog](https://github.com/petergoldstein/dalli/blob/master/History.md)
- [Commits](https://github.com/petergoldstein/dalli/compare/v2.7.10...v2.7.11)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-14 23:54:58 +00:00
Javi Martín
faa6a7d5c6 Merge pull request #4635 from consul/dependabot/bundler/master/ahoy_matey-3.2.0
Bump ahoy_matey from 1.6.0 to 3.2.0
2021-08-15 01:46:17 +02:00
Javi Martín
b5220effd1 Bump ahoy_matey from 1.6.0 to 3.2.0
Bumps [ahoy_matey](https://github.com/ankane/ahoy) from 1.6.0 to 3.2.0.
- [Release notes](https://github.com/ankane/ahoy/releases)
- [Changelog](https://github.com/ankane/ahoy/blob/master/CHANGELOG.md)
- [Commits](https://github.com/ankane/ahoy/compare/v1.6.0...v3.2.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-15 01:26:29 +02:00
Javi Martín
340c591822 Merge pull request #4634 from consul/dependabot/bundler/master/acts_as_votable-0.13.1
Bump acts_as_votable from 0.12.1 to 0.13.1
2021-08-14 20:23:31 +02:00
dependabot[bot]
9290b0f1fc Bump acts_as_votable from 0.12.1 to 0.13.1
Bumps [acts_as_votable](https://github.com/ryanto/acts_as_votable) from 0.12.1 to 0.13.1.
- [Release notes](https://github.com/ryanto/acts_as_votable/releases)
- [Commits](https://github.com/ryanto/acts_as_votable/compare/v0.12.1...v0.13.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-14 18:02:58 +00:00
Javi Martín
29808f3ea1 Merge pull request #4622 from consul/dependabot/bundler/master/wkhtmltopdf-binary-0.12.6.5
Bump wkhtmltopdf-binary from 0.12.4 to 0.12.6.5
2021-08-14 15:47:22 +02:00
dependabot[bot]
ee567c2946 Bump wkhtmltopdf-binary from 0.12.4 to 0.12.6.5
We're also updating the WickedPdf initializer since wkhtmltopdf prevents
accessing the filesystem by default since version 0.12.6, causing image
tags generated by the `wicked_pdf_image_tag` method not to be rendered.

Bumps [wkhtmltopdf-binary](https://github.com/zakird/wkhtmltopdf_binary_gem) from 0.12.4 to 0.12.6.5.
- [Release notes](https://github.com/zakird/wkhtmltopdf_binary_gem/releases)
- [Changelog](https://github.com/zakird/wkhtmltopdf_binary_gem/blob/master/CHANGELOG.md)
- [Commits](https://github.com/zakird/wkhtmltopdf_binary_gem/commits)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-14 15:19:09 +02:00
Javi Martín
18c6f72cb4 Merge pull request #4656 from consul/dependabot/bundler/master/ancestry-4.1.0
Bump ancestry from 3.2.1 to 4.1.0
2021-08-13 21:36:01 +02:00
dependabot[bot]
9d4c781a4c Bump ancestry from 3.2.1 to 4.1.0
Bumps [ancestry](https://github.com/stefankroes/ancestry) from 3.2.1 to 4.1.0.
- [Release notes](https://github.com/stefankroes/ancestry/releases)
- [Changelog](https://github.com/stefankroes/ancestry/blob/master/CHANGELOG.md)
- [Commits](https://github.com/stefankroes/ancestry/compare/v3.2.1...v4.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-13 19:04:17 +00:00
Javi Martín
3033df760f Merge pull request #4651 from consul/dependabot/bundler/master/caxlsx-3.1.0
Bump caxlsx from 3.0.4 to 3.1.0
2021-08-13 16:29:27 +02:00
dependabot[bot]
e67272a974 Bump caxlsx from 3.0.4 to 3.1.0
Bumps [caxlsx](https://github.com/caxlsx/caxlsx) from 3.0.4 to 3.1.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/v.3.0.4...v3.1.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-13 13:53:02 +00:00
Javi Martín
98d0e9f0a4 Merge pull request #4616 from consul/dependabot/bundler/master/devise-security-0.16.0
Bump devise-security from 0.11.1 to 0.16.0
2021-08-13 15:49:18 +02:00
dependabot[bot]
ffe9ac7854 Bump devise-security from 0.11.1 to 0.16.0
Bumps [devise-security](https://github.com/devise-security/devise-security) from 0.11.1 to 0.16.0.
- [Release notes](https://github.com/devise-security/devise-security/releases)
- [Commits](https://github.com/devise-security/devise-security/compare/v0.11.1...v0.16.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-13 15:28:22 +02:00