Commit Graph

1026 Commits

Author SHA1 Message Date
Javi Martín
df17bd1354 Ask confirmation to delete pages from the edit page
We were already doing that when deleting pages from the index page, and
we also ask for confirmation in almost every page in the admin section.
2024-04-17 17:31:34 +02:00
Javi Martín
ccf5c81ea9 Use a button to destroy pages from the edit page
We were already using buttons to destroy pages from the pages index.

As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST (or, in this case, DELETE) requests to
the server has a few issues.
2024-04-17 17:31:34 +02:00
Javi Martín
62aad851bf Use icons as links to edit content blocks
Just like we do with the rest of the tables in the admin section.
2024-04-17 16:59:14 +02:00
Javi Martín
6a2ee921de Ask confirmation to delete content blocks from the edit page
We were already doing that when deleting content blocks from the index
page, and we also ask for confirmation in almost every page in the admin
section.
2024-04-17 16:44:10 +02:00
Javi Martín
5a7021396e Use a button to destroy content blocks from the edit page
We were already using button to destroy content blocks from the content
blocks index.

As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST (or, in this case, DELETE) requests to
the server has a few issues.
2024-04-17 16:44:10 +02:00
Javi Martín
d050c04bb0 Use a button to destroy poll question answer images
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST (or, in this case, DELETE) requests to
the server has a few issues.

Note that the AJAX response stopped working after replacing the link
with a button. Not sure about the reason, but, since this is one of the
very few places where we use AJAX calls to delete content, the easiest
solution is to stop using AJAX and be consistent with what we do in the
rest of the admin section.
2024-04-17 16:44:10 +02:00
Javi Martín
53d85d6431 Use a button to destroy officials
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST (or, in this case, DELETE) requests to
the server has a few issues.
2024-04-17 16:44:10 +02:00
Javi Martín
5876738369 Ask confirmation to delete drafts and questions
This is similar to what we do in almost every other page of the admin
section.
2024-04-17 16:44:10 +02:00
Javi Martín
ecad046a99 Use buttons to destroy drafts and questions
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST (or, in this case, DELETE) requests to
the server has a few issues.
2024-04-17 16:44:09 +02:00
Javi Martín
20d3725709 Add missing test to delete a draft version
We weren't testing this action anywhere.
2024-04-17 16:44:09 +02:00
Javi Martín
52ec55970b Use buttons to send notifications and newsletters
As mentioned in commits 5311daadf and bb958daf0, using links combined
with JavaScript to generate POST requests to the server has a few
issues.
2024-04-17 16:44:09 +02:00
Javi Martín
8596f1539f Upgrade to Rails 7.0
The config.file_watcher option still exists but it's no longer included
in the default environtment file. Since we don't use it, we're removing
it.

The config.assets.assets.debug option is no longer true by default [1],
so it isn't included anymore.

The config.active_support.deprecation option is now omitted on
production in favor of config.active_support.report_deprecations, which
is false by default. I think it's OK to keep it this way, since we check
deprecations in the development and test environments but never on
production environments.

As mentioned in the Rails upgrade guide, sprockets-rails is no longer a
rails dependency and we need to explicitly include it in our Gemfile.

The behavior of queries trying to find an invalid enum value has changed
[2], so we're updating the tests accordingly.

The `favicon_link_tag` method has removed the deprecated `shortcut`
link type [3], so we're updating the tests accordingly.

The method `raw_filter` in ActiveSupport callbacks has been renamed to
`filter` [4], so we're updating the code accordingly.

[1] https://github.com/rails/rails/commit/adec7e7ba87e3
[2] https://github.com/rails/rails/commit/b68f0954
[3] Pull request 43850 in https://github.com/rails/rails
[4] Pull request 41598 in https://github.com/rails/rails
2024-04-15 15:39:23 +02:00
Javi Martín
5f24ee9121 Use Zeitwerk instead of the classic autoloader
In Rails 6.1, the classic autoloader is deprecated.

We were getting an error because we were using `autoload` in the
ActiveStorage plugin for CKEditor:

expected file app/lib/ckeditor/backend/active_storage.rb to define
constant Ckeditor::Backend::ActiveStorage

So we're removing the line causing the error.

Finally, we can now restore all the tests that that failed sometimes
with the classic autoloader and that we modified in commits 2af1fc72f
and 8ba37b295.
2024-04-11 19:08:02 +02:00
Javi Martín
35659d4419 Replace initialjs-rails with custom avatar code
The initialjs-rails gem hasn't been maintained for years, and it
currently requires `railties < 7.0`, meaning we can't upgrade to Rails 7
while we depend on it.

Since the code in the gem is simple, and we were already rewriting its
most complex part (generating a background color), we can implement the
same code, only we're using Ruby instead of JavaScript. This way, the
avatars will be shown on browsers without JavaScript as well. Since
we're adding a component test that checks SVG images are displayed even
without JavaScript, we no longer need the test that checked images were
displayed after AJAX requests.

