Until we correctly make MapLocation relation with mappables a polymorphic
one... we'll need to return the investment_id and proposal_id values.
Right now it was returning the MapLocation ID, and the JS was making a
call searching for an Investment with the MapLocation ID... sometimes
finding a record with same ID but totally NOT the one associated to the
MapLocation.
The db:dev_seed rake logs info as it progresses as information for the
developer. But that's not needed when ran from its tests file, and it
bloats the travis/rspec output with unnecessary information.
Now the task will always log info unless the rake task receives an
optional argument.
There's no need to check again headers in this scenario, previous one
already does it.
Correctly naming variables, as well as using explicit expectations is a
good idea.
Last but not least, expectations where reversed but by luck or lack of
attention where passing.
The created investment didn't had all data to correctly assert each
column values are correctly exported.
The expectations checking if each particular text appears are invalid in
this test. The objective is to check that the downloaded file contents
are exactly as they should be... not particular parts checked in an
independent way as for example "Yes" could appear in two different
columns and just looking if the text appears is not a valid assertion.
The csv generation doesn't seem like a Model concern, at least not taking
into account the amount of lines of the method (36+). Just a simple ruby
class that encapsulates the logic makes it easier to read and maintain as
we increase the columns exported.. also customize in case other forks need
different values.
There's no good reason to call assigned_valuators(investment) when the
logic can be at the model.
Also removed the valuator_groups texts to be added in an independent
method
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
By using a random seed value smaller than 1, we solve the previous
situation[1] in a simpler way
This test is now obsolete.
It’s hard to write a tests to verify that even with a big seed in
params, we will covert it to a float smaller than 1.
We should refactor these `set_random_seed` methods into a nice model or
controller concern and test it thoroughly
[1]
https://github.com/AyuntamientoMadrid/consul/commit/ba3bf11526fc6ce9c66f
647c414946c61ff945fe
This is a defensive test, just in case we decide to go back to using
`setseed` instead of the `modulus`[1] approach to display investments
in random order
The reason for this test is that `setseed` only ~works in the next
`select` statement. And as when loading a user’s votes for investments
we do a second `select` it does not work as expected 😌
To solve this… we could call `set_random_seed` before loading a user’s
votes for an investment[2]
[1] https://github.com/consul/consul/pull/2131
[2]
https://github.com/AyuntamientoMadrid/consul/blob/master/app/controllers
/budgets/investments_controller.rb#L37
We are trying out a modulus function to return investments in random
order https://github.com/consul/consul/pull/2131
However we ran into the gotcha of having a seed value too big for the
modulus function to work as expected
If the seed is bigger than the investment id, the records are returned
ordered by id
By dividing the seed by a big number, this problem seems to get fixed
Why:
ValuatorGroup name should be unique and present to be able to identify
correctly each of them.
How:
- Adding a presence & uniqueness validation at the model
- Adding a sequenced value for name attribute at its factory
- Adding missing model spec that covers validations
When there are no budgets we were seeing an exception in the budgets’
index
There are two parts to take into account here:
1) Making sure there is a current_budget present, otherwise we display
the “no budgets” message
2) The map helper is called from the controller, so we need to make
sure current_budget is present there too
Note: We could have added a bunch of `try` statements in the budgets’s
index, instead of using a conditional, however there are quite a few
`current_budget` calls so it seems more appropriate to use a conditional