Commit Graph

16 Commits

Author SHA1 Message Date
taitus
9081174dd7 Add and apply Style/KeywordArgumentsMerging rubocop rule
This rule was introduced in RuboCop 1.68 to encourage passing
additional keyword arguments directly instead of using merge.
2025-03-05 11:42:47 +01:00
Javi Martín
2c9c5d9cd4 Extract component to render avatars in comments
This way it'll be easier to add tests for it and refactor it.
2024-04-11 18:48:33 +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
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
taitus
934ce21871 Allow passing :with argument to :be_rendered
We need it in order to check the rendered content.
2021-11-04 10:49:36 +01:00
taitus
612872ac7a Define and apply matcher :be_rendered
Add this changes to make components specs clear
2021-11-04 10:49:36 +01:00
Javi Martín
72c2b87227 Wait till CKEditor is ready before checking it
With chromedriver >= 80, the tests are freezing sometimes, particularly
when the same editor is loaded again.

We don't know whether it's a CKEditor issue or a chromedriver issue. In
the past we've had some errors related to CKEditor trying to load the
same instance twice and we aren't sure they have been fixed since we
could never reproduce them.

It could be a coincidence, though. If we modify the views so the only
content of the `<body>` tag is a textarea with the `html-area` class,
chromedriver freezes even if we only access the page once. So maybe
we're only detecting the problem on the second visit because the second
request is faster than the first one.

Since chromedriver no longer hangs after this change, we don't have to
force any chromedriver version anymore.
2020-06-09 13:29:56 +02:00
Javi Martín
4d65507cbb Check for exact text in have_ckeditor
If we don't use the `exact` option, tests will pass even if filling in
CKEditor adds the content twice or adds the new content to the existing
content, which has actually happened and has gone mostly unnoticed while
testing several ways to fill in CKEditor with Capybara (particularly,
when using Capybara's `send_keys` method). The problem was detected by
just one test, which checked the original content wasn't present anymore
after updating a record.
2020-06-09 13:29:56 +02:00
Javi Martín
e844b0b2db Remove CKEditor divs
This way the HTML does not depend on CKEditor, and changing the editor
we use in textareas will require very few changes.
2019-10-25 17:00:18 +02:00
Javi Martín
3012df29e7 Add matcher for CKEditor fields 2019-10-25 15:34:40 +02:00
Javi Martín
71d9ddd849 Apply rule to end files with a newline character 2019-09-10 20:02:15 +02:00
decabeza
cd7bff04b4 Refactors social meta tags spec 2018-10-31 11:51:44 +01:00
rgarcia
dffc5f5eae adds specs 2015-11-23 13:43:48 +01:00
kikito
7c3ca55de1 Adds the default score selector/controller. Refactors debates specs 2015-09-04 11:50:07 +02:00
Marko Lovic
bfeff8d241 Implement custom rspec matcher appear_before 2015-08-27 15:24:59 +02:00