Commit Graph

20144 Commits

Author SHA1 Message Date
Javi Martín
6f7d4096f5 Add document about our coding conventions
There are some conventions that can't be checked by linters and were not
documented anywhere.
2025-01-13 16:26:42 +01:00
Javi Martín
3b62474f5d Merge pull request #5821 from consuldemocracy/ruby3.2.6
Upgrade Ruby to version 3.2.6
2025-01-10 16:38:24 +01:00
Javi Martín
ff76d65b43 Merge pull request #5825 from consuldemocracy/maintainers_update
Update list of maintainers
2025-01-10 16:37:27 +01:00
Javi Martín
28dde2e798 Merge pull request #5820 from consuldemocracy/ruby_version_in_gemfile
Add Ruby version to Gemfile
2025-01-09 17:47:56 +01:00
Javi Martín
453c4d2427 Upgrade Ruby to version 3.2.6 2025-01-09 17:15:33 +01:00
Javi Martín
cf6d9ce753 Add Ruby version to Gemfile
Since Bundler 2.4.19, including in Ruby 3.2.3, it's possible to define
the Ruby version in the Gemfile by indicating which file contains the
version [1].

There are at least two practical cases where this is an advantage.

First, people using RVM in development will no longer accidentally run
the application using the wrong Ruby version (which, before these
changes, might happen if they switch to a branch using a different Ruby
version and forget to run `rvm use` or exit the current folder and enter
it again) because they will get an error when trying to do so.

Second, people using services like Heroku no longer need to modify the
Gemfile.

The disadvantage is that, now, every time we update the Ruby version, we
have to remember to run `bundle` so our `Gemfile.lock` gets the new
version.

[1] https://github.com/rubygems/rubygems/releases/tag/bundler-v2.4.19
2025-01-09 17:14:42 +01:00
Javi Martín
7204b8bbec Merge pull request #5818 from consuldemocracy/split_vendored_css
Extract CSS files for vendored and admin styles
2025-01-08 20:35:08 +01:00
Javi Martín
ed1713d5e2 Merge pull request #5819 from consuldemocracy/remove_code_to_upgrade_to_2.2
Remove tasks to upgrade to version 2.2
2025-01-08 20:10:29 +01:00
Javi Martín
d7c373509a Remove tasks to upgrade to version 2.2
Note that, while we're no longer including them as part of the
`execute_release_2.2.0_tasks` task, we're keeping the tasks to remove
duplicate poll voters and poll options just in case there are some
unexpected issues when adding a unique database index while upgrading to
version 2.3.0. We'll remove them in version 2.4.0.
2025-01-08 16:47:57 +01:00
Javi Martín
8d1a848e60 Remove code to rotate non-SHA256 cookies
This code was added in commit b3f570512 in order to rotate existing
cookies used by Consul Democracy 2.1 and earlier. Since the code was
included in Consul Democracy 2.2, existing installation using Consul
Democracy 2.2 will have already rotated the old cookies, which means we
don't need the cookie rotator anymore.
2025-01-08 16:47:57 +01:00
Javi Martín
e5bfb92564 Compile admin CSS in a different stylesheet
With this change, on my browser, reloading a page in development after
changing a CSS file is about 25% faster than simply splitting the CSS
code between `application.css` and `vendored.css`. Compared to using
only one `application.css` file containing everything, reloading a page
in development is about 35% faster.

The combined size of all the generated stylesheets is now about 0.5%
bigger. Not sure why (maybe placeholder selectors?), but the difference
is negligible.

Note that we could load the `administration.css` file only in the admin
area, reducing the size of the page for people accessing the public
area. However, the size of this stylesheet (compressed) is 28K, which is
less than 3% of the overall size of a page and, on the other hand,
there's a risk of some styles no longer being applied because we might
have overlooked the fact that some styles in the `administration.css`
are also applied to the public area.

So, for now, we're still loading the administration styles in the public
area. We might reconsider in the future.
2025-01-08 16:37:43 +01:00
Javi Martín
4646c056a7 Compile vendored CSS in a different stylesheet
With this change, on my browser, reloading a page in development after
changing a CSS file is about 10%-15% faster.

