Commit Graph

19410 Commits

Author SHA1 Message Date
Javi Martín
cf23de2f8b Allow headings ending in question marks in markdown
Not sure whether it's a good idea to end a heading with a question mark.
When in doubt, we usually keep the code as it is now, so that's what
we're doing.
2024-06-21 15:57:52 +02:00
Javi Martín
3a173fdb0b Use two spaces to indent lists in markdown
We were already doing it in the `docs/` folder, and this is consistent
with the indentations we use in prettly much every programming language.
2024-06-21 15:57:52 +02:00
Javi Martín
da1bac3638 Add a Markdownlint style file
This way we'll be able to customize some of the rules, which doesn't
seem to be possible when using the `.mdlrc` file.

For simplification purposes, instead of including all rules one by one,
we're excluding the few rules we don't use.
2024-06-21 15:57:52 +02:00
Javi Martín
035bfeb3b1 Add and apply MD047 MDL rule
We weren't adding a newline character at the end of a couple of files.
2024-06-21 15:57:52 +02:00
Javi Martín
ad66334446 Remove MDL rules that weren't being applied
I've no idea why, but these rules were ignored by the `mdl` command, so
we weren't following them. We might add them again in the future.
2024-06-21 15:57:52 +02:00
Javi Martín
504fa1b5e7 Remove non-existing rules in MDL configuration file
These rules (MD008, MD015, MD016 and MD017) were removed almost 10 years
ago, before we started this project [1].

[1] https://github.com/markdownlint/markdownlint/commit/71333042
2024-06-21 15:57:52 +02:00
Javi Martín
b0a29ca528 Apply rule MD034 Bare URL in github templates 2024-06-21 15:57:52 +02:00
Javi Martín
f59b0475b2 Adjust heading levels in github templates
Since the page contains an <h1> tag (the title of the issue), the main
headings of this file should be level 2 headings.

We're removing the "How" section in the flaky specs template for
simplicity (and because we usually don't use this template at all).

Note that MDL reports that the first heading should be a level 1
heading, but, as mentioned earlier, this doesn't make sense in the
context of a github issue. We'll probably exclude these files from MDL
checks in order to avoid this issue.
2024-06-21 15:57:52 +02:00
Javi Martín
b2d9d37070 Apply MDL spacing rules in github templates 2024-06-21 15:57:52 +02:00
Javi Martín
55e060424c Merge pull request #5544 from consuldemocracy/import_docs
Import code and commit history from the docs repository
2024-06-21 15:56:05 +02:00
Javi Martín
a5f134a10c Merge pull request #5584 from consuldemocracy/between_ages_spec
Fix typo in between_ages spec
2024-06-20 15:05:55 +02:00
Javi Martín
3f3d1dec17 Fix typo in between_ages spec
The test was failing sometimes because there's no guarantee that the
`.between_ages` scope will return the records in a specific order.
2024-06-19 18:42:14 +02:00
Javi Martín
777781f361 Update documentation README files
These files are essentially the same as our README files, only our
README files contain information that only makes sense in the context
of a repository.
2024-06-18 23:39:42 +02:00
Javi Martín
0b9be27c8c Use one SUMMARY.md file per language
On GitBook, currently Spanish and English belong in different spaces, so
we're going to provide two different github integrations (one per
language).

So we're using a different SUMMARY.md file per language.

For consistency, since there was a link to the README file in the
Spanish summary, we're also adding it to the English one. It was working
in any case because on our current gitbook page the summary was
generated through gitbook.

Since we no longer have any of the files referenced in the
`.gitbook.yaml` file, we're removing it as well.

Note that there was a typo in the English summary, which pointed to the
Spanish license. It didn't matter, though, since the license file is
actually in English in both cases.
2024-06-18 23:38:46 +02:00
Javi Martín
0710e3d542 Remove redundant files in docs subfolder
These files were both in the Consul Democracy repository and the
documentation repository. Since now both repositories have been merged
into one, we can remove the duplicate files.

