Commit Graph

18703 Commits

Author SHA1 Message Date
Javi Martín
45c1f93562 Add a link to skip to the main content
While people using screen readers already have keyboard shortcuts to
jump to the <main> tag, there are people who navigate the page with the
keyboard using just the tab key, and for them, this link provides a way
to save time and start reading the main content instead of having to
manually go through all the navigation links every time a new page is
loaded.

Note that we had to add an additional `width: 0` rule because
Foundation's `element-invisible` would apply `1px` and the test checking
for `visible: :hidden` would faile.
2024-03-23 00:35:47 +01:00
Javi Martín
2b962f2789 Use a <main> tag on every page
Many pages had this tag, but many other didn't, which made navigation
inconsistent for people using screen readers.

Note that there are slight changes in two pages:

* The homepage now includes the banner and the content of the
  `shared/header` element inside the <main> tag
* The budgets index now includes the banner inside the <main> tag

I see both potential advantages and disadvantages of this approach,
since banners aren't necessarily related to the main content of a page
but on the other hand they aren't the same across pages and people using
screen readers might accidentally skip them if they jump to the <main>
tag.

So I'm choosing the option that is easier to implement.

Note we're adding a `public-content` class to the <main> element in the
application layout. This might be redundat because the element could
already be accessed through the `.public main` selector, but this is
consistent with the `admin-content` class used in the admin section, and
without it the <main> element would sometimes have an empty class
attribute and we'd have to use `if content_for?(:main_class)` or
`tag.main` which IMHO makes the code less consistent.

The Capybara::DSL monkey-patch is only done on the `visit` method
because it's the only reliable one. Other methods like `click_link`
generate AJAX requests, so `expect(page).to have_css "main", count: 1`
might be executed before the AJAX request is finished, meaning it
wouldn't properly test anything.
2024-03-23 00:35:43 +01:00
Javi Martín
9c037a484e Make proposals map test more robust
We were testing what happens when clicking on a geozone without HTML
coordinates, which won't happen in a real browser.

So we're now defining the HTML coordinates and clicking on the area in
the test, which is what real people will do.

We also avoid having two consecutive `visit` calls, which will interfere
with the way we plan to test the presence of the <main> tag after every
`visit`.

Note that, the test didn't work with the HTML coordinates defined in the
`with_html_coordinates` trait, with Capybara showing the following
error:

```
Selenium::WebDriver::Error::ElementClickInterceptedError:
element click intercepted: Element
  <area shape="poly"
  coords="30,139,45,153,77,148,107,165"
  href="/proposals?search=California"
  title="California" alt="California">
is not clickable at point (413, 456).
Other element would receive the click:
  <img usemap="#map" src="/assets/map.jpg">
```