On the minus side, this change results in an extra request when browsing
the page; AFAIK it isn't that big of a deal, even when the server isn't
using HTTP/2.
2025-01-08 16:27:52 +01:00
Javi Martín
b6ffeeca62 Move styles from admin to layout
These styles are used in places other than the admin section. In
particular, the `.button.small.success` style is no longer used in the
admin section but only in the verified user form.

Note: I'm not sure whether the `table .callout` selector matches any
element, either in the admin or in the public section, so I'm leaving it
where it was.
2025-01-08 16:27:43 +01:00
Javi Martín
111516f660 Move stats styles to the stats stylesheet
These styles aren't only used in the admin section but also in the
public stats page.
2025-01-08 16:20:37 +01:00
Javi Martín
b3588b1865 Remove no-margin-bottom HTML class
It was only used once, and we can use a selector that makes it obvious
where it is used. Besides, the style for the no-margin-bottom class was
to remove the bottom margin, which was inconsistent with the style for
the no-margin-top class, which adds a negative margin to the element.

I'm not sure why we're removing the margin here, though, since it isn't
consistent with the rest of the forms in the application. For now, we're
keeping it the way it used to look.
2025-01-08 16:20:37 +01:00
Javi Martín
02aac86b04 Move edit password manually view to a component
We're restructuring the CSS of the admin stylesheet, and there was a
rule that is only applied to this component.
2025-01-08 16:20:37 +01:00
Javi Martín
0657749ead Remove unused CSS in admin stylesheet
* The `archived` class isn't used since commit cd982768f
* The `ignored` class isn't used since commit 343025872
* The `count-error` class isn't used since commit bddfee2b8
* The `edit-legislation-draft-version`, `edit-legislation-process` and
  `legislation-questions-answers` classes aren't used since commit
  d679c1eb7
* The `legislation-process-save`, `legislation-question-delete`,
  `legislation-process-version` and `legislation-process-question`
  classes aren't used since commit f8707a73cd
* The `is-featured` class isn't used since e60ffa3c0
* The `on-hover` and `on-hover-block` classes aren't used since commit
  d91388b2b