Note there was a small difference in the `.mdlrc` file because we
changed it in commit b3a718ae6. We're keeping this change so we don't
get these syntax warnings in the documentation.
2024-06-18 20:33:01 +02:00
Javi Martín
3875503ea5 Update rbenv installation script URL
Their master branch was renamed to main.
2024-06-18 20:33:01 +02:00
Javi Martín
a76d2bba11 Fix broken link on translations page 2024-06-18 20:33:01 +02:00
cronopioelectronico
b536548cec Remove unnecessary texts in the README 2024-06-18 20:33:01 +02:00
cronopioelectronico
a4dbe1b413 Remove reference to old project team email address 2024-06-18 20:33:01 +02:00
Javi Martín
532c3dda1f Merge remote-tracking branch 'docs/master' into import_docs 2024-06-18 20:33:01 +02:00
Javi Martín
cc3268b968 Merge pull request #5578 from consuldemocracy/dependabot/npm_and_yarn/braces-3.0.3
Bump braces from 3.0.2 to 3.0.3
2024-06-18 20:32:07 +02:00
dependabot[bot]
70445ae43e Bump braces from 3.0.2 to 3.0.3
Dependabot couldn't find the original pull request head commit, 5654724f66010c1a52a4518cb2a8442277f368ed.
2024-06-18 18:07:10 +00:00
Javi Martín
d5dfb6ce7c Merge pull request #5583 from consuldemocracy/dependabot_pronto
Fix linters workflow on Dependabot pull requests
2024-06-18 20:06:27 +02:00
Javi Martín
e2a8b3caae Fix linters workflow on Dependabot pull requests
The name of the actor is not dependabot but dependabot[bot] [1].

[1] https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#responding-to-events
2024-06-18 19:54:06 +02:00
Javi Martín
961d7d9efa Merge pull request #5545 from consuldemocracy/linters_in_github_actions
Run every linter separately in Github Actions
2024-06-18 19:33:53 +02:00
Javi Martín
995f7036de Run every linter separately in Github Actions
The main reason for this change is that Pronto doesn't run in pull
requests opened by external contributors, and we haven't found how to
fix this issue.

Another reason is that Pronto only detects issues in the lines where the
changes are done, but sometimes we introduce issues related to other
lines and those aren't detected by Pronto. Also, when adding or changing
Rubocop rules, or when we update Rubocop, Pronto doesn't check whether
those rules are applied in every Ruby and ERB file, and we sometimes
forget to do so (particularly in ERB files).

So, from now, the linters will check all the code in every pull request.

Note we're now excluding the `vendor` folder in our linters because the
`setup-ruby` action actions generates a `vendor/bundle/` folder with all
our gem dependencies, and we don't want to check those files.
2024-06-18 19:11:55 +02:00
Javi Martín
61a6ba26b1 Simplify dependabot condition in pronto workflow
We had the `*` because, in the past, pull request could be opened by
either dependabot or dependabot-bot. That's no longer the case since we
started using dependabot v2.
2024-06-18 19:01:31 +02:00
Javi Martín
e646689535 Rename linters workflow to pronto
We're going to add a linters workflow, so the name would be confusing.
2024-06-18 18:27:32 +02:00
Javi Martín
444b8c3390 Ignore stylelint false positive in datepicker overrides
We can't simply remove the nesting selector in this case since it's
inside a `:not` pseudo-class. Removing the nesting selector would cause
a syntax error.
2024-06-18 18:27:32 +02:00
Javi Martín
6f9de94013 Extract stylesheet for social share button styles
This way we can ignore the selector-class-pattern stylelint rule error
due to the `.ssb-whatsapp_app` selector.
2024-06-18 18:27:32 +02:00
Javi Martín
b2be64848c Ignore legislation_process nesting in stylelint
This file was generated by a different developer who ignored the nesting
rules. Refactoring it has been in our TODO list for years, but we
haven't done it yet.