Now the tests show the user experience better; people don't care about
the internal name used to select the initial (which is what we were
checking); they care about the initial actually displayed.

Note initialjs generated an <img> tag using a `src="data:image/svg+xml;`
attribute. We're generating an <svg> tag instead, because it's easier.
For this reason, we need to change the code slightly, giving the <svg>
tag the `img` role and using `aria-label` so its contents won't be read
aloud by screen readers. We could give it a `presentation` role instead
and forget about `aria-label`, but then screen readers would read the
text anyway (or, at least, some of them would).
2024-04-11 18:48:33 +02:00
Javi Martín
d3b1b21d3d Extract matcher to check for avatars
We're going to change the code to render avatars, and having a matcher
will make it easier.
2024-04-11 18:48:33 +02:00
Javi Martín
c8c1b18bc1 Fix RSpec/LetBeforeExamples rubocop offense
This was accidentally introduced in commit 64aa1ffe0. Pronto didn't
detect it because the line itself was fine; the problem lied in its
place within the file.
2024-03-30 02:08:49 +01:00
CoslaJohn
237bfb4fad Change the english translation of check ballot to avoid confusion 2024-03-29 23:41:05 +01:00
Sebastia
d76f95459e Merge pull request #5369 from consuldemocracy/refactor_comments_specs
Make comments specs faster
2024-03-25 15:04:04 +01:00
taitus
6987c2e7df Remove unnecessary specs
All these types of tests have already been grouped together in the
comments_specs file which contains different factories including
budget_investments.

I don't think it is necessary to maintain these tests.
2024-03-25 07:59:42 +01:00
taitus
64aa1ffe06 Move notifiable in app shared example to questions specs 2024-03-25 07:59:42 +01:00
taitus
ad04ea76f5 Remove unused spec file 2024-03-25 07:59:42 +01:00
taitus
64de5eb81c Improve describe text 2024-03-25 07:59:42 +01:00
taitus
793eaf4429 Remove unnecessary specs
The test "display administrator id on public views" is not correct. The valuation comments
are not display never on public views. If we reload this admin page we can see that the
description is render instead of administrator_id as we can see at the upper test:

```
scenario "display administrator description on admin views"
```

The deleted test was passed because there is an error at the moment to render the comments.
As we can see in the file ´app/views/comments/create.js.erb:10´ we try render comment
without valuation value:

```
App.Comments.add_comment(parent_id, "<li><%= j(render @comment) %></li>");
```
That it is necessary to render correctly the description or the id.

By other hand the test "public users not see admin description"  is already being checked
 in the 'system/comments_specs'. However, we are going to add a new expectation to
make sure that the admin description does not appear on the public pages.
2024-03-25 07:59:42 +01:00
taitus
3f1561e408 Unify flaggable specs 2024-03-25 07:59:42 +01:00
taitus
f328d53f41 Unify submit button comments specs 2024-03-25 07:59:42 +01:00
taitus
e3ce8a85fa Unify show comments specs 2024-03-25 07:59:42 +01:00
taitus
886aee72fc Unify reply to reply comments specs 2024-03-25 07:59:42 +01:00
taitus
8da4c60c2a Unify hide comments specs 2024-03-25 07:59:42 +01:00
taitus
8ba16c2330 Unify collapse comments specs 2024-03-25 07:59:42 +01:00
taitus
093ad07a14 Unify voting comments allow undoing votes specs 2024-03-25 07:59:42 +01:00
taitus
992a8182ff Unify voting comments update specs 2024-03-25 07:59:42 +01:00
taitus
35bc03f640 Unify voting comments create specs 2024-03-25 07:59:42 +01:00
taitus
dbd419e75d Unify voting comments show specs 2024-03-25 07:59:42 +01:00
taitus
57805747a2 Simplify administrators comments tests 2024-03-25 07:59:42 +01:00
taitus
79d00e7b92 Unify can not comment as a moderator specs 2024-03-25 07:59:42 +01:00
taitus
ac740f3657 Unify reply as an administrator
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
f9349a4b0d Unify comment as administrator specs 2024-03-25 07:59:42 +01:00
taitus
8a2e0c8e1f Simplify moderator comments tests 2024-03-25 07:59:42 +01:00
taitus
adae022f77 Unify can not comment as an administrator specs 2024-03-25 07:59:42 +01:00
taitus
a949a046ab Unify reply as a moderator 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
1a17ab4ac1 Unify comment as a moderator specs 2024-03-25 07:59:42 +01:00
taitus
154fb19b87 Unify erasing a comment's author comments specs 2024-03-25 07:59:42 +01:00
taitus
df4668004c Unify N replies comments specs 2024-03-25 07:59:42 +01:00
taitus
f0fa004f85 Unify errors on 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".

```
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
f4c3e740e6 Unify reply show parent comments specs 2024-03-25 07:59:42 +01:00
taitus
d4f3680dcc Unify reply update parent comments specs 2024-03-25 07:59:42 +01:00
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