Add defensive test to display correctly a user's votes

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
This commit is contained in:
rgarcia
2018-03-01 22:52:37 +01:00
parent ce3cb045f8
commit ef30dc1efe

View File

@@ -621,6 +621,30 @@ feature 'Budget Investments' do
expect(order).to_not eq(orderd_by_id)
end
scenario "Set votes for investments randomized with a seed" do
voter = create(:user, :level_two)
login_as(voter)
10.times { create(:budget_investment, heading: heading) }
voted_investments = []
10.times do
investment = create(:budget_investment, heading: heading)
create(:vote, votable: investment, voter: voter)
voted_investments << investment
end
visit budget_investments_path(budget, heading_id: heading.id)
voted_investments.each do |investment|
if page.has_link?(investment.title)
within("#budget_investment_#{investment.id}") do
expect(page).to have_content "You have already supported this investment"
end
end
end
end
def investments_order
all(".budget-investment h3").collect {|i| i.text }
end