Commit Graph

29 Commits

Author SHA1 Message Date
Javi Martín
a1439d0790 Apply Layout/LineLength rubocop rule
Note we're excluding a few files:

* Configuration files that weren't generated by us
* Migration files that weren't generated by us
* The Gemfile, since it includes an important comment that must be on
  the same line as the gem declaration
* The Budget::Stats class, since the heading statistics are a mess and
  having shorter lines would require a lot of refactoring
2023-08-30 14:46:35 +02:00
Javi Martín
1a098dfcab Add and apply MultilineMethodCallBraceLayout rule
In order for this rule to work effectively when running `--autocorrect`,
we also need to enable the `ClosingParenthesisIndentation` rule.
2023-08-18 14:56:16 +02:00
Javi Martín
8f7a3bfb35 Disable JavaScript in notification digest spec
This test has been failing many times because it checks the database
after starting the process running the browser.

We're disabling JavaScript like we do in every other test using the
`create_proposal_notification` method. This way, Capybara will use the
rack driver and there'll be no risk of errors that currently might take
place if both the process running the browser and the process running the
test access the database.
2022-06-13 17:39:21 +02:00
Javi Martín
647a7dc435 Fix text to subscribe to a newsletter
In English, circumstancial complements usually go after the direct
complement.
2022-06-01 14:27:33 +02:00
Javi Martín
fa15ac0c3b Implement pending email digest test 2022-04-07 15:34:09 +02:00
Javi Martín
1f55be7c5e Remove obsolete pending test reference
The test "Sender email" already checks the receiver's name appears in
the copy sent to the sender.
2022-04-07 11:55:35 +02:00
taitus
7bd1f15f37 Improve translation for the notification of comments
Currently the translation:
"Notify me by email when someone comments on my proposals or debates"
It only refers to proposals and debates, but actually it also refers to budget
investments, topics and polls.
2022-01-21 20:21:52 +01:00
taitus
13965901f8 Update "newsletter" notification email to add unsubscribe link 2022-01-21 20:21:52 +01:00
taitus
1fcbd49448 Update "reply" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.

We also adapted the existing generic text by adding a description of
the related notification.
2022-01-21 20:21:52 +01:00
taitus
3a2564a92d Remove "slashes" from specs
I think the "slashes" can be removed.
The specs work fine without the "slashes".
2022-01-21 20:21:52 +01:00
taitus
478ac3a952 Update "proposal" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.
2022-01-21 20:21:52 +01:00
taitus
a36f3feb87 Update "direct message" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.
2022-01-21 20:21:52 +01:00
taitus
0af765a3bd Update "comment" notification email to add unsubscribe link
We modified the link that previously redirected us to the "My content"
page to redirect us to the new page for managing subscriptions.

We also adapted the existing generic text by adding a description of
the related notification.
2022-01-21 20:21:52 +01:00
Javi Martín
f638e50174 Wait for suggestions to finish loading in tests
Sometimes tests were hanging indefinitely. Debugging shows that in some
cases it's due to submitting a form before the AJAX request to get
proposals, debates or investments suggestions is finished, since having
an AJAX and a non-AJAX request at the same time when running the test
sometimes leads to unexpected results.

In our case, we were having many timeouts in Github Actions in the
branches where we use both ActiveStorage and Paperclip to store files
(based on pull request 4598). I can reproduce it in those branches
running the following test ("Should show new image after successful
creation with one uploaded file"), although only when my laptop isn't
plugged (!!):

```
rspec './spec/system/proposals_spec.rb[1:33:1:14]'
```

Since we didn't have a proper way to know the AJAX request had finished,
we're adding a `suggest-success` class to the element showing the
suggestions when that happens. Then in the tests we can look for that
class after filling in the title of a proposal, debate or investments.
Just for clarity's sake, we're also adding the `suggest-loading` class
when the suggestions are loading.

In order not to have expectations everywhere about the suggestions,
we're extracting methods to fill in those titles in the tests. Note we
aren't using these methods in the "edit" actions (suggestions are not
showing when editing) or in tests with the `no_js` tag (since
suggestions only work with JavaScript).
2021-09-22 18:29:23 +02:00
Javi Martín
9b61945ee4 Add and apply Lint/EmptyBlock rubocop rule
It was introduced in Rubocop 1.1.0.
2021-09-03 11:49:53 +02:00
Javi Martín
afb660f82c Fix rubocop convention offenses
While we use Pronto to detect offenses in the lines changed in our pull
request, sometimes our changes introduce offenses in other lines, and we
don't detect them.