The cause of this error was the strange shape of the polygon, which was
greatly concave and and so the middle of its area wasn't part of it.
We're changing the polygon so it's now convex and when Capybara clicks
on its middle point everything will work as expected.
2024-03-23 00:33:41 +01:00
Javi Martín
f1105140ae Remove duplicate <main> tags in management views
There can only be one <main> tag in a document, and we've already got a
<main> tag in the management layout.
2024-03-23 00:33:41 +01:00
Javi Martín
f0baa080b6 Merge pull request #4955 from consuldemocracy/dependabot/bundler/master/graphql-2.0.13
Bump graphql from 1.12.14 to 1.13.22
2024-03-22 23:14:38 +01:00
dependabot[bot]
8e63bd9d20 Bump graphql from 1.12.14 to 1.13.22
Bumps [graphql](https://github.com/rmosolgo/graphql-ruby) from 1.12.14 to 1.13.22.
- [Release notes](https://github.com/rmosolgo/graphql-ruby/releases)
- [Changelog](https://github.com/rmosolgo/graphql-ruby/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rmosolgo/graphql-ruby/compare/v1.12.14...v1.13.22)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-22 22:56:42 +01:00
Javi Martín
d0f5a4b80a Merge pull request #5442 from consuldemocracy/code_of_conduct_contact
Update code of conduct contact address
2024-03-22 18:49:54 +01:00
Javi Martín
6c3971871d Update code of conduct contact address 2024-03-22 18:34:47 +01:00
Javi Martín
56a545f86e Merge pull request #5440 from consuldemocracy/remove_link_to_gitter
Remove link to gitter chat
2024-03-22 17:04:24 +01:00
Javi Martín
6bb587c7da Remove link to gitter chat
We're replacing gitter with GitHub Discussions.
2024-03-22 16:39:10 +01:00
Sebastia
9e5344b5d7 Merge pull request #5276 from consuldemocracy/order-cards
Allow sorting homepage cards
2024-03-22 10:56:33 +01:00
Javi Martín
692d509cf5 Merge pull request #5398 from consuldemocracy/readme_badges
Update badges in README files
2024-03-22 03:05:13 +01:00
taitus
bce1474527 Only render position field on table when cards rendered are not headers 2024-03-21 19:00:56 +01:00
coslajohn
529357c980 Merge pull request #5390 Geozone Admin maps
This makes it easier to see if Geojson has been imported correctly.
2024-03-21 18:47:37 +01:00
taitus
4e9d5d8c5a Allow sorting widget_cards on custom pages 2024-03-21 18:27:49 +01:00
taitus
f795c18bec Allow sorting widget_cards on sdg section 2024-03-21 18:27:49 +01:00
taitus
7c85daac3f Allow sorting widget_cards on homepage
Note that we keep :created_at order as complement to new :order field.

We do this so that current installations will not notice any change in the
sorting of their cards when upgrading, as the default "order" field will always
be 1, so it will continue to sort by the "created_at".
2024-03-21 18:27:49 +01:00
taitus
6059aab674 Allow saving a position when create a widget card
We are ensuring that only position field is rendered only on
non-header cards.

Note that we have 3 sections that use widget cards:
- Homepage (cards and header cards)
- Custompages (only have cards)
- Sdg Homepage (cards and header cards)
2024-03-21 18:15:50 +01:00
taitus
9dd10cac19 Add order field to widget cards
We will use this field to enter the position where the cards will be shown to the
user in the homepage.
2024-03-21 18:10:26 +01:00
taitus
e9a7731f49 Do not render "Number of colums" when create a sdg header card
Co-authored-by: Javi Martín <javim@elretirao.net>
2024-03-21 18:08:25 +01:00
Javi Martín
82c24a7ef3 Merge pull request #5428 from consuldemocracy/release_2.1.1
Release version 2.1.1
2024-03-21 15:08:54 +01:00
Javi Martín
e7cc823c87 Reorganize badges in README
So now related badges are together. First paragraph, legal stuff.
Second paragraph, technical tools and status. Third paragraph, links
related to collaboration.
2024-03-21 14:25:01 +01:00
Javi Martín
e32818b3fc Remove Rocket Validator badge
We haven't used this service for at least four and a half years.
2024-03-21 14:24:46 +01:00
Javi Martín
b9e939d375 Release version 2.1.1 2024-03-20 03:38:59 +01:00
Javi Martín
31f42a2c76 Merge pull request #5432 from consuldemocracy/fix_unsafe_spec_warning
Sanitize the output of a dummy component class
2024-03-19 15:24:55 +01:00
Javi Martín
669472c800 Sanitize the output of a dummy component class
After commit 52ec5094f, we started to get a warning when running out
test suite:

```
WARNING: The #<Class:0x00007958c06fb8e0> component rendered HTML-unsafe
output. The output will be automatically escaped, but you may want to
investigate.
```

The reason is that, for security reasons, since version 3.9.0,
ViewComponent no longer renders unsafe output in the `call` method, so
we need to make sure the rendered text is safe. This is similar to what
Rails automatically does in views with `<%= %>`.

While this change doesn't affect the application (this class is only
used in a test), with it we avoid the warning.
2024-03-19 14:54:06 +01:00
Javi Martín
42eff36bdd Merge pull request #5421 from consuldemocracy/rails6.1_rubocop_rules
Add rubocop rules affecting Rails 6.1
2024-03-18 16:29:54 +01:00
Javi Martín
d0fae3377e Add and apply Rails/WhereMissing rubocop rule
So now we know where to use the `where.missing` method which was
introduced in Rails 6.1.

Note this rule didn't detect all cases where the new method can be used.
2024-03-18 16:05:07 +01:00
Javi Martín
86cf674d0c Add Rails/DeprecatedActiveModelErrorsMethods rule
Even though we're already applying this rule since commit 08b12a78f,
it's very useful to have it so we don't accidentally introduce code that
won't work with Rails 7.

After upgrading to Rails 7, this rule will no longer be necessary, since
the code using the deprecated syntax will not work and so we'll notice
it immediately.
2024-03-18 16:05:07 +01:00
Javi Martín
77505db337 Merge pull request #5389 from CoslaDigital/render_geojson
Allow whitespace between square brackets in GeoJSON polygons
2024-03-18 16:03:59 +01:00
Javi Martín
0658edbea2 Merge pull request #5395 from consuldemocracy/fix_new_window_typo
Fix link to debates help
2024-03-18 15:47:59 +01:00
Javi Martín
1a22db8b17 Fix link to debates help
This link used to open in a new window, and we accidentally changed that
behavior while refactoring it in commit c2710de5f.

Since we're adding a test for this case, and the Proposals::NewComponent
class is similar, we're adding a test for that class too. In the case of
proposals, we need to sign in a user because the proposals form contains
fields to attach image, that currently rely on a user being signed in.
2024-03-18 15:29:46 +01:00
Javi Martín
0972bcbbe9 Merge pull request #5422 from consuldemocracy/fix_polls_test
Prevent "Unable to autoload constant" error in tests
2024-03-18 15:28:26 +01:00
Javi Martín
c7ea55ae35 Merge pull request #5431 from consuldemocracy/rubocop_capybara_code_climate
Update Code Climate Rubocop version
2024-03-18 15:23:07 +01:00
Javi Martín
8ba37b295a Temporarily disable a test that fails sometimes
This test is failing often due to an "Unable to autoload constant"
error, that will be fixed after switching to zeitwerk.

Just like it happened in the the "Polls can be listed" test, the reason
seems to be accessing a page containing several ActiveStorage
attachments. However, since this test only makes sense when two or more
images are displayed on the page, we can't change the test so create
just one image.

So, for now, we're commenting the test, and we'll uncomment it again
when we enable zeitwerk in version 2.2.0.
2024-03-18 15:09:17 +01:00
Javi Martín
bbac39e976 Merge pull request #5426 from consuldemocracy/fix_comment_votes_html
Fix invalid HTML in comment votes
2024-03-18 15:02:25 +01:00
Javi Martín
d921eee30d Update Code Climate Rubocop version
Code Climate was failing to analyze our repo because their rubocop 1.31
doesn't support rubocop-capybara.

Since we're using rubocop 1.56.4 in our code, we're going to use
version 1.56.3 for Code Climate which, at the time of writing, is the
latest available version in Code Climate.
2024-03-18 14:54:46 +01:00
Javi Martín
a670b77e75 Merge pull request #5399 from consuldemocracy/dependabot/bundler/view_component-3.11.0
Bump view_component from 3.6.0 to 3.11.0
2024-03-18 14:49:00 +01:00
Javi Martín
8006227bb4 Merge pull request #5403 from consuldemocracy/missing_spanish_translations
Add missing Spanish translations
2024-03-08 15:51:21 +01:00
Javi Martín
3d63238ef6 Add missing Spanish translations
These texts were added in English in commit 7070b0915, but we forgot to
add the texts in Spanish as well.
2024-03-08 15:15:34 +01:00
CoslaJohn
8b3ec8fc79 Applied patch to tidy whitespace and add tests 2024-03-07 12:08:17 +00:00
Javi Martín
a101608ebe Fix invalid HTML in comment votes
We forgot to change the `span` tag when we replaced links with buttons
in commit ba0d21b46.
2024-03-05 00:41:53 +01:00
Javi Martín
deb8b374e7 Simplify creating a proposal poll in a test
This way we avoid variables starting with underscores, which we don't
use almost anywhere else.
2024-03-02 23:43:44 +01:00
Javi Martín
c480cdd918 Don't create records after a visit in polls tests
Creating records after starting the browser with the `visit` method
sometimes results in database corruption and failing tests on our CI.

Splitting some tests or merging them together solves the issue.
2024-03-02 23:43:26 +01:00
Javi Martín
2af1fc72f3 Prevent Unable to autoload constant error in tests
When running these tests, under certain conditions, we get a warning
followed by an error:

```
activesupport-6.1.7.7/lib/active_support/dependencies.rb:502:
warning: already initialized constant ActiveStorage::Representations

activesupport-6.1.7.7/lib/active_support/dependencies.rb:502:
warning: previous definition of Representations was here

Failure/Error: raise LoadError, "Unable to autoload constant
'#{qualified_name}', expected #{file_path} to define it"

LoadError: Unable to autoload constant
ActiveStorage::Representations::RedirectController, expected
activestorage-6.1.7.7/app/controllers/active_storage/representations/redirect_controller.rb
to define it
```

The error seems to take place when we request a page in a test that
loads two (or more) ActiveStorage images if ActiveStorage hasn't loaded
yet, although it's a flaky error and so the test doesn't always behave
like this.

We've tested that switching to zeitwerk solves the issue but, since we
aren't switching to zeitwerk in version 2.1.1 and we'd like this version
to run all tests correctly, for now we're changing the tests so they
don't load two records with images.

On of these tests ("Polls Index Polls can be listed") fails on my
machine when run individually. I haven't been able to consistently
reproduce the other ones.
2024-03-02 22:06:25 +01:00
Javi Martín
1d955b7a20 Simplify using helper methods in components
The `use_helpers` method was added in ViewComponent 3.8.0, and it's
included by default in all components since version 3.11.0.

Note we sometimes delegated the `can?` method to the controller instead
of the helpers, for no particularly reason. We're unifying that code as
well.
2024-03-02 17:34:25 +01:00
dependabot[bot]
52ec5094f0 Bump view_component from 3.6.0 to 3.11.0
Bumps [view_component](https://github.com/viewcomponent/view_component) from 3.6.0 to 3.11.0.
- [Release notes](https://github.com/viewcomponent/view_component/releases)
- [Changelog](https://github.com/ViewComponent/view_component/blob/main/docs/CHANGELOG.md)
- [Commits](https://github.com/viewcomponent/view_component/compare/v3.6.0...v3.11.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-02 17:34:25 +01:00
Javi Martín
8ac1acc5ea Merge pull request #5374 from consuldemocracy/dependabot/bundler/bullet-7.1.6
Bump bullet from 7.0.7 to 7.1.6
2024-03-02 17:31:59 +01:00
dependabot[bot]
331784e926 Bump bullet from 7.0.7 to 7.1.6
Bumps [bullet](https://github.com/flyerhzm/bullet) from 7.0.7 to 7.1.6.
- [Changelog](https://github.com/flyerhzm/bullet/blob/main/CHANGELOG.md)
- [Commits](https://github.com/flyerhzm/bullet/compare/7.0.7...7.1.6)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-02 03:00:10 +00:00
Javi Martín
a6f3952c3b Merge pull request #5361 from consuldemocracy/dependabot/bundler/pdf-reader-2.12.0
Bump pdf-reader from 2.11.0 to 2.12.0
2024-03-02 03:43:06 +01:00