Commit Graph

16 Commits

Author SHA1 Message Date
Javi Martín
f8c97b9bb9 Remove monkey-patch of the Numeric class
This monkey-patch doesn't seem to be working with Zeitwerk, and we were
only using it in one place, so the easiest way to solve the problem is
to remove it.

Note that, in the process, we're changing the operation so `* 100`
appears before the division, so it's consistent with other places where
we do similar things (like the `supports_percentage` method in the
proposals helper).
2024-04-11 19:08:01 +02:00
Javi Martín
86ad2df46d Unify code in debates/legislation vote links
We were using the same code to render links to agree and disagree, so we
can extract a new component for this code.

We're also adding component tests to make it easier to test whether
we're breaking anything while refactoring, although the code is probably
already covered by system tests.

Since the votes mixin was only used in one place, we're removing it and
moving most of its code to a new CSS file for the shared component.
2022-02-21 18:47:13 +01:00
Javi Martín
b98244afd9 Remove votes query optimizations
Just like we did in commit 0214184b2d for investments, we're removing
some possible optimizations (we don't have any benchmarks proving they
affect performance at all) in order to simplify the code.

The investement votes component `delegate` code was accidentally left
but isn't used since commit 0214184b2, so we're removing it now that
we're removing the `voted_for?` helper method.
2022-02-21 18:47:13 +01:00
Javi Martín
66759d2dc0 Apply StringConcatenation rule in some places
This rule was added in Rubocop 0.89.0. However, there are some false
positives when we don't use interpolation but simply concatenate in
order to avoid long lines. Even if there weren't false positives, there
are places where we concatenate to emphasize the point that we're adding
a certain character to a text.

We might reconsider this rule in the future, since we generally prefer
interpolation over concatenation.
2020-10-23 12:01:39 +02:00
Javi Martín
d0d681a44b Add and apply EmptyLineAfterGuardClause rule
We were inconsistent on this one. I consider it particularly useful when
a method starts with a `return` statement.

In other cases, we probably shouldn't have a guard rule in the middle of
a method in any case, but that's a different refactoring.
2019-10-24 17:56:03 +02:00
Javi Martín
db97f9d08c Add and apply rubocop rules for empty lines
We were very inconsistent regarding these rules.

Personally I prefer no empty lines around blocks, clases, etc... as
recommended by the Ruby style guide [1], and they're the default values
in rubocop, so those are the settings I'm applying.

The exception is the `private` access modifier, since we were leaving
empty lines around it most of the time. That's the default rubocop rule
as well. Personally I don't have a strong preference about this one.


[1] https://rubystyle.guide/#empty-lines-around-bodies
2019-10-24 17:11:47 +02:00
Javi Martín
f9ed186909 Add rubocop spacing rules
We were following these rules in most places; we just didn't define them
anywhere.
2019-09-10 21:04:56 +02:00
Julian Herrero
b460c024f3 Use double quotes in app/helpers 2019-03-15 09:26:49 +01:00
Juanjo Bazán
94ccae91a4 refactors helper method 2015-09-15 14:59:07 +02:00
Juanjo Bazán
26da253a5d moves helper method to votes helper and adds spec 2015-09-15 14:44:12 +02:00
rgarcia
b5de9830ec fixes specs 2015-09-14 21:25:05 +02:00
rgarcia
eea3b0922e adds already supported proposals 2015-09-14 21:21:34 +02:00
rgarcia
ad8880d02c adds proposal votes 2015-09-13 21:56:52 +02:00
rgarcia
f2b917d486 adds proposal show 2015-09-12 12:30:20 +02:00
kikito
9a071d2ed7 Renames @voted_values to @debate_votes in controllers 2015-09-01 13:07:03 +02:00
Juanjo Bazán
37199125fa refactors votes view code to helper 2015-08-07 09:19:02 +02:00