Update investments order when hide_money is active

This commit is contained in:
decabeza
2022-02-03 10:52:17 +01:00
committed by taitus
parent 8c3b222c98
commit 50e00a096b
2 changed files with 11 additions and 1 deletions

View File

@@ -190,7 +190,7 @@ class Budget < ApplicationRecord
when "accepting", "reviewing", "finished"
%w[random]
when "publishing_prices", "balloting", "reviewing_ballots"
%w[random price]
hide_money? ? %w[random] : %w[random price]
else
%w[random confidence_score]
end

View File

@@ -277,6 +277,16 @@ describe Budget do
expect(budget.investments_orders).to eq(["random", "price"])
end
it "is random when ballotting and reviewing ballots if hide money" do
budget.update!(voting_style: "approval", hide_money: true)
budget.phase = "publishing_prices"
expect(budget.investments_orders).to eq(["random"])
budget.phase = "balloting"
expect(budget.investments_orders).to eq(["random"])
budget.phase = "reviewing_ballots"
expect(budget.investments_orders).to eq(["random"])
end
it "is random and confidence_score in all other cases" do
budget.phase = "selecting"
expect(budget.investments_orders).to eq(["random", "confidence_score"])