Commit Graph

10 Commits

Author SHA1 Message Date
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
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
Javi Martín
78c6395e5f Respond with 404 when confirming an invalid token
We were getting a 500 Internal Server Error because `find_by` returned
`nil`, but the code assumed it returned an object responding to
`encrypted_password`. In this case, maybe some other status code (like
400 or 401) might be more appropriate, but I've kept 404 because it was
easier to implement and I wasn't sure which one was better.

Also note ideally we would test the controller using:

expect(response).to have_http_status(:not_found)

However, we would need to configure the test to show exceptions and not
to consider all requests local. I haven't been able to do so for
controller tests, and doing so for feature/request specs seems to
require changes in the test environment configuration which would affect
other tests.
2019-04-10 12:41:21 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Bertocq
3a54713ed0 Fix all Rails/DynamicFindBy rubocop issues 2017-07-10 23:04:27 +02:00
Josep Jaume Rey Peroy
5de3d700e4 Simplify Settings API 2016-01-18 12:43:34 +01:00
Jakub
e4b31cfe29 Move automatic official_level assignment to the controller. 2015-12-01 23:18:23 +01:00
kikito
ac90ea3e4f adds comments to confirmations_controller.rb 2015-10-09 16:27:37 +02:00
kikito
10de596a94 Adds missing parameter for confirmations 2015-10-08 15:19:28 +02:00
kikito
5f74528f12 Modifies devise so that unconfirmed users w/o password can set it when confirming their account 2015-10-07 20:18:54 +02:00