Commit Graph

18696 Commits

Author SHA1 Message Date
taitus
d3f4c7f99e Unify reply comments specs
Note that the click_link "Reply" is now inside a "within".

This is due to the case of "legislation_annotation" before in the original test
no comment was created as it simply took the one created by default when creating
a "legislation_annotation".

```
  annotation = create(:legislation_annotation, author: citizen)
  comment = annotation.comments.first
```

Now to try to unify this test, we always create a comment, and in this case as we
also created the "legislation_annotation" we have 2 comments, so it is necessary
to add the "click_link" inside the "within".
2024-03-25 07:59:42 +01:00
taitus
ed5ba0592c Unify create comments specs 2024-03-25 07:59:42 +01:00
taitus
d24c2859c4 Unify paginated comments specs 2024-03-25 07:59:42 +01:00
taitus
7006564c31 Unify sanitizes comment spec 2024-03-25 07:59:42 +01:00
taitus
2f01d66557 Unify turns links specs 2024-03-25 07:59:42 +01:00
taitus
b979c17a4b Unify Creation date specs 2024-03-25 07:59:42 +01:00
taitus
98aea85eaa Unify comment order specs 2024-03-25 07:59:42 +01:00
taitus
daab57a21e Unify collapsable comments specs 2024-03-25 07:59:42 +01:00
taitus
0c58e7e3b4 Unify link to comment show specs
Note that, in all cases except in :legislation_annotation, the behavior for
click_link is now slightly different.

Previously, the click_link outsite of within block meant that we made sure there
was only one link with that text in the whole page. Now, in order to unify this
spec we change the behaviour.
2024-03-25 07:59:42 +01:00
taitus
f2e4eec748 Unify show comments specs 2024-03-25 07:59:42 +01:00
taitus
ab79d1e30e Unify index comments specs 2024-03-25 07:59:42 +01:00
taitus
a5e4fb13b4 Unify errors on create comments 2024-03-25 07:59:42 +01:00
taitus
0f2f79ba99 Unify not logged user comments specs
Since commit de1bfd44 'Write a comment' text is deleted.
We are changing this text for the current text 'Leave your comment'
or 'Leave your answer'
2024-03-25 07:59:42 +01:00
taitus
45d82d6e6b Move comments form to component 2024-03-25 07:59:39 +01:00
taitus
bca3415aa6 Use comments component for investments valuation comments 2024-03-22 08:57:05 +01:00
taitus
260196ca54 Use comments component for legislation annotations and questions 2024-03-22 08:56:13 +01:00
taitus
6a9e347676 Use comments component in budget investments show 2024-03-21 14:30:41 +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
dependabot[bot]
ac9472cc0b Bump pdf-reader from 2.11.0 to 2.12.0
Bumps [pdf-reader](https://github.com/yob/pdf-reader) from 2.11.0 to 2.12.0.
- [Changelog](https://github.com/yob/pdf-reader/blob/main/CHANGELOG)
- [Commits](https://github.com/yob/pdf-reader/compare/v2.11.0...v2.12.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-02 03:19:02 +01:00
Javi Martín
8ec1edca30 Merge pull request #5373 from consuldemocracy/dependabot/bundler/faker-3.2.3
Bump faker from 3.2.1 to 3.2.3
2024-03-02 03:15:19 +01:00
dependabot[bot]
518eb333b4 Bump faker from 3.2.1 to 3.2.3
Bumps [faker](https://github.com/faker-ruby/faker) from 3.2.1 to 3.2.3.
- [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.2.1...v3.2.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-02 02:00:07 +00:00
Javi Martín
a30917b746 Merge pull request #5356 from consuldemocracy/dependabot/bundler/factory_bot_rails-6.4.3
Bump factory_bot_rails from 6.2.0 to 6.4.3
2024-03-02 02:58:19 +01:00
dependabot[bot]
56311eeefb Bump factory_bot_rails from 6.2.0 to 6.4.3
Bumps [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails) from 6.2.0 to 6.4.3.
- [Release notes](https://github.com/thoughtbot/factory_bot_rails/releases)
- [Changelog](https://github.com/thoughtbot/factory_bot_rails/blob/main/NEWS.md)
- [Commits](https://github.com/thoughtbot/factory_bot_rails/compare/v6.2.0...v6.4.3)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-02 01:21:14 +00:00
Javi Martín
70edfbe624 Merge pull request #5290 from consuldemocracy/dependabot/bundler/mdl-0.13.0
Bump mdl from 0.12.0 to 0.13.0
2024-03-02 02:15:00 +01:00
dependabot[bot]
99b9167e72 Bump mdl from 0.12.0 to 0.13.0
Bumps [mdl](https://github.com/mivok/markdownlint) from 0.12.0 to 0.13.0.
- [Changelog](https://github.com/markdownlint/markdownlint/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mivok/markdownlint/compare/v0.12.0...v0.13.0)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-02 00:51:07 +00:00