Since we want stylelint to check that there are no errors after the
changes in a pull request, but we've still got errors in this file,
we're ignoring them for now.
2024-06-18 18:27:32 +02:00
Javi Martín
3d5696aff5 Apply no-redeclare ESLint rule
This rule is part of the `eslint:recommended` package. It was the only
rule we weren't following 100% of the time (other than the line length).
2024-06-18 18:27:32 +02:00
Javi Martín
5d4c5a12a8 Add ESLint as a development dependency
Since now we aren't just using ESLint in the context of a pull request
(with pronto-eslint), we're also adding the `ignorePatterns` option so
it ignores third-party files.

Note we're using ESLint 8 because ESLint 9 doesn't support our
`.eslintrc` configuration file, which we need because it's required by
pronto-eslint. However, when running pronto-eslint, we're using ESLint 6
(I think); this means that now the eslint command we run in development
and the one run by pronto might behave differently, particularly if we
add rules that have been introduced in ESLint 7 or 8. For now, since we
generated the `.eslintrc` file using ESLint 6.0.1, everything works as
expected in both situations.
2024-06-18 18:27:32 +02:00
Javi Martín
94145f4d09 Don't check ERB Lint ErbSafety in files using raw
We're excluding these files because they use `raw` to render content
than only administrators can edit, and we trust administrators not to
provide unsafe HTML. We should definitely sanitize them at some point
but, at the same time, we should also try to keep compatibility in
installations taking advantage of `raw`.

Also note that ERB Lint does not allow customizing the severity of a
linter; if it ever does, we'll use the severity rule instead of
excluding files.
2024-06-18 18:27:32 +02:00
Javi Martín
a15ff36a22 Apply Rails/SafeNavigation in officing booth view
In commit 9329e4b6e, `try` was added because there was a case where this
partial was rendered and the `current_booth` method didn't exist.
However, that's no longer the case since commit d5c7858f6. Since then,
this partial is only rendered in the officing section, where the
`current_booth` method is defined.

So we can use the safe navigation operator instead of `try`.
2024-06-18 18:27:32 +02:00
Javi Martín
db274e9a44 Apply Lint/SymbolConversion rule in ERB files 2024-06-18 18:27:32 +02:00
Javi Martín
7c1c8e0436 Merge pull request #5580 from consuldemocracy/sign_out_specs
Use logout to sign out in tests
2024-06-18 17:01:21 +02:00
Javi Martín
3e55f22d9f Merge pull request #5575 from consuldemocracy/fix_avatar_alignment
Fix avatar alignment in "my account"
2024-06-18 16:58:47 +02:00
Javi Martín
ca7983baf4 Fix avatar alignment in "my account" and users#show
In commit 35659d441, we started using an <svg> tag instead of an <img>
tag to render avatars. That meant that the `vertical-align: middle` rule
we've got for images was no longer being applied.

So we're adding it back.

The only places where this icon wasn't rendered correctly were "my
account" and the show action in the users controller. The comments were
not affected because we've got a `float: left` rule for the
`comment-avatar svg` selector, which causes the browser to ignore the
value of the `vertical-align` propertly, and the avatars showing author
information were not affected because the `.author-photo` selector
already had a `vertical-align` rule.
2024-06-17 18:19:18 +02:00
Javi Martín
9eca5b081e Merge pull request #5543 from consuldemocracy/node_js_18.20.2
Update Node.js from 18.18.2 to 18.20.3
2024-06-17 17:50:44 +02:00
Javi Martín
4ec7be12fc Update Node.js from 18.18.2 to 18.20.3 2024-06-17 17:37:06 +02:00
Javi Martín
c7267f9729 Use logout to sign out in tests
We were doing it most of the time, but in some cases we were clicking
the "Sign out" link instead. These actions aren't the same, just like
using `login_as` is not the same as visiting the sign in page and
submitting the form.

Some of these tests failed sometimes because the user wasn't signed in
after using `login_as`. One possible cause could be that we weren't
adding an expectation after clicking the "Sign out" link.

