Show all investments in the map
We were showing only the ones being shown in the current page because
we were modifying `@investments` using a method which used
`@investments`, and we were calling that method twice.
There are many possible solutions: using a local variable to store the
result of the `investments` method, modifying `@investments` after
modifying `@investments_map_coordinates`, ... I've used the one which in
my humble opinion is a bit less fragile: not using `@investments` inside
the `investments` method. That way, the `investments` method will always
return the same result.
Note `stub_const("Budgets::InvestmentsController::PER_PAGE", 2)`
wouldn't work because `Budgets::InvestmentsController` isn't loaded when
that line is executed. So we need to load it. Instead of requiring the
file, using `#{Budgets::InvestmentsController}` seems to be an easier
solution.
This commit is contained in:
@@ -169,11 +169,11 @@ module Budgets
|
||||
|
||||
def investments
|
||||
if @current_order == 'random'
|
||||
@investments.apply_filters_and_search(@budget, params, @current_filter)
|
||||
.send("sort_by_#{@current_order}", params[:random_seed])
|
||||
@budget.investments.apply_filters_and_search(@budget, params, @current_filter)
|
||||
.send("sort_by_#{@current_order}", params[:random_seed])
|
||||
else
|
||||
@investments.apply_filters_and_search(@budget, params, @current_filter)
|
||||
.send("sort_by_#{@current_order}")
|
||||
@budget.investments.apply_filters_and_search(@budget, params, @current_filter)
|
||||
.send("sort_by_#{@current_order}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user