Commit Graph

103 Commits

Author SHA1 Message Date
taitus
cd7185f317 Create sdg manager 2020-12-16 11:43:15 +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
5ff1162038 Simplify creating follows in specs
While in theory we wouldn't need to use the `transient` nor the
`after(:create)` because there's already a `has_many :through`
association with followers, Factory Bot / ActiveRecord don't
automatically associate the followable, resulting in an invalid record
exception.
2019-09-30 13:34:31 +02:00
Javi Martín
818b442d52 Simplify creating voters in specs 2019-09-30 00:36:40 +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
44ffcfba2c Simplify test for heading names
We were using `to_sentence` to check the order, while it's easier to
just check the exact contents of the array.

Furthermore, using `to_sentence` checked the order of the array, so it
was a potentially flaky spec since the method doesn't specify an order
and PostgreSQL doesn't guarantee the order of the records.
2019-09-29 23:54:11 +02:00
Javi Martín
f27beb1e47 Simplify testing array contents
We were testing for the size and the content of the elements when we
could test for the array itself.
2019-09-24 21:32:52 +02:00
Javi Martín
4301937e85 Check arrays are empty instead of size 0
In ruby we check for `array.empty?` instead of `array.size == 0`, so
it's natural to write the tests in the same way.
2019-09-24 21:32:28 +02:00
Javi Martín
98fe8349d7 Use match_array instead of sorting arrays
It does the same thing, and it's easier to read.
2019-09-24 20:50:49 +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
Javi Martín
dadbf873ba Order translations using ruby
Joining the translations table caused duplicate records to appear.
Ordering with SQL is simply too hard because we need to consider
fallback locales.

Thanks Senén for providing most of the tests in the poll spec.
2019-06-03 18:35:59 +02:00
decabeza
73a0f999ad Add order to voted headings names 2019-02-12 17:19:36 +01:00
decabeza
3471cbb979 Fix hound warnings 2019-02-12 17:19:26 +01:00
Marko Lovic
e47cbe2a10 Extract "supported headings" logic to User method
In preparation to use this method from views where
it doesn't make sense for it to be associated with
a specific investment.
2019-02-12 17:16:29 +01:00
Javier Martín
157cd001d5 Add spec to expose a bug finding manager logged in
I've moved the method to the User model in order to make it easier to
test. I'm not sure where it belongs, though.

There was already a failing spec in `spec/features/management_spec.rb`,
but it passed if run standalone because it only failed if previous tests
had already created nine users or more.
2018-07-28 22:03:33 +02:00
rgarcia
f670019325 Deal gracefully with recommendations of hidden proposals
We were seeing an exceptions in the home page when displaying
recommendations. This was due to trying to load tags of hidden proposals

With this commit we are skipping proposals that that have been hidden,
which will hopefully solve this exception
2018-07-10 17:47:28 +02:00
Bertocq
34bb9d65b1 Enable RSpec/NotToNot cop and fix all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/NotToNot
2018-01-07 17:39:48 +01:00
Bertocq
1441de5107 Enable RSpec/HookArgument cop and fix issues
To be consistent about before/after arguments, as `:each` or `:example`
 are same and default scopes, best not to send an argument in those
 scenarios.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/HookArgument
2018-01-07 02:07:19 +01:00
Bertocq
ed16a78f42 Enables RSpec/ExampleWording and fixes all issues
Both avoiding 'should' and repiting 'it' on the tests description
improves reading them and also makes all descriptions consistent.

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ExampleWording
2018-01-07 01:03:45 +01:00
Bertocq
265d4d0967 Enables RSpec/DescribedClass cop & fixes all issues
Autocorrection for existing issues, and stashing at .rubocop_todo.yml
the false positives

Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribedClass
2018-01-07 00:38:19 +01:00
taitus
9b6b57a24c Remove all white spaces 2017-09-06 14:12:32 +02:00
taitus
dcaa10147a Relocate User model spec to Community model spec. 2017-09-05 12:54:32 +02:00
taitus
4539c5fa00 Refactor and tests. 2017-09-05 12:52:14 +02:00
Bertocq
7d406cae76 Rubocop autocorrections 2017-07-25 13:01:03 +02:00
Senén Rodero Rodríguez
4b2310c135 Move and refactor method from follow to user model to get user interests. Add specification to check the discard of duplicate interests. 2017-07-07 15:18:34 +02:00
Bertocq
2fa92937d2 Fix all Style/BracesAroundHashParameters rubocop issues and remove them from rubocop_todo list 2017-06-28 14:12:51 +02:00
Bertocq
f6fe9cc7d2 Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list 2017-06-26 18:04:20 +02:00
Juanjo Bazán
315c57929a allows managers to create users without email
allows managers to create users without email

hides email preferences from account page for email-less users

prevents email delivery to users with no email

adds spec for user creation from management

adds specs for user's email requirement

adds spec for no deliveries if no email
2017-06-19 13:02:48 +02:00
Juanjo Bazán
dee1b64eb6 fixes typo 2017-02-10 14:48:49 +01:00
Juanjo Bazán
35078848c3 adds methods to take votes from other user (generic & erased) 2017-02-09 20:09:06 +01:00
Juanjo Bazán
ae5ba97f1e adds erased scope to User 2017-02-09 18:43:50 +01:00
Juanjo Bazán
0b2454fb97 adds User#age 2017-01-25 14:17:49 +01:00
Juanjo Bazán
454ae678e6 adds spec for user#poll_officer? 2016-12-27 18:51:38 +01:00
rgarcia
39fd031780 adds specs 2016-12-12 19:11:00 +01:00
kikito
f0b8cfd4a2 Time.now -> Time.current 2016-11-23 19:19:19 +01:00
rgarcia
9d9bf488fc does not create notifications for blocked or erased users 2016-08-02 20:52:20 +02:00
Andrés Pereira
c5e6735caa Change madrid.es to consul.dev - closes #1169 2016-07-14 16:28:16 +02:00
rgarcia
9e910a834b Displays badge for official positions 2016-06-20 21:37:25 +02:00
rgarcia
98040e191e fixes conflicts with fork 2016-06-20 21:33:34 +02:00
rgarcia
28d12fe55b removes sending individual proposal notifications via email 2016-06-15 10:43:02 +02:00
rgarcia
fd67294075 adds option to receive direct messages 2016-06-14 18:20:36 +02:00
rgarcia
9f19a5d143 adds option to receive email digest 2016-06-14 18:08:27 +02:00
rgarcia
ad697cd2c1 adds preference to receive proposal notifications 2016-06-06 12:55:33 +02:00
Juanjo Bazán
d1e50d70d6 managers can login to /management 2016-05-10 19:10:02 +02:00
kikito
d577a2b82e add spec for user identity erasure 2016-04-19 13:33:52 +02:00
rgarcia
08db8a6b17 fixes specs 2016-04-18 20:08:05 +02:00
Raimond Garcia
9aa716ddc1 Merge pull request #930 from morenohe/phone_erase#837
phone_erase#837
2016-03-02 13:55:44 +01:00
morenohe
567420ae35 phone_erase 2016-02-24 10:33:51 +00:00