Commit Graph

20065 Commits

Author SHA1 Message Date
Javi Martín
ec8473dd85 Merge pull request #5518 from consuldemocracy/dependabot/npm_and_yarn/stylistic/stylelint-plugin-2.1.2
Bump @stylistic/stylelint-plugin from 2.1.1 to 2.1.2
2024-07-02 22:23:53 +02:00
dependabot[bot]
c9c8711356 Bump @stylistic/stylelint-plugin from 2.1.1 to 2.1.2
Bumps [@stylistic/stylelint-plugin](https://github.com/stylelint-stylistic/stylelint-stylistic) from 2.1.1 to 2.1.2.
- [Release notes](https://github.com/stylelint-stylistic/stylelint-stylistic/releases)
- [Changelog](https://github.com/stylelint-stylistic/stylelint-stylistic/blob/main/CHANGELOG.md)
- [Commits](https://github.com/stylelint-stylistic/stylelint-stylistic/compare/v2.1.1...v2.1.2)

---
updated-dependencies:
- dependency-name: "@stylistic/stylelint-plugin"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 20:06:23 +00:00
Javi Martín
6dace929a7 Merge pull request #5604 from consuldemocracy/dependabot/bundler/selenium-webdriver-4.22.0
Bump selenium-webdriver from 4.16.0 to 4.22.0
2024-07-02 21:47:05 +02:00
Javi Martín
ad4680788e Merge pull request #5606 from consuldemocracy/dependabot/bundler/knapsack_pro-7.6.2
Bump knapsack_pro from 7.0.1 to 7.6.2
2024-07-02 21:46:17 +02:00
dependabot[bot]
4e7f5d2454 Bump selenium-webdriver from 4.16.0 to 4.22.0
Bumps [selenium-webdriver](https://github.com/SeleniumHQ/selenium) from 4.16.0 to 4.22.0.
- [Release notes](https://github.com/SeleniumHQ/selenium/releases)
- [Changelog](https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES)
- [Commits](https://github.com/SeleniumHQ/selenium/compare/selenium-4.16.0...selenium-4.22.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 19:26:27 +00:00
dependabot[bot]
6dd8f5607c Bump knapsack_pro from 7.0.1 to 7.6.2
Bumps [knapsack_pro](https://github.com/KnapsackPro/knapsack_pro-ruby) from 7.0.1 to 7.6.2.
- [Changelog](https://github.com/KnapsackPro/knapsack_pro-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.0.1...v7.6.2)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 19:26:14 +00:00
Javi Martín
c8d7a1c4d6 Merge pull request #5566 from consuldemocracy/dependabot/bundler/letter_opener_web-3.0.0
Bump letter_opener_web from 2.0.0 to 3.0.0
2024-07-02 21:24:36 +02:00
dependabot[bot]
ad9697b3e1 Bump letter_opener_web from 2.0.0 to 3.0.0
Bumps [letter_opener_web](https://github.com/fgrehm/letter_opener_web) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/fgrehm/letter_opener_web/releases)
- [Changelog](https://github.com/fgrehm/letter_opener_web/blob/master/CHANGELOG.md)
- [Commits](https://github.com/fgrehm/letter_opener_web/compare/v2.0.0...v3.0.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 19:02:29 +00:00
Javi Martín
ff004c00d8 Merge pull request #5527 from consuldemocracy/dependabot/bundler/spring-4.2.1
Bump spring from 4.1.3 to 4.2.1
2024-07-02 20:57:58 +02:00
dependabot[bot]
05d6eddc63 Bump spring from 4.1.3 to 4.2.1
Bumps [spring](https://github.com/rails/spring) from 4.1.3 to 4.2.1.
- [Release notes](https://github.com/rails/spring/releases)
- [Changelog](https://github.com/rails/spring/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rails/spring/compare/v4.1.3...v4.2.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 18:36:07 +00:00
Javi Martín
9bb0484688 Merge pull request #5609 from consuldemocracy/dependabot/bundler/capistrano-3.19.1
Bump capistrano from 3.18.1 to 3.19.1
2024-07-02 20:21:36 +02:00
dependabot[bot]
e0fa4e43ab Bump capistrano from 3.18.1 to 3.19.1
Bumps [capistrano](https://github.com/capistrano/capistrano) from 3.18.1 to 3.19.1.
- [Release notes](https://github.com/capistrano/capistrano/releases)
- [Commits](https://github.com/capistrano/capistrano/compare/v3.18.1...v3.19.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 20:08:49 +02:00
Javi Martín
fb978c8051 Merge pull request #5594 from consuldemocracy/dependabot/bundler/rspec-rails-6.1.3
Bump rspec-rails from 6.1.2 to 6.1.3
2024-07-02 19:46:55 +02:00
dependabot[bot]
b22a0660e0 Bump rspec-rails from 6.1.2 to 6.1.3
Bumps [rspec-rails](https://github.com/rspec/rspec-rails) from 6.1.2 to 6.1.3.
- [Changelog](https://github.com/rspec/rspec-rails/blob/main/Changelog.md)
- [Commits](https://github.com/rspec/rspec-rails/compare/v6.1.2...v6.1.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 15:02:25 +00:00
Javi Martín
bf47d82989 Merge pull request #5599 from consuldemocracy/dependabot/bundler/rubocop-factory_bot-2.26.1
Bump rubocop-factory_bot from 2.25.1 to 2.26.1
2024-07-02 16:59:39 +02:00
dependabot[bot]
265743314a Bump rubocop-factory_bot from 2.25.1 to 2.26.1
Bumps [rubocop-factory_bot](https://github.com/rubocop/rubocop-factory_bot) from 2.25.1 to 2.26.1.
- [Release notes](https://github.com/rubocop/rubocop-factory_bot/releases)
- [Changelog](https://github.com/rubocop/rubocop-factory_bot/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop-factory_bot/compare/v2.25.1...v2.26.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 14:37:32 +00:00
Javi Martín
1d16835fd9 Merge pull request #5596 from consuldemocracy/dependabot/bundler/rubocop-performance-1.21.1
Bump rubocop-performance from 1.20.2 to 1.21.1
2024-07-02 16:35:16 +02:00
dependabot[bot]
e63f7715de Bump rubocop-performance from 1.20.2 to 1.21.1
Bumps [rubocop-performance](https://github.com/rubocop/rubocop-performance) from 1.20.2 to 1.21.1.
- [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.20.2...v1.21.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 14:18:02 +00:00
Javi Martín
aa6b87ef23 Merge pull request #5595 from consuldemocracy/dependabot/bundler/rubocop-capybara-2.21.0
Bump rubocop-capybara from 2.20.0 to 2.21.0
2024-07-02 16:16:27 +02:00
dependabot[bot]
7f5bf2ec5c Bump rubocop-capybara from 2.20.0 to 2.21.0
Bumps [rubocop-capybara](https://github.com/rubocop/rubocop-capybara) from 2.20.0 to 2.21.0.
- [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.20.0...v2.21.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 13:58:28 +00:00
Javi Martín
fe660096c9 Merge pull request #5565 from consuldemocracy/dependabot/bundler/faker-3.4.1
Bump faker from 3.3.1 to 3.4.1
2024-07-02 15:40:53 +02:00
Javi Martín
bdcedafc8d Remove kanban management github action workflow
This workflow only supports classic projects [1], but we're migrating to
new projects because github will automatically close classic projects on
August 23 [2].

[1] Issue 89 in https://github.com/srggrs/assign-one-project-github-action/
[2] https://github.blog/changelog/2024-05-23-sunset-notice-projects-classic/
2024-07-02 15:30:02 +02:00
dependabot[bot]
0505132173 Bump faker from 3.3.1 to 3.4.1
Bumps [faker](https://github.com/faker-ruby/faker) from 3.3.1 to 3.4.1.
- [Release notes](https://github.com/faker-ruby/faker/releases)
- [Changelog](https://github.com/faker-ruby/faker/blob/main/CHANGELOG.md)
- [Commits](https://github.com/faker-ruby/faker/compare/v3.3.1...v3.4.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-02 13:21:31 +00:00
Sebastia
cc71d98d69 Merge pull request #5586 from consuldemocracy/release_2.2.0
Release version 2.2.0
2024-07-01 16:43:51 +02:00
taitus
b20fb4e943 Release version 2.2.0 2024-06-28 16:58:20 +02:00
Sebastia
5c88028e96 Merge pull request #5589 from consuldemocracy/i18n_crowdin
Update translations from Crowdin
2024-06-28 16:55:07 +02:00
Consul Bot
0cc421f372 Update translations from Crowdin 2024-06-28 16:10:24 +02:00
Javi Martín
82b73e5ddc Merge pull request #5587 from consuldemocracy/zeitwerk_docs
Update documentation to load custom code
2024-06-28 14:24:18 +02:00
Javi Martín
f78e2bed94 Update documentation to load custom code
Just like mentioned in commit 6552e3197d, we need to use `load` instead
of `require_dependency` since we started using zeitwerk.
2024-06-28 03:49:20 +02:00
Javi Martín
20c55da48b Merge pull request #5539 from consuldemocracy/add_option_id_to_poll_answers
Avoid duplicate records in poll answers
2024-06-27 15:35:24 +02:00
Javi Martín
5dbd2ede14 Delete duplicate records in different languages 2024-06-27 15:22:02 +02:00
Javi Martín
58f88d6805 Add task to add option_id to existing answers
Note: to avoid confusion, "answer" will mean a row in the poll_answers
table and "choice" will mean whatever is in the "answer" column of that
table (I'm applying the same convention in the code of the task).

In order make this task perform reasonably on installations with
millions of votes, we're using `update_all` to update all the answers
with the same choice at once. In order to do that, we first need to
check the existing choices and what are the possible option_ids for
those choices.

Note that, in order for this task to work, we need to remote the
duplicate answers first. Otherwise, we will run into a RecordNotUnique
exception when trying to add the same option_id to two duplicate
answers.

So we're making this task depend on the one that removes duplicate
answers. That means we no longer need to specify the task to remove
duplicate answers in the release tasks; it will automatically be
executed when running the task to add an option_id.
2024-06-27 15:05:56 +02:00
Javi Martín
d2ec73e92c Add task to delete duplicate poll answers 2024-06-26 20:20:24 +02:00
Javi Martín
81abbd5021 Remove unused block variable in poll ABC factory 2024-06-26 20:20:24 +02:00
Javi Martín
5033691666 Avoid duplicate records in poll answers
Until now, we've stored the text of the answer somebody replied to. The
idea was to handle the scenarios where the user voters for an option but
then that option is deleted and restored, or the texts of the options
are accidentally edited and so the option "Yes" is now "Now" and vice
versa.

However, since commit 3a6e99cb8, options can no longer be edited once
the poll starts, so there's no risk of the option changing once somebody
has voted.

This means we can now store the ID of the option that has been voted.
That'll also help us deal with a bug introduced int 673ec075e, since
answers in different locales are not counted as the same answer. Note we
aren't dealing with this bug right now.

We're still keeping (and storing) the answer as well. There are two
reasons for that.

First, we might add an "open answer" type of questions in the future and
use this column for it.

Second, we've still got logic depending on the answer, and we need to be
careful when changing it because there are existing installations where
the answer is present but the option_id is not.

Note that we're using `dependent: nullify`. The reasoning is that, since
we're storing both the option_id and the answer text, we can still use
the answer text when removing the option. In practice, this won't matter
much, though, since we've got a validation rule that makes it impossible
to destroy options once the poll has started.

Also note we're still allowing duplicate records when the option is nil.
We need to do that until we've removed every duplicate record in the
database.
2024-06-26 20:20:24 +02:00
Javi Martín
03f89c9ca2 Move action to create answers to AnswersController
It was confusing to have the action to create an answer in
`QuestionsController#answer` while the action to destroy it was
`AnswersController#destroy`.
2024-06-26 20:20:24 +02:00
Javi Martín
9a840bb8d1 Remove unused code in poll questions controller
This code wasn't used since commit d9ad65875.
2024-06-26 20:20:24 +02:00
Javi Martín
9fbd7eec8f Remove obsolete routes for poll questions
The routes for poll questions were accidentally deleted in commit
5bb831e959 when deleting the `:show` action, and restored in commit
9871503c5e. However, the deleted code was:

```
resources :questions, only: [:show], controller: 'polls/questions' (...)
```

While the restored code was:

```
resources :questions, controller: 'polls/questions' (...)
```

Meaning we forgot to add the `only: []` option when restoring the
routes.

We also forgot to remove the `before_action` code when deleting the
`:show` action, so we're removing it now.
2024-06-26 20:20:24 +02:00
Javi Martín
e9377c1536 Merge pull request #5532 from consuldemocracy/poll_duplicate_voters
Avoid creating duplicate voters in polls
2024-06-26 20:19:53 +02:00
Javi Martín
b327275d18 Add a log file to track deleted duplicate records
It might be interesting in some cases to check the information related
to those records.
2024-06-26 15:41:44 +02:00
Javi Martín
b013a5b1b6 Add task to delete duplicate voters
Note that, since poll answers belong to a user and not to a voter, we
aren't doing anything regarding poll answers. This is a separate topic
that might be dealt with in a separate pull request.

Also note that, since there are no records belonging to poll voters, and
poll voters don't use `acts_as_paranoia` and don't have any callbacks on
destroy, it doesn't really matter whether we call `destroy!` or
`delete`. We're using `delete` so there are no unintended side-effects
that might affect voters with the same `user_id` and `poll_id` on
Consul Democracy installations customizing this behavior.
2024-06-26 15:41:44 +02:00
Javi Martín
9a8bfac5bd Prevent creation of duplicate poll voters
Note that, when taking votes from an erased user, since poll answers
don't belong to poll voters, we were not migrating them in the
`take_votes_from` method (and we aren't migrating them now either).
2024-06-26 15:41:44 +02:00
Javi Martín
175e990bb4 Remove unused answer_id field in poll_voters table
This field isn't used since commit 51be80eed, right after being
added in commit 5806d86e3.
2024-06-26 15:41:44 +02:00
Javi Martín
5f12db899f Remove no longer needed call to Poll::Answer#touch
This call was added in commit 81f65f1ac, and the test for its need was
added in commit cb1542874. However, both the test and the helper method
relying on the `touch` call were removed in commit f90d0d9c4.
2024-06-26 15:41:44 +02:00
Javi Martín
fb9156f9b8 Use with_lock instead of lock!
That way the record is only locked while necessary.
2024-06-26 15:41:44 +02:00
Javi Martín
a54d424aed Add missing validation rule to poll answers
We were checking we didn't have more votes than allowed in the case of
questions with multiple answers, but we weren't checking it in the case
of questions with a single answer. This made it possible to create more
than one answer to the same question. This could happen because the
method `find_or_initialize_user_answer` might initialize two answers in
different threads, due to a race condition.
2024-06-26 15:41:44 +02:00
Javi Martín
6aafc107ae Remove Questionable concern
Since we were only using it in one place, it made the code harder to
follow.

We'll extract it again if we ever find a way to reuse it.
2024-06-26 15:41:44 +02:00
Javi Martín
0c650c423d Fix exception creating an answer without an author
We were getting `undefined method `lock!' for nil:NilClass` when the
question allowed multiple answers.
2024-06-26 15:41:44 +02:00
Javi Martín
bcaf05f78f Merge pull request #5585 from consuldemocracy/authorize_resource_in_locales_controller
Adjust permissions in admin locales
2024-06-26 15:41:26 +02:00
Javi Martín
12e49ff607 Hide languages link when there's only one language
Most existing Consul Democracy installations will have changed their
`config.i18n.available_locales` option so only a few locales are
available. In many cases, only one locale will be available. In these
cases, rendering a form that only offers one option is useless.

We've considered adding a text in this case mentioning that, in order to
enable more languages, they need to configure their
`config.i18n.available_locales`. However, we haven't done it for two
reasons.

First, if they've changed the available locales to just one, there's a
good chance they aren't interested at all in configuring the locales.

And, second, if there's only one available locale, administrators will
learn to ignore the "languages" link, so they won't realize that locales
can be configured if developers change the available locales. If we hide
the link, on the other hand, they will notice that locales can now be
configured once developers change the available locales.

Note we're still allowing access by entering the URL. This is harmless,
though, since people accessing it this way will see a form with only one
possible option and won't be able to modify anything.
2024-06-25 18:58:57 +02:00