So using `logout` adds consistency, simplifies the code, and might
reduce the chance of these tests failing in the future (although they
might still fail in the future because some of these tests check the
database after a `visit` call).
2024-06-17 16:48:37 +02:00
Javi Martín
a20f32401f Add an expectation after signing out in officing spec
In this test, we were signing out after confirming a vote, but we
weren't waiting for the request to finish before using the `login_as`
method. Sometimes this test failed with a screenshot showing that the
user wasn't signed in after the `login_as` call, so this might have been
the cause.

We could use the `logout` method instead, but since we don't have any
other tests that click the "Sign out" link from the officing area, we're
leaving it as it was; we might change it to `logout` in the future if
the test keeps failing once in a while.

Note we're also replacing a `visit` call which my guess is was there
because the "Sign out" link wasn't visible due to the notice covering
it. So we're closing the notice instead.
2024-06-17 16:46:36 +02:00
Javi Martín
9018048e06 Merge pull request #5541 from consuldemocracy/ruby3.2.4
Upgrade Ruby to version 3.2.4
2024-06-17 15:43:06 +02:00
Javi Martín
118a4dde89 Upgrade Ruby to version 3.2.4
As usual, we're upgrading the parser gem so we don't get warnings about
the Ruby version when running a rails console.
2024-06-17 15:18:40 +02:00
Javi Martín
4011ec0d3c Merge pull request #5500 from consuldemocracy/remove_bullet
Remove Bullet from Gemfile
2024-06-17 15:13:08 +02:00
Javi Martín
fbc7ba78e9 Merge pull request #5547 from consuldemocracy/empty_cache_when_upgrading
Clear Rails cache when upgrading Consul Democracy
2024-06-17 15:11:00 +02:00
Javi Martín
7cb122564d Merge pull request #5577 from consuldemocracy/capybara_screenshots_path
Update screenshots path in GitHub Actions
2024-06-17 15:07:38 +02:00
Javi Martín
10d93a04d3 Clear Rails cache when upgrading Consul Democracy
We use caching in our application in two different ways:

1. Rails.cache.fetch in models/controllers/libraries
2. Fragment caching in the views

When using Rails.cache.fetch, we usually set an expiration date or
provide a precise way to invalidate it. If the code changes and the
information stored in the cache is different from what the new code
would return, it's usually not a big deal because the cache will expire
in an hour or a day. Until commit a4461a1a5, the statistics were an
exception to this rule, but that's no longer the case. The actual
exception to this rule are the i18n translations, but the code caching
them is very simple and hasn't changed for more than three years (when
it was written for the first time).

When using fragment caching, on the other hand, Rails automatically
invalidates the cache when the associated _view code_ changes. That is,
if a view contains cache, the view renders a partial, and the partial
changes, the cache is correctly invalidated. The cache isn't invalidated
when the code in helpers, models or controllers change, though, which
the Rails team considers a compromise solution.

However, we've been moving view partials (and even views) to components,
and the cache isn't invalidated when a component changes (it doesn't
matter whether the component Ruby file or the component ERB file
changes). That means that the cache will keep rendering the HTML
generated by the old code.

So, now, we're clearing the cache when upgrading to a new version of
Consul Democracy, as part of the release tasks. That way, institutions
upgrading to a new version don't have to worry about possible issues
with the cache due to the new code not being executed.

I was thinking of adding it to a Capistrano task, but that would mean
that every time people deploy new code, even if it's a hotfix that
doesn't affect the cache at all, the cache would be cleared, which could
be inconvenient. Doing it in a release, that usually changes thousands
of lines of code, sounds like a good compromise.
2024-06-17 14:48:34 +02:00
Javi Martín
baec41c43d Fix screenshots in GitHub Action when two jobs fail
The upload-artifact action does not support using the same artifact name
in different jobs (or in different matrix scenarios) since version 4,
which we started using in commit acfaada82. That meant that screenshots
were not uploaded correctly when two or more knapsack nodes failed.
2024-06-14 17:55:27 +02:00