Commit Graph

17301 Commits

Author SHA1 Message Date
taitus
7e826a9cb4 Do not show unpublished proposals on the homepage
The chances of an unpublished proposal appearing on the homepage was
very low because only the proposals with the most votes appear there and
unpublished proposals don't have any votes. However, it was technically
possible on new sites where only a few proposals had been created.
2021-09-08 12:38:54 +02:00
Javi Martín
f0d0f1f623 Fix updating a translation to its original value
Users were unable to reset a translation to its original value after
updating it because we weren't storing anything in the database in that
case.

I've considered deleting the existing translation when this happens. I'm
not sure about which approach is the better one, so I'm using the less
destructive one.
2021-09-08 12:38:27 +02:00
Javi Martín
bc47d84a1e Extract method do update I18n contents
This way we can test it properly, which will be helpful when fixing
bugs.
2021-09-08 12:38:27 +02:00
Javi Martín
e5cd763385 Merge pull request #4662 from consul/ruby2.7
Upgrade Ruby to version 2.7.4
2021-09-08 12:25:40 +02:00
Javi Martín
250f3e74c8 Merge pull request #4629 from consul/dependabot/bundler/master/rubocop-rails-and-rubocop-performance-and-rubocop-rspec-and-rubocop-2.11.3
Bump rubocop-rails, rubocop-performance, rubocop-rspec and rubocop
2021-09-08 12:13:39 +02:00
cronopioelectronico
99cc2bdfd1 Update machine learning spec 2021-09-08 11:41:19 +02:00
Javi Martín
f087d6f1ea Remove step to install Bundler in Dockerfile
I think we could have already done so when upgrading Ruby to version
2.6.x (which also included the Bundler gem), but since we didn't, now
that we've upgraded to Bundler 2.x it's probably a good moment.
2021-09-07 21:09:17 +02:00
cronopioelectronico
b6f0b1b063 Update machine learning ini files 2021-09-07 18:24:04 +02:00
cronopioelectronico
6d6888f201 Update machine learning scripts with NNMF and TextRank-GloVe techniques 2021-09-07 18:18:47 +02:00
Javi Martín
4f4f8f6180 Supress warnings in Paperclip::UrlGenerator
We were getting hundreds of "warning: URI.escape is obsolete" messages.
So we're using `URI::DEFAULT_PARSER.escape` instead.

IMHO it's OK to add this monkey-patch because we're replacing Paperclip
with Active Storage, and when we finish with that we'll delete this
file.
2021-09-03 12:12:38 +02:00
Javi Martín
f2330bee2b Upgrade Ruby to version 2.7.4
Note this version includes Bundler 2, so we can finally upgrade.
2021-09-03 12:12:38 +02:00
Javi Martín
1cecce1bc8 Fix Style/RedundantInterpolation rubocop offense
It was accidentally added in commit 713ae540b.
2021-09-03 11:49:53 +02:00
Javi Martín
26fed593df Apply Style/RedundantInterpolation to ERB files
We forgot to do so in commit 469b39ffa.
2021-09-03 11:49:53 +02:00
Javi Martín
720d3530d7 Add and apply Style/HashTransformKeys rubocop rule
The `transform_keys` method is available since Ruby 2.5.
2021-09-03 11:49:53 +02:00
Javi Martín
53aa1770a2 Add and apply Style/HashTransformValues rule
The `transform_values` method is available since Ruby 2.5.
2021-09-03 11:49:53 +02:00
Javi Martín
5b00df0565 Simplify valuator filter tests in budgets
Doing so makes it possible to have shorter lines after applying the
Layout/RedundantLineBreak rule.
2021-09-03 11:49:53 +02:00
Javi Martín
65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00
Javi Martín
ac5c9459c7 Add and apply Style/StringChars rubocop rule
This rule was added in Rubocop 1.12.0.
2021-09-03 11:49:53 +02:00
Javi Martín
2bc6018465 Add and apply Style/HashConversion rubocop rule
This rule was added in Rubocop 1.10.0. This style is IMHO clearer and
possible since Ruby 2.1.
2021-09-03 11:49:53 +02:00
Javi Martín
41a9d17c76 Add and apply Lint/SymbolConversion rubocop rule
This rule was added in Rubocop 1.9.0.

We're excluding the Setting model in order to keep the settings
consistent.
2021-09-03 11:49:53 +02:00
Javi Martín
54cced9296 Add and apply Style/IfWithBooleanLiteralBranches
This rule was added in Rubocop 1.9.0.
2021-09-03 11:49:53 +02:00
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