Commit Graph

62 Commits

Author SHA1 Message Date
Javi Martín
11832cc07d Make it easier to customize allowed parameters
When customizing CONSUL, one of the most common actions is adding a new
field to a form.

This requires modifying the permitted/allowed parameters. However, in
most cases, the method returning these parameters returned an instance
of `ActionController::Parameters`, so adding more parameters to it
wasn't easy.

So customizing the code required copying the method returning those
parameters and adding the new ones. For example:

```
def something_params
  params.require(:something).permit(
    :one_consul_attribute,
    :another_consul_attribute,
    :my_custom_attribute
  )
end
```

This meant that, if the `something_params` method changed in CONSUL, the
customization of this method had to be updated as well.

So we're extracting the logic returning the parameters to a method which
returns an array. Now this code can be customized without copying the
original method:

```
alias_method :consul_allowed_params, :allowed_params

def allowed_params
  consul_allowed_params + [:my_custom_attribute]
end
```
2022-04-07 19:35:40 +02:00
Javi Martín
65c9786db7 Apply Layout/RedundantLineBreak rule to short lines
We're not adding the rule because it would apply the current line length
rule of 110 characters per line. We still haven't decided whether we'll
keep that rule or make lines shorter so they're easier to read,
particularly when vertically splitting the editor window.

So, for now, I'm applying the rule to lines which are about 90
characters long.
2021-09-03 11:49:53 +02:00
Javi Martín
57d8a59d10 Add an apply Style/RaiseArgs rubocop rule
We were already applying it most of the time.
2021-08-09 17:32:46 +02:00
Javi Martín
f2cdc31786 Use ActiveRecord::Relation#count with a block
This method used to ignore the block but in Rails 5.1 it uses
Enumerable#count.

See https://github.com/rails/rails/pull/24203/commits/58772397
2020-04-27 19:26:37 +02:00
Javi Martín
eafb4018bf Apply Style/CollectionMethods rubocop rule
We were already using `map` and `reduce` almost everywhere.
2019-10-26 13:03:49 +02:00
Javi Martín
d938077813 Remove empty lines around if and when body
Unfortunately, there doesn't seem to be a Rubocop rule for this one.
I've found these empty lines thanks to Rufo.
2019-10-24 17:56:03 +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
4e72d9f3b7 Remove useless assignments to return values 2019-09-25 12:43:44 +02:00
Javi Martín
9fe8c47528 Apply Rails/SafeNavigation rubocop rule 2019-09-10 21:43:39 +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
b5b07bccd3 Apply PercentLiteralDelimiters rubocop rule 2019-09-10 20:02:15 +02:00
Javier Martín
b14661e378 Merge pull request #3581 from consul/duplicate_translations
Avoid duplicate records using translations
2019-06-06 13:08:05 +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
Julian Herrero
b122302c58 Use find instead of find_by_id
Better raise a 404 HTML NotFound exception than any other unexpected error.
2019-06-03 17:54:19 +02:00
rgarcia
998b4d9e39 Load budgets using slugs 2019-06-03 16:54:39 +02:00
voodoorai2000
24dde9c35e Delete valuation 2019-05-31 15:43:06 +02:00
rgarcia
f23fd6f3bb Remove parameterise deprecation warning
DEPRECATION WARNING: Passing the separator argument as a positional
parameter is deprecated and will soon be removed. Use `separator: '_'`
instead.
2019-04-17 17:40:55 +02:00
alejandro
bafab3b769 fixes some deprecation warnings 2019-04-17 17:40:52 +02:00
Julian Herrero
d24376f6ad Use double quotes in controllers/ 2019-03-13 22:19:49 +01:00
Julian Herrero
922600252c Make budget headings translatable 2019-02-13 13:35:07 +01:00
Javi Martín
b0f1b6245e Simplify scope usage
Rails automatically calls the `id` method inside scopes and the variable
name makes more sense if it represents investments instead of the number
of investments.
2018-12-21 17:17:35 +01:00
Javi Martín
10e8117f83 Remove unnecessary line
We were assigning the same variable twice in a row, making the first
assignment useless.
2018-12-21 17:08:27 +01:00
Bertocq
3e75bd4dfd Fix Valuation Investment index heading filters
Why:

Heading filter where not being correctly displayed

How:

Increasing scenario to cover all possible combinations, and fixing the
heading_filters method of the Valuation Budget Investment Controller to
correctly:
  * Find how many investments the valuator can access
  * Count investments for each heading
