Commit Graph

41 Commits

Author SHA1 Message Date
Javi Martín
3b7948a139 Use a date field to select the date of birth
The default `date_select` used in fields presents an accessibility
issue, because in generates three select controls but only one label.
That means that there are two controls without a label.

So we're using a date field instead. This type is field is supported by
about 99% of the browsers, and we've already got JavaScript code
converting this field to a jQuery UI datepicker in case the browser
doesn't support date fields.

Note that, since we no longer need to parse the three date fields into
one, we can simplify the code in both the models and the tests.

Another slight improvement is that, previously, we couldn't restrict the
month and day controls in order to set the minimum date, so the maximum
selectable date was always the 31st of December of the year set by the
minimum age setting. As seen in the component test, now that we use only
one field, we can set a specific date as the maximum one.
2024-11-12 15:15:34 +01: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
Javi Martín
5b6de96241 Add and apply MultilineMethodCallIndentation rule 2023-08-18 14:56:16 +02:00
Javi Martín
629e208e9d Add and apply ArgumentAlignment rubocop rule
We're choosing the default `with_first_argument` style because it's the
one we use the most.
2023-08-18 14:56:16 +02:00
Javi Martín
8b13daad95 Add and apply rules for multi-line hashes
For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
2023-08-18 14:56:16 +02:00
Javi Martín
09c63e354c Add and apply Layout/DotPosition rule
Since IRB has improved its support for multiline, the main argument
towars using a trailing dot no longer affects most people.

It still affects me, though, since I use Pry :), but I agree
leading dots are more readable, so I'm enabling the rule anyway.
2023-08-18 14:56:16 +02:00
Javi Martín
8ae138aa19 Add and apply Rails/WhereNot rubocop rule
We simplify the code a little bit, and make it more consistent since we
were already using `where.not` in most places.
2021-08-09 23:52:47 +02:00
Javi Martín
02ecdf6acc Add and apply Style/AccessorGrouping rubocop rule
This rule was added in Rubocop 0.87.0. We were already grouping
accessors in most places.
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
93c6347b45 Apply Rails/FindBy rubocop rule
We were already using it in most places.
2019-10-23 18:29:09 +02:00
Javi Martín
7ca55c44e0 Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.

There are a few methods I've kept the same way they were.

The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.

We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").

Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.

There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.

For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
2019-10-23 14:39:31 +02:00
Javi Martín
431074c99f Add save! method to ActiveModel models
This way we make it clear we expect records to be valid when we save
them, just like we do with ActiveRecord models.
2019-10-23 14:32:42 +02:00
taitus
6e62ea81a9 Add new model presence validates
- Only validate :date_of_birth and :postal_code presence when the
  application has configured Remote Census and their alias fields
  has values.
2019-07-29 13:10:09 +02:00
taitus
c0c967b961 Create Management::Document initialize
Allow parse :date_of_birth on Management::Document initialize
2019-07-29 13:10:09 +02:00
taitus
bc36c5a987 Allow to Management::Document works with CustomCensusAPI
- Allow receive new fields :date_of_birth and :postal_code
- Send new fields to CensusCaller call method to allow use
  on RemoteCensusAPI
2019-07-29 13:10:09 +02:00
taitus
a382f7c301 Update all CensusCaller calls with new arguments. 2019-07-29 13:10:09 +02:00
Julian Herrero
3ba961a2d7 Use double quotes in models 2019-03-14 17:25:43 +01:00
María Checa
d576fd5951 Merge branch 'master' into 1725-census_local_copy_user_verification 2017-07-14 15:50:26 +02:00
María Checa
089c690b49 Created new entry point CensusCaller
Here's a better alternative than the first one. Added a new abstraction level from which are performed both types of census calls, while the logic of those is managed in their own library.
2017-07-10 12:22:30 +02:00
Bertocq
97d7a21791 Fix all Style/RedundantReturn rubocop issues 2017-07-05 11:55:52 +02:00
kikito
386a5aa941 Fixes typos 2017-02-03 16:08:58 +01:00
kikito
ba87eaa47c Moves Age calculation to a module instead of monkeypatching Date 2017-02-03 15:35:41 +01:00
kikito
95f80651b1 uses Date#age_in_years when calculating ages 2017-02-03 12:56:40 +01:00
Juanjo Bazán
e2118f701b removes hardcoded age, favours setting 2017-01-09 16:05:27 +01:00
rgarcia
b12c8d3a5d validates document uniqueness only for active accounts 2016-12-12 19:11:00 +01:00
kikito
f0b8cfd4a2 Time.now -> Time.current 2016-11-23 19:19:19 +01:00
kikito
3a5928e83f aligns document verification with Madrid 2016-04-13 12:06:43 +02:00
kikito
3880ef9e24 aligns document verification with census API 2016-04-12 18:35:23 +02:00
Juanjo Bazán
07117f4a49 includes all date in document age verification 2015-10-19 12:18:42 +02:00
rgarcia
0a668ae39a checks valid age 2015-10-19 11:20:32 +02:00
kikito
050971c459 modifies email controllers: management email makes users level two verified, and sets their document number permanently. Fixes failing test 2015-10-13 17:20:39 +02:00
rgarcia
c07bf7e212 removes unnecessary attr_accessor 2015-10-12 14:12:03 +02:00
rgarcia
f55c3974aa refactors managed user info into management layout 2015-10-12 14:05:06 +02:00
kikito
99bb082555 refactors management/validations/email validations 2015-10-09 13:47:25 +02:00
kikito
131982c8e9 Moves translations from one namespace to another 2015-10-07 19:43:34 +02:00
kikito
d5d5e683d1 Refactors account_info partial 2015-10-07 19:39:59 +02:00
kikito
3ed5c269e4 Adds unconfirmed_document_number into email verifications
It also makes sure that when a user is considered level 3 is also
considered residence-verified.
2015-10-02 18:44:15 +02:00
kikito
9e05a3283c Includes the document number and type in the verification email 2015-10-02 18:40:24 +02:00
kikito
75721ab186 Implements Verification::Management::Email#save + refactors 2015-10-02 13:20:44 +02:00
kikito
1fe850b6dc Renaming of management validations 2015-10-01 19:27:04 +02:00