The group is automatically assigned when we assign the heading. The
budget isn't needed either, except for a special case related to the
reason to be rejected.
Now factories define default headings for investments, so there's no
need to create a group and a heading to create an investment.
Likewise, in order to create a heading it isn't necessary to specify a
group anymore; specifying the budget is enough.
It's possible that there are more similar cases we haven't simplified
yet; I'm only addressing the obvious ones.
The `type: :feature` is automatically detected by RSpec because these
tests are inside the `spec/features` folder. Using `feature` re-adds a
`type: :feature` to these files, which will result in a conflict when we
upgrade to Rails 5.1's system tests.
Because of this change, we also need to change `background` to `before`
or else these tests will fail.
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
Rebase master branch so that this PR can
be updated with the latest changes.
Conflicts has been solved and some specs
updated to fit the new changes. dev_seeds
has been also adapted to the new format.
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
Budget Investment factory creates a secondary budget as a collateral
effect because it has a Heading factory that has a Group factory that
creates a Budget.
This was resulting in problems due to having two "active" Budgets created
and `current_budget` method not choosing the one that we expected
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.
Valuators should not be able to edit a finished valuation (only admins
should).
The valuation form is only shown to the valuator if he has that ability
(we've previously modified app/models/abilities/valuator.rb to be able
to rely on `valuate` over an investment to check that)
If the valuator can't see the form, we present him just the data in
plain text.
Why:
Avoid instance variables as we agreed upon with RSpec/InstanceVariable
How:
Using a let(:invsetment) and replacing all `@investment` with
`investment`, as well as adding a let(:admin) for the administrator.
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