In commit 0488b3735, we removed the only usage of the `heading` method
in a test, which caused a `RSpec/LetSetup` offense.

In commit 287c48873, we changed some lines from `fill_in` to
`fill_in_ckeditor`. Some of these lines were aligned with the following
ones, which after that change had extra spacing for no reason.

Finally, in commit 8d38ed58c we added a line before two lines which had
their equals signs aligned. Since, after adding this line, the block was
no longer aligned, there was no reason for the extra space in one of the
lines.
2021-08-09 16:23:40 +02:00
decabeza
0488b3735f Hide single heading select on new budget investment form 2021-06-11 12:37:56 +02:00
Javi Martín
405c6e6d14 Test data introduced from the user's point of view
Users don't care about database content; they care about what they see
on the screen.

Writing tests this way we also avoid potencial database inconsistencies
due to accessing the database after starting the browser.
2021-04-16 14:33:26 +02:00
Javi Martín
9f926de54e Refactor method to reply to comment in tests
We take the comment as a parameter instead of the user, since usually
people reply to comments and not to users.

We also remove one database query after the browser has started, since
we can use `debate_path(debate)`. It's also more clear why we're using
`debate_path` in the test; before these changes, we had to enter the
`reply_to` method to realize that we were replying on a debate.
2021-04-16 14:25:34 +02:00
Javi Martín
2458ca22c5 Use a more descriptive parameter name 2021-04-16 14:25:34 +02:00
Javi Martín
92ddcb7aef Use JavaScript in system tests by default
JavaScript is used by about 98% of web users, so by testing without it
enabled, we're only testing that the application works for a very
reduced number of users.

We proceeded this way in the past because CONSUL started using Rails 4.2
and truncating the database between JavaScript tests with database
cleaner, which made these tests terribly slow.

When we upgraded to Rails 5.1 and introduced system tests, we started
using database transactions in JavaScript tests, making these tests much
faster. So now we can use JavaScript tests everywhere without critically
slowing down our test suite.
2021-04-07 14:41:06 +02:00
Javi Martín
424fe7f5d2 Add extra expectation in emails spec
The test is failing on my machine sometimes. I thought it was because
`open_last_email` didn't wait fot the request generated by clicking the
"Registrarse" button to finish. Even if that might be the case, adding
an extra expectation showed the test was really failing because
invisible captcha reported the form was filled in too fast.

I wonder whether invisible captcha is working properly or there are
times where it doesn't start its timer when it should.

Since this might be a bug in the application, I'm not changing the test
just to make it pass.
2021-04-07 14:41:06 +02:00
Javi Martín
287c488734 Use JavaScripts in tests using CKEditor
We were filling in textareas, so we were only testing how the
application behaves for about 1%-2% of our users.
2021-04-07 14:41:06 +02:00
Javi Martín
b2bc4d19f5 Use JavaScript in tests opening modal dialogs
This way we reproduce the user experience in the tests, and we can make
sure modal dialogs open when we expect it.
2021-04-07 14:41:06 +02:00
Javi Martín
f3595833fd Improve readability in some system specs
We're improving the readability of the ones we're about to modify.
Using human texts makes tests easier to read and guarantees we're
testing from the user's point of view. For instance, if we write
`fill_in banner_target_url`, the test will pass even if the field has no
label associated to it. However, `fill_in "Link"` makes sure there's a
field with an associated label.
2021-04-07 14:32:49 +02:00
taitus
1a58fcf2a2 Make tests independent of Setting["org_name"]
So tests won't fail when an institution changes the default organization
name.

The tests are also easier to understand now, since it's more obvious
where the "CONSUL" text is coming from.
2020-12-08 18:56:33 +01:00
Javi Martín
3da4ee00b8 Simplify tests requiring admin login
We were repeating the same code over and over (with a few variants) to
setup tests which require an administrator. We can use a tag and
simplify the code.
2020-12-02 15:33:19 +01:00
Javi Martín
61a63ddd59 Use label text instead of ID to fill in comments
This way tests are easier to read (and easier to write).
2020-05-12 23:57:57 +02:00
Javi Martín
9427f01442 Use system specs instead of feature specs
We get rid of database cleaner, and JavaScript tests are faster because
between tests we now rollback transactions instead of truncating the
database.
2020-04-24 15:43:54 +02:00