2018-06-27 14:30:09 +02:00
iagirre
b8cc10d218 Fix conflics after rebase 2018-04-09 15:02:35 +02:00
Bertocq
09fb4701b8 Fix Valuation Investment index heading filters
Why:

Heading filter where not being correctly displayed

How:

Increasing scenario to cover all possible combinations, and fixing the
heading_filters method of the Valuation Budget Investment Controller to
correctly:
  * Find how many investments the valuator can access
  * Count investments for each heading
2018-04-06 00:42:36 +02:00
Bertocq
8fd6f8f1d6 Valuators access to edit/valute on right phase
When a valuator tries to edit/valuate an investment outside valuating
phase, an explanatory message will be shown along with a redirect to
prevent access.
2018-03-12 20:22:53 +01:00
BertoCQ
05a6406189 Merge branch 'master' into remove_investments_internal_comments 2018-01-31 13:47:15 +01:00
Bertocq
dff966d9b3 Show valuation comment thread @ Valuation show/edit
Why:

Budget Investment's valuators should be able to see internal valuation
comments thread at both show and edit views.

How:

At Valuation::BudgetInvestmentsController:
* Include CommentableActions to gain access to the entire feature, with
required resource_model & resource_name methods.
* Add the only possible order (oldest to newest)
* Load comments on both show & edit actions, passing `valuations` flag
to the CommentTree in order to only list those.

At CommentTree:
* Use `valuations` flag as instance variable to decide wich
comment threat to load: valuations (if relation exists) or comments.
2018-01-31 01:53:33 +01:00
Bertocq
d280c254c8 Remove usage of Investment's internal_comments attr 2018-01-29 21:15:28 +01:00
Bertocq
6d3359dbbc Fix bad line break 2018-01-26 12:01:22 +01:00
Bertocq
070c94494e Fix linelenght over 100 on multiple files 2018-01-26 00:27:03 +01:00
rgarcia
eca971a648 Use current_budget instead of Budget.current 2018-01-16 19:34:21 +01:00
rgarcia
5086314bee Display only current budget for Valuators
Before we could have multiple current budgets, as we now only have one
current_budget, some specs broke.

As there is no need to display multiple budgets to Valuators, only the
current budget is necessary, we can remove arrays and assume that only
a single budget, the current budget, is displayed to Valuators
2018-01-15 22:02:04 +01:00
Bertocq
3a94fe4cc2 Fix indentation on if-else assignement 2017-07-10 16:03:31 +02:00
Bertocq
69f4e1c683 Fix all rubocop Metrics/LineLength issues (140+) 2017-07-10 13:22:49 +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
02524b164a Rubocop autocorrections (indentations, revers unless to if, extra spaces) 2017-06-08 12:14:35 +02:00
Juanjo Bazán
c86cdb5d9b logs valuators activity 2017-03-27 13:56:55 +02:00
rgarcia
68bf119c18 sends unfeasible budget investment 2017-01-14 17:02:33 +01:00
kikito
b7a0aa3b57 Fixes i18n errors now that they are detected by i18n-tasks 2017-01-06 19:55:23 +01:00
kikito
635de83f86 prints the right value in budgets table 2017-01-04 18:48:01 +01:00
kikito
9c66fa0dc8 removes filter from valuation index page 2017-01-04 16:31:16 +01:00
kikito
5b56336941 Fixes valuation features 2016-12-13 15:51:58 +01:00
kikito
2a2179d0f3 Merge branch 'master' into budget 2016-11-28 11:41:49 +01:00
rgarcia
bb3c4c6399 adds consistency to ruby code style
Keep a blank line before and after private
Keep a blank line before and after protected
Remove extra empty line at class body end
Remove extra blank line
Add final newline
Use 2 (not 3) spaces for indentation
Use 2 (not 4) spaces for indentation
Remove space before comma
Add space after comma
Remove trailing whitespaces
Remove unnecessary spacing
Use snake_case for variable names
Do not use then for multi-line if
Remove unused block argument - i
Use the new Ruby 1.9 hash syntax
Remove unused assignment to variable
Indent when as deep as case
Align attributes
Align end with def
2016-11-15 11:18:43 +01:00
Juanjo Bazán
42c705e1e3 adds dossier editing of investments to valuation 2016-09-09 15:09:06 +02:00
Juanjo Bazán
0fc31b1259 adds budget/budget_investment indexes to valuators 2016-09-09 13:39:08 +02:00
Juanjo Bazán
3087b2dac9 changes default order in valuation/sps to votes up 2016-04-11 16:12:03 +02:00
kikito
3e8150ceae hides the not-pending sps in valuation 2016-04-07 12:16:11 +02:00