* The `total-price` class isn't used since commit d0b8fef6b
* The `login-as` class was never used in the first place
2025-01-08 16:19:44 +01:00
Javi Martín
89ffec2b87 Fix typo in investments stylesheets folder name
The styles were being loaded anyway because we use `budgets/**/*` to
load the stylesheets related to budgets.
2025-01-08 16:10:05 +01:00
Javi Martín
7c988e2568 Merge pull request #5829 from consuldemocracy/dependabot/bundler/rails-7.0.8.7
Bump rails from 7.0.8.6 to 7.0.8.7
2025-01-08 14:48:12 +01:00
dependabot[bot]
4373cca6f8 Bump rails from 7.0.8.6 to 7.0.8.7
Bumps [rails](https://github.com/rails/rails) from 7.0.8.6 to 7.0.8.7.
- [Release notes](https://github.com/rails/rails/releases)
- [Commits](https://github.com/rails/rails/compare/v7.0.8.6...v7.0.8.7)

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

Signed-off-by: dependabot[bot] <support@github.com>
2025-01-01 23:00:30 +00:00
Javi Martín
0eb62f9b9c Merge pull request #5616 from coslajohn/maps
Render Geozone Maps Collections and Multipolygons
2024-12-23 18:01:12 +01:00
Javi Martín
887d0d2419 Use render_map to render the map component
This is done for consistency. We always use `render_map`, but forgot to
do the same in commit 529357c98.
2024-12-23 17:35:33 +01:00
Javi Martín
1f627d34f1 Make sure polygons contain valid rings
According to the GeoJSON specification [1]:

> * A linear ring is a closed LineString with four or more positions.
> * The first and last positions are equivalent, and they MUST contain
>   identical values; their representation SHOULD also be identical.
> (...)
> * For type "Polygon", the "coordinates" member MUST be an array of
>   linear ring coordinate arrays.

Note that, for simplicity, right now we aren't checking whether the
coordinates are defined counterclockwise for exterior rings and
clockwise for interior rings, which is what the specification expects.

[1] https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.6
2024-12-23 17:35:33 +01:00
Javi Martín
c3bda443a6 Make sure all lines in a MultiLineString are valid
Note we're starting to use hashes in tests because the objects here are
complex and using hashes makes the tests easier to read.
2024-12-23 17:35:33 +01:00
Javi Martín
9ef68f863a Make sure a LineString has at least two points
According to the GeoJSON specification [1]:

> For type "LineString", the "coordinates" member is an array of two or
> more positions.

Note that the same doesn't seem to apply to a MultiPoint [2]:

> For type "MultiPoint", the "coordinates" member is an array of
> positions.

[1] https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.4
[2] https://datatracker.ietf.org/doc/html/rfc7946#section-3.1.3
2024-12-23 17:35:33 +01:00
CoslaJohn
624e60eab9 Added layer control to map to allow each geozone display to be toggled on/off
Note we're adding a `name` property to the geozones investments sidebar
map even if we don't render the geozones in the map, in order to
simplify the JavaScript function `geozoneLayers`.
2024-12-23 17:35:33 +01:00
CoslaJohn
cb8b0ad6ff Support different colors and headings on each feature
We're making sure each feature contains properties in order to avoid
possible JavaScript errors.

We're also adding a default color to a geozone.
2024-12-23 17:35:33 +01:00
CoslaJohn
5dbe2cbf24 Support FeatureCollection and MultiPolygon in geozones
We're reworking the format validation to correctly interpret feature
collection, feature, and geometry, according to RFC 7946 [1].

Since Leaflet interprets GeoJSON format, we're rendering the GeoJSON as
a layer instead of as a set of points. For that, we're normalizing the
GeoJSON to make sure it contains either a Feature or a
FeatureCollection. We're also adding the Leaflet images to the assets
path so the markers used for point geometries are rendered correctly.

Note we no longer allow a GeoJSON containing a geometry but not a
defined type. Since there might be invalid GeoJSON in existing Consul
Democracy databases, we're normalizing these existing geometry objects
to be part of a feature object.

We're also wrapping the outline points in a FeatureCollection object
because most of the large GIS systems eg ArcGIS, QGIS export geojson as
a complete FeatureCollection.

[1] https://datatracker.ietf.org/doc/html/rfc7946

Co-authored-by: Javi Martín <javim@elretirao.net>
2024-12-23 17:35:33 +01:00
Javi Martín
11e9e404b6 Merge pull request #5506 from consuldemocracy/remove_campaigns_and_ahoy_events
Remove the campaigns and ahoy_events database tables
2024-12-20 21:24:11 +01:00
Javi Martín
4e010708e5 Update list of maintainers 2024-12-19 14:46:16 +01:00
Javi Martín
ce131ea650 Merge pull request #5817 from consuldemocracy/bookworm_in_docker
Use Debian Bookworm in our Dockerfile
2024-12-18 16:45:20 +01:00
Javi Martín
bf4e79d42b Merge pull request #5823 from consuldemocracy/dependabot/npm_and_yarn/nanoid-3.3.8
Bump nanoid from 3.3.7 to 3.3.8
2024-12-17 17:53:15 +01:00
dependabot[bot]
f5e45ee1c5 Bump nanoid from 3.3.7 to 3.3.8
Bumps [nanoid](https://github.com/ai/nanoid) from 3.3.7 to 3.3.8.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.3.7...3.3.8)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-14 23:20:14 +00:00
Javi Martín
b6ba27fe47 Use Debian Bookworm in our Dockerfile
Debian Bookworm was released in version 10 June 2023, and Bullseye
already received its final point release on August 2024 [1].

[1] https://lists.debian.org/debian-release/2024/07/msg00231.html
2024-12-09 14:13:46 +01:00
Javi Martín
dc832f1adb Merge pull request #5815 from consuldemocracy/dependabot/npm_and_yarn/cross-spawn-7.0.6
Bump cross-spawn from 7.0.3 to 7.0.6
2024-12-05 17:51:09 +01:00
dependabot[bot]
9da846f73c Bump cross-spawn from 7.0.3 to 7.0.6
Bumps [cross-spawn](https://github.com/moxystudio/node-cross-spawn) from 7.0.3 to 7.0.6.
- [Changelog](https://github.com/moxystudio/node-cross-spawn/blob/master/CHANGELOG.md)
- [Commits](https://github.com/moxystudio/node-cross-spawn/compare/v7.0.3...v7.0.6)

---
updated-dependencies:
- dependency-name: cross-spawn
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-05 16:25:25 +00:00
Javi Martín
a664ccfa5a Merge pull request #5812 from consuldemocracy/dependabot/bundler/rails-html-sanitizer-1.6.1
Bump rails-html-sanitizer from 1.6.0 to 1.6.1
2024-12-05 17:24:44 +01:00
dependabot[bot]
a8096102d6 Bump rails-html-sanitizer from 1.6.0 to 1.6.1
Bumps [rails-html-sanitizer](https://github.com/rails/rails-html-sanitizer) from 1.6.0 to 1.6.1.
- [Release notes](https://github.com/rails/rails-html-sanitizer/releases)
- [Changelog](https://github.com/rails/rails-html-sanitizer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/rails/rails-html-sanitizer/compare/v1.6.0...v1.6.1)

---
updated-dependencies:
- dependency-name: rails-html-sanitizer
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-02 22:20:33 +00:00
Sebastia
2e8eb6abf7 Merge pull request #5797 from consuldemocracy/reduce-tests
Make nested imageable specs faster
2024-11-26 19:01:49 +01:00
taitus
fdee159185 Remove show_caption_for? method
The `show_caption_for?` method was used to determine whether to check for the
presence of a `figcaption` element, but its only purpose was to skip the check
when the factory was `:budget.

The reason we skip the `figcaption` check for `:budget` is that it is the only case
where the test is verifying the form's edit page, where displaying a `figcaption` does
not make sense.
2024-11-26 18:10:28 +01:00
taitus
3fd2a1f498 Remove redirected_to_resource_show_or_navigate_to method
This method was removed as its logic was redundant or unnecessary:

- For "Proposal" new:
After creating a proposal, we are redirected to the "created" page, where the text
"Not now, go to my proposal" is not present, leading to a constant
`rescue Capybara::ElementNotFound`.

Instead, the "created" page shows a preview of how the proposal will look when
published and a link saying "No, I want to publish the proposal".  Since the click's
purpose was to navigate to the proposal's "show" page, and this can already be
verified on the "created" page, no additional handling is needed for this case.

- For "Proposal" edit:
After updating the proposal, we are directly redirected to the proposal's "show" page,
so no click_link logic is necessary here either.

- For "Budget":
The redirection is now handled directly with:
  `visit edit_admin_budget_path(imageable) if factory == :budget`.
2024-11-26 18:10:28 +01:00
taitus
08c4ecbed2 Remove unnecessary method 2024-11-26 18:10:28 +01:00
taitus
84bec1241f Remove redundant "loading-bar.errors"
In the imageable_attach_new_file method used in this tests the:
> expect(page).to have_css ".loading-bar.errors"
is already being checked.

Therefore, to leave only the line:
> imageable_attach_new_file(file_fixture("logo_header.png"), false)
in the test, since there is another test that verifies it,
I think we can remove the test altogether.
2024-11-26 18:10:28 +01:00
taitus
c80641e5f2 Regroup tests for edit path 2024-11-26 18:10:28 +01:00
taitus
e450186122 Regroup tests for link visibility and upload images 2024-11-26 18:10:28 +01:00
taitus
71e758f71c Remove redundant ".loading-bar.complete"
In the imageable_attach_new_file method used in these tests the:
> expect(page).to have_css ".loading-bar.complete"
is already being checked, so there is no need to verify it twice.
2024-11-26 18:10:28 +01:00
taitus
3877479b69 Extract proposal edit from shared nested imageable specs to system specs 2024-11-26 18:10:26 +01:00
taitus
cdfaec5217 Extract management budget investment from shared nested imageable specs to system specs 2024-11-26 17:58:10 +01:00
taitus
9d7fa9d0f8 Unify notice responders for budget investments create action 2024-11-26 17:58:10 +01:00
taitus
1cf85560dd Extract poll question option images from shared nested imageable specs to system specs
This is the only it_behaves_like "nested imageable" call where the has_many_images parameter is set to true.

Previously, the shared example skipped or altered expectations based on this parameter. Now, this behavior is
moved to the factory level (:future_poll_question_option).

Since this is an administrative section, a related administrator is created for the user.
2024-11-26 17:58:10 +01:00