Commit Graph

14352 Commits

Author SHA1 Message Date
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
Javi Martín
ad14636255 Use Tag instead of ActsAsTaggableOn::Tag
It's shorter, it's easier to extend its behaviour, and it's easier to
integrate with other parts of our application, like translations.
2019-10-05 03:38:44 +02:00
Javi Martín
f444533956 Remove legacy reference to flash[:html_safe]
This code doesn't work since commit a5338a44.
2019-10-05 03:38:44 +02:00
Javi Martín
c6c3ff5423 Remove leftover sandbox code
The rest of the sandbox code was removed in commit d679c1eb.
2019-10-05 03:38:44 +02:00
Javi Martín
21fcdba8c8 Remove obsolete method
This method wasn't used since commit 24dde9c3.
2019-10-05 03:38:44 +02:00
Javier Martín
d193fd9740 Merge pull request #3666 from consul/dependabot/bundler/foundation_rails_helper-3.0.0
Bump foundation_rails_helper from 2.0.0 to 3.0.0
2019-10-05 03:02:51 +02:00
Javi Martín
e524374293 Use new foundation helper classes in tests 2019-10-03 17:30:12 +02:00
dependabot-preview[bot]
26201d4fc2 Bump foundation_rails_helper from 2.0.0 to 3.0.0
Bumps [foundation_rails_helper](https://github.com/sgruhier/foundation_rails_helper) from 2.0.0 to 3.0.0.
- [Release notes](https://github.com/sgruhier/foundation_rails_helper/releases)
- [Changelog](https://github.com/sgruhier/foundation_rails_helper/blob/master/CHANGELOG.md)
- [Commits](https://github.com/sgruhier/foundation_rails_helper/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-03 03:22:21 +00:00
Javier Martín
460d3271b3 Merge pull request #3737 from consul/dependabot/bundler/rubyzip-1.3.0
[Security] Bump rubyzip from 1.2.2 to 1.3.0
2019-10-01 16:30:16 +02:00
dependabot-preview[bot]
235ee0fb83 [Security] Bump rubyzip from 1.2.2 to 1.3.0
Bumps [rubyzip](https://github.com/rubyzip/rubyzip) from 1.2.2 to 1.3.0. **This update includes a security fix.**
- [Release notes](https://github.com/rubyzip/rubyzip/releases)
- [Changelog](https://github.com/rubyzip/rubyzip/blob/master/Changelog.md)
- [Commits](https://github.com/rubyzip/rubyzip/compare/v1.2.2...v1.3.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2019-10-01 13:06:28 +00:00
Javier Martín
fd4e007ada Merge pull request #3597 from consul/original_heading_id
Add original heading id to investments
2019-10-01 14:52:17 +02:00
taitus
11d8bd6a3d Stub the response to an external request 2019-10-01 13:20:09 +02:00
Javier Martín
3bb7c9bc90 Merge pull request #3736 from consul/rspec_instance_variables
Remove instance variables in RSpec
2019-09-30 17:26:49 +02:00
Javier Martín
c6b9bcc80d Merge pull request #3734 from consul/remove_unused_variables
Fix remaining unused variables warnings
2019-09-30 16:43:45 +02:00
Javi Martín
4de4045fcc Allow instance variables in has filter/order specs
These files create a fake class using an instance variable. While the
proper thing to do would be to refactor the `HasOrders` and `HasFilters`
concerns so they didn't use instance variables but methods, I don't
think that's going to happen in the near future.
2019-09-30 16:43:10 +02:00
Javi Martín
2ce3cfab5e Remove @process instance variable
Note we cannot name this variable `process` because in a controller spec
the word `process` is a method, like `get` or `post`.
2019-09-30 16:43:10 +02:00
Javi Martín
a8903d80ce Remove instance variables in draft version spec
This one is a bit different than our usual scenario, since we create
three annotations and we only use two of them in the specs (because we
visit the path to that annotation). So there are probably better options
than the combination of `let!` and `before` I've chosen.
2019-09-30 16:43:10 +02:00
Javi Martín
5c81a70fa7 Use factory bot blocks to create complex data
Having two questions, each of them with two comments, made the code hard
to follow.

Grouping the comments inside the block creating the questions makes it
easier to know which comment belongs to which question, even if the code
is still not 100% readable.

We also remove instance variables, which by the way used the same
variable name for two different things.
2019-09-30 16:43:10 +02:00
Javi Martín
86366da28c Declare local variables outside a block
We couldn't declare them inside the block because they would be
considered local variables and its value would be lost when the block
was finished. So we were using instance variables instead.

However, with instance variables we don't get any warnings when we
misspell their names. We can avoid them by declaring the local variables
before the block starts.
2019-09-30 16:43:10 +02:00
Javi Martín
91c21b0982 Remove instance variables in RSpec
Instance variables might lead to hard-to-detect issues, since using a
nonexistent instance variable will return `nil` instead of raising an
error.
2019-09-30 16:43:10 +02:00
Javi Martín
f70e10fe9f Remove unused instance variables
These variables were declared but never used.
2019-09-30 16:37:34 +02:00
Javier Martín
a43a313da0 Merge pull request #3728 from consul/use_let
Use `let` to remove duplication in specs
2019-09-30 16:18:22 +02:00