Commit Graph

14525 Commits

Author SHA1 Message Date
Javi Martín
20ca6beb30 Remove unneeded html_safe and raw calls
There's no HTML in these texts, or it has already been escaped by Rails
`link_to` helper method.
2019-10-08 13:20:22 +02:00
Javier Martín
2c80c05372 Merge pull request #3739 from consul/dependabot/bundler/rubocop-0.75.0
Bump rubocop from 0.60.0 to 0.75.0
2019-10-08 13:20:01 +02:00
Javi Martín
19555442da Update Hound's rubocop version
Hound doesn't support version 0.75 yet, so we need to use 0.72.0.
2019-10-08 12:52:11 +02:00
Javi Martín
63d31f47c7 Add missing rubocop dependencies
Rails and performance cops have been extracted to separate gems.

Note in the past we had to add these lines in order to activate Rails
cops:

```
Rails:
  Enabled: true
```

But we didn't do it, and so Rails cops were ignored.

With the new version, it's enough to require `rubocop-rails`.
2019-10-08 12:42:46 +02:00
Javier Martín
4e37ef045e Merge pull request #3750 from consul/obsolete_code
Fix typos in legacy code
2019-10-08 12:28:53 +02:00
Javi Martín
e06bbaed78 Remove unused and add missing Spanish i18n keys
They were accidentally added in commit 9d1ca3bf, missing in that same
commit, or left by accident in commit 78c6f6f7.
2019-10-07 17:26:45 +02:00
Javi Martín
2614253b69 Fix typo in <br> tag
We probably meant `<br>`, `<br />` or `<br/>`, but wrote `</br>`
instead.
2019-10-07 17:26:24 +02:00
Javi Martín
29e8f1ac9f Remove obsolete method
This code isn't used since commit eef8ad1b.
2019-10-07 17:25:11 +02:00
Javier Martín
c3685e748b Merge pull request #3744 from consul/admin_booths_search
Fix booth search with blank text
2019-10-07 15:21:46 +02:00
Javi Martín
710a1d8357 Split Poll::Booth.search in two methods
We use this method in two different scenarios. In an AJAX request, we
don't want to return every booth if the search is blank. However, in a
normal HTTP GET request, we want to return every record when the search
is empty, as we do everywhere else.

It's possible the behaviour of the AJAX call is unusual, since it
searches all booths, and not just the ones assigned to a poll. If we
changed this behaviour, we could simplify the code and remove the
`quick_search` method.
2019-10-07 14:30:39 +02:00
Javi Martín
24e4f4518f Render search field before "no results" message
The same way it's done in other sections.
2019-10-07 14:30:39 +02:00
Javier Martín
056ce1d79b Merge pull request #3746 from consul/active_record_labels
Use active record translations for labels
2019-10-07 02:40:19 +02:00
Javi Martín
bbbd0820c1 Use active record translations in votation types
We need to build a votation type object in the form so translations are
applied automatically.
2019-10-07 01:56:24 +02:00
Javi Martín
9ddbd01f91 Use active model translations for labels
The same way we did for Active Record, but this time we do it for models
not inheriting fom Active Record.
2019-10-07 01:56:24 +02:00
Javi Martín
6fa67b5e53 Use active record translations for labels
This way we can simplify the way we generate form fields. In some cases,
we also use the human attribute in table headers, which IMHO makes
sense.

I haven't moved all of them: for example, sometimes a label is
different depending on whether it's shown to administrators, valuators,
or users. And I haven't touched the ones related to devise, since I
wasn't sure about possible side effects.

