Commit Graph

18 Commits

Author SHA1 Message Date
Javi Martín
a0416d4d85 Fix method description in user segments tests
We generally use "#" to describe instance methods and "." to describe
class methods.
2021-12-20 15:07:25 +01: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
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
fd1325768f Check exact array contents instead of inclusion
We're using `eq` and `match_array` in most places, but there were a few
places where we were still checking each element is included in the
array. This is a bit dangerous, because the array could have duplicate
elements, and we wouldn't detect them with `include`.
2019-09-29 23:57:35 +02:00
Javi Martín
f69a0336a5 Use eq to match arrays with 1 element
It's shorter, and easy to read.
2019-09-29 23:24:53 +02:00
Javi Martín
a04a289850 Simplify testing arrays exact contents
Instead of testing the contents of each element, we can test the whole
array at once.
2019-09-29 23:24:53 +02:00
Javi Martín
ee0031ccb3 Remove isolated data creation useless assignments
While there are other variables in these tests, they're not part of the
setup of the test, and so these ones can be removed while keeping the
code easy to read.
2019-09-25 12:43:44 +02:00
Javi Martín
ffc50246c2 Apply explict RSpec/DescribedClass rubocop rule
We settled on using this style in commit 4cbe81a1, but didn't add the
rule enforcing this style and we didn't apply it to existing code.
2019-09-23 16:51:00 +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
voodoorai2000
338fecc7c7 Use retired trait in specs
This fixes a validation error being raised in these specs, as we were
missing some attributes that are required. Using the factory trait the
missing attributes are correctly filled out.
2019-06-27 09:21:19 +02:00
decabeza
e6af2f15fb Add new user segment all_proposals_authors 2019-05-17 17:22:29 +02:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
Julian Herrero
fc69c21ebb Send newsletter emails in order
The list of emails for sending newsletters will always be ordered by
user creation date, so it will be easier to debug and to know for
which users the email has been sent.
2019-02-06 15:06:29 +01:00
Bertocq
2ecbfc76e0 Add Segment for users without supports on Budget
Created not_supported_on_current_budget at UserSegment along with model
spec scenario and translation strings.
2018-03-15 16:48:54 +01:00
María Checa
7913128520 Changed tests for UserSegments#feasible_and_undecided_investment_authors 2018-02-28 16:54:28 +01:00
Bertocq
61f015e2c2 Add administrators UserSegment
We need a user segment to have only administrators as recipients of both
newsletters and notifications
2018-02-21 23:34:20 +01:00
Bertocq
bdbb32e824 Move newsletter User scope outside UserSegments
Why:

UserSegments are not only used for Newsletters or Email downloads, but
also for internal Global Notifications. We don't want to have that scope
hardcoded inside UserSegments as users that have opted-out from the
newsletter should still be recipients of global notifications.

How:

Removing the scope from the UserSegments `all_users` method that acts as
base for all the other segments. Including that `newsletter` scope only
on the places that is relevant:
* When listing recipients for a newsletter
* When downloading a listing emails that can be newsletter recipients

Also updated relevant tests
2018-02-21 11:45:38 +01:00
María Checa
e8c797766a Added newsletter specs 2018-02-14 16:06:33 +01:00