Commit Graph

24 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
f5b60e03e1 Don't let valuators update investments
There were some confusing definitions regarding the valuation of budget
investments.

In the controller, `CommentableActions` was included, which includes the
update action.

In the abilities, a valuator was given permission to update an
investment.

However, the action to update an investment didn't work because there is
no route defined to do so.

The ability was defined so valuators could access the "edit" action,
which will not call the "update" action but the "valuate" action. Since
internally "edit" and "update" use the same permission, it worked.

But then we added permission for regular users to update budget
investments, and these permissions were allowing valuators to update
another user's investment.

After this change, everything seems to work properly since we check
authorization in the controller itself instead of using abilities.
2019-10-18 16:24:27 +02:00
Javi Martín
c6808c9c12 Directly assign valuator groups in specs 2019-09-30 15:20:56 +02:00
Javi Martín
a9159e0ec8 Directly assign valuators in specs
Creating a record and then assigning an association makes the code even
harder to follow.
2019-09-30 15:08:27 +02:00
Javi Martín
aeb1655961 Use budget phase traits
We were already using them in many places, but not everywhere.
2019-09-24 21:34:06 +02:00
Javi Martín
969a4e21c9 Apply RSpec/RepeatedExample rubocop rule 2019-09-10 21:43:39 +02:00
lalo
c2860dda0e Add can_comment and can_edit_dossier abilities to valuators 2019-06-11 16:24:02 +02:00
voodoorai2000
24dde9c35e Delete valuation 2019-05-31 15:43:06 +02:00
Julian Herrero
31ac8b7f55 Change single quotes to double quotes 2019-02-15 11:40:39 +01:00
rgarcia
7a01745188 Add valuation permissions to groups 2018-04-03 20:58:35 +02:00
Bertocq
1ef2789640 Trim valuator investment valuation ability scope
Valuators shouldn't be able to valuate an investment which valuation has
already been finished (only admins can)
2018-03-06 20:18:05 +01:00
Bertocq
3762fd347e Enable RSpec/ScatteredSetup & fix issue
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredSetup
2018-01-07 18:46:58 +01:00
Bertocq
f8fb32db76 Enable RSpec/ScatteredLet cop & fix issue
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/ScatteredLet
2018-01-07 18:46:58 +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
2253155a51 Enables RSpec/EmptyLineAfterSubject & fixes all issues
Read more about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterSubject
2018-01-07 00:50:50 +01:00
Bertocq
fa017b664f Enables RSpec/EmptyLineAfterFinalLet cop & fixes all issues
Read about cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/EmptyLineAfterFinalLet
2018-01-07 00:49:37 +01:00
Bertocq
6ec6f64675 Enable RSpec/DescribeClass rubocop rspec cop & fix issues
Manually fixes all issues & "stashed" false positives at .rubocop_todo.yml

Read about the cop at http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/DescribeClass
2018-01-07 00:20:55 +01:00
kikito
4ceeb68a90 changes abilities extending valuation period 2017-01-04 15:59:36 +01:00
kikito
451179fa59 fixes issues with valuating in specs 2017-01-02 08:22:11 +01:00
Juanjo Bazán
3964988bb1 fixes specs
updates investment to have group_id & budget_id
2016-09-05 13:50:25 +02:00
Juanjo Bazán
b5a6828e41 adds Budget::Group model to group headings
many refactors through budget related models
2016-06-09 18:00:06 +02:00
kikito
13f43d8b67 Adds valuator investment abilities 2016-05-30 13:55:12 +02:00
Juanjo Bazán
decf0f2683 changes admin/valuator permissions
not allowed to create/destroy spending proposals anymore
2016-03-14 14:35:57 +01:00
Juanjo Bazán
8fc302cb46 valuators can manage spending proposals 2016-03-04 20:19:42 +01:00