Note I've also removed placeholders when they had the same text as their
labels, since they weren't helpful. On the contrary, the added redundant
text to the form, potentially distracting users.
2019-10-07 01:56:23 +02:00
Javi Martín
1bc66925ab Remove redundant labels
We already had translations for these attributes.
2019-10-07 01:55:56 +02:00
Javi Martín
7aae842b38 Fix missing proposal translations 2019-10-06 20:33:55 +02:00
Javier Martín
24ccee0df4 Merge pull request #3745 from consul/auto_labels
Simplify generating form fields with labels
2019-10-06 20:32:50 +02:00
Javi Martín
4f1131d2e5 Add labels to radio buttons automatically 2019-10-06 20:06:00 +02:00
Javi Martín
aec84f6522 Generate labels for attribute automatically
I'm not sure why it isn't already done by foundation's form builder. It
doesn't make any sense to change an ID of a form field without changing
the `for` attribute of its label.
2019-10-06 19:32:04 +02:00
Javi Martín
8d9cb4d8e3 Simplify generating checkboxes in forms
Using the block syntax to generate the label with a <span> tag inside
isn't necessary after upgrading foundation_rails_helpers. Before the
upgrade, we couldn't do so because the <span> tag was escaped.
2019-10-06 19:32:04 +02:00
Javi Martín
5fe56a62f1 Remove useless label false parameter in select_tag
`select_tag` creates just a select with no label, so there's no need to
specify `label: false`.
2019-10-06 19:32:04 +02:00
Javi Martín
4f5de5be3b Add aria-describedby attribute automatically
We were manually adding the attribute in many places, but not
everywhere. I'm assuming adding it where we didn't have it is doing no
harm.
2019-10-06 19:32:03 +02:00
Javi Martín
4a19bb6b77 Simplify generating fields with hints
We were already using this code in translatable forms. Using it on every
form means we can reduce the code we need to generate a field with a
hint.
2019-10-06 18:03:38 +02:00
Javi Martín
ae6fab9f5e Inherit from builder instead of monkey patching it
We were monkey-patching FoundationRailsHelper::Formbuilder, which made
form customization difficult. We can inherit from it, which is the
standard way of extending what an existing class does, and make our form
the default one.
2019-10-05 16:01:58 +02:00
Javi Martín
3ea9f3cecf Simplify generating form fields with labels
Instead of generating the label and then a field without a label, we can
directly generate a field with a label.
2019-10-05 16:01:58 +02:00
Javier Martín
42dbbf5507 Merge pull request #3735 from consul/rubocop_lint
Add rubocop lint rules
2019-10-05 15:50:01 +02:00
Javier Martín
fb2476a651 Merge pull request #3738 from consul/rubocop_fixes
Add rubocop rule for multiline blocks
2019-10-05 15:40:19 +02:00
Javi Martín
871fa020a5 Add and apply ParenthesesAsGroupedExpression rule 2019-10-05 15:03:26 +02:00
Javi Martín
447c970eb3 Remove unused block arguments
There are more cases where we have unused block arguments, but I'm only
changing the obvious ones.
2019-10-05 15:03:26 +02:00
Javi Martín
93a2ebd46f Add and apply DuplicateMethods rubocop rule
These methods were defined with `attr_reader` (or accessor in some
cases) and then they were redefined.
2019-10-05 15:03:26 +02:00
Javi Martín
6ffe563264 Add an apply StringConversionInInterpolation rule 2019-10-05 15:03:26 +02:00
Javi Martín
9c3686a6d8 Remove unused block parameters
We're using `yield` in the method body.
2019-10-05 15:03:25 +02:00
Javier Martín
deba0b1a75 Merge pull request #3741 from consul/extract_vote_message
Extract partials to show "sign in to vote" message
2019-10-05 14:58:54 +02:00
Javi Martín
2fed7b9db3 Add and apply AmbiguousRegexpLiteral rule
This is a very subtle behaviour: `match /attachment/i` could represent a
regular expression, but it could also represent a division like
`match / attachment / i`. So we need to make an exception to the usual
way we omit parenthesis in RSpec expectations.
2019-10-05 14:47:19 +02:00
Javi Martín
d6eb9f8fb6 Add and apply ShadowingOuterLocalVariable rule
Naming two variables the same way is confusing at the very least, and
can lead to hard to debug errors. That's why the Ruby interpreter issues
a warning when we do so.
2019-10-05 14:47:19 +02:00
Javi Martín
70a07c095f Add and apply Style/BlockDelimiters rubocop rule
We were already using it most of the time, but there were a few places
were we used brackets for multiline blocks.
2019-10-05 14:44:14 +02:00
Javi Martín
d42b9ff4a5 Extract method to get valid answers to a question
This way we remove duplication and we avoid a multi-line block in a
validation rule, which made the code hard to read.
2019-10-05 14:34:52 +02:00
Javi Martín
657f8d129c Use class methods for multi-line scopes
Some of our team members don't like using `do...end` for scopes, and
some other team members don't like using `{ ... }` for multi-line
blocks, so we've agreed to use class methods instead.
2019-10-05 14:34:52 +02:00
Javi Martín
21f9d8e1b4 Fix missing double quotes
It could be argued that the following lines use single quotes to escape
double quotes, but on the other hand, using a single quote isn't a
great benefit.
2019-10-05 14:32:46 +02:00
Javi Martín
86a205c8fc Extract link to verify account to a mehtod
We were using the same text and the same route in many places.
2019-10-05 14:20:03 +02:00
Javi Martín
f8bd3d4f39 Extract links to signin and signup to methods 2019-10-05 14:07:24 +02:00
Javi Martín
9289a051c3 Extract partial to show "sign in to vote" message 2019-10-05 14:07:24 +02:00
Javi Martín
f5d8badeb6 Extract partial to show "login to comment" message 2019-10-05 14:07:24 +02:00
Javi Martín
2ccc283bb7 Use the same I18n key for "verify account" text
We were using several different keys, all of them having the same text.
2019-10-05 14:07:24 +02:00
Javi Martín
78c6f6f7e9 Use the same key for "signin" and "signup" texts
We were using the same texts in several places
2019-10-05 14:07:23 +02:00
Javi Martín
ae64458fce Use the same I18n key for "login to comment" text
We were using several different keys, all of them having the same
translations.
2019-10-05 14:07:23 +02:00
Javier Martín
f018706e6b Merge pull request #3740 from consul/remove_obsolete_code
Remove leftover code
2019-10-05 04:11:58 +02:00
cyrillefr
44b2a07878 Moderate legislation proposals (#3602)
Moderate legislation proposals

- added a controller for moderation/legislation
- updated view to appropriate link + added route
- added a spec
- Feature test
- test for faded
- javascripts for visual effects
2019-10-05 04:02:39 +02:00
Javi Martín
27522f60e7 Remove unneeded GET method
Links already use GET by default, so there's no need to specify it.
Furthermore, using `method: :get` makes a link incompatible with
turbolinks.
2019-10-05 03:38:44 +02:00