Use match_array instead of sorting arrays
It does the same thing, and it's easier to read.
This commit is contained in:
@@ -9,7 +9,7 @@ describe "Paranoid methods" do
|
||||
debate3 = create(:debate)
|
||||
debate4 = create(:debate)
|
||||
|
||||
expect(Debate.all.sort).to eq([debate1, debate2, debate3, debate4].sort)
|
||||
expect(Debate.all).to match_array [debate1, debate2, debate3, debate4]
|
||||
|
||||
Debate.hide_all [debate1, debate2, debate4].map(&:id)
|
||||
|
||||
@@ -30,7 +30,7 @@ describe "Paranoid methods" do
|
||||
|
||||
Debate.restore_all [debate1, debate3].map(&:id)
|
||||
|
||||
expect(Debate.all.sort).to eq([debate1, debate2, debate3].sort)
|
||||
expect(Debate.all).to match_array [debate1, debate2, debate3]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -355,7 +355,7 @@ describe Budget::Investment do
|
||||
|
||||
by_valuator = Budget::Investment.by_valuator(valuator1.id)
|
||||
|
||||
expect(by_valuator.sort).to eq([investment1, investment3].sort)
|
||||
expect(by_valuator).to match_array [investment1, investment3]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -509,7 +509,7 @@ describe Budget::Investment do
|
||||
undecided_investment = create(:budget_investment, :undecided)
|
||||
feasible_investment = create(:budget_investment, :feasible)
|
||||
|
||||
expect(Budget::Investment.not_unfeasible.sort).to eq [undecided_investment, feasible_investment].sort
|
||||
expect(Budget::Investment.not_unfeasible).to match_array [undecided_investment, feasible_investment]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -539,7 +539,7 @@ describe Budget::Investment do
|
||||
unselected_undecided_investment = create(:budget_investment, :unselected, :undecided)
|
||||
unselected_feasible_investment = create(:budget_investment, :unselected, :feasible)
|
||||
|
||||
expect(Budget::Investment.unselected.sort).to eq [unselected_undecided_investment, unselected_feasible_investment].sort
|
||||
expect(Budget::Investment.unselected).to match_array [unselected_undecided_investment, unselected_feasible_investment]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ describe Poll::Ballot do
|
||||
poll_ballot.update(data: [investment.id, investment2.id, investment3.id, investment4.id].join(","))
|
||||
poll_ballot.verify
|
||||
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id).sort).to eq([investment.id, investment2.id, investment3.id].sort)
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id)).to match_array [investment.id, investment2.id, investment3.id]
|
||||
end
|
||||
|
||||
it "adds ballot lines if they are from valid headings" do
|
||||
@@ -34,7 +34,7 @@ describe Poll::Ballot do
|
||||
poll_ballot.update(data: [investment.id, investment2.id, investment3.id, investment4.id].join(","))
|
||||
poll_ballot.verify
|
||||
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id).sort).to eq([investment.id, investment2.id, investment3.id].sort)
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id)).to match_array [investment.id, investment2.id, investment3.id]
|
||||
end
|
||||
|
||||
it "adds ballot lines if they are from selectable" do
|
||||
@@ -45,7 +45,7 @@ describe Poll::Ballot do
|
||||
poll_ballot.update(data: [investment.id, investment2.id, investment3.id, investment4.id].join(","))
|
||||
poll_ballot.verify
|
||||
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id).sort).to eq([investment.id, investment2.id, investment3.id].sort)
|
||||
expect(poll_ballot.ballot.lines.pluck(:investment_id)).to match_array [investment.id, investment2.id, investment3.id]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -580,7 +580,7 @@ describe User do
|
||||
user.take_votes_from other_user
|
||||
|
||||
expect(other_user.votes.count).to eq(0)
|
||||
expect(user.vote_ids.sort).to eq([v1.id, v2.id, v3.id].sort)
|
||||
expect(user.vote_ids).to match_array [v1.id, v2.id, v3.id]
|
||||
end
|
||||
|
||||
it "reassigns budget ballots from other user" do
|
||||
@@ -598,7 +598,7 @@ describe User do
|
||||
user.take_votes_from other_user
|
||||
|
||||
expect(Budget::Ballot.where(user: other_user).count).to eq(0)
|
||||
expect(Budget::Ballot.where(user: user).sort).to eq([b1, b2].sort)
|
||||
expect(Budget::Ballot.where(user: user)).to match_array [b1, b2]
|
||||
end
|
||||
|
||||
it "reassigns poll voters from other user" do
|
||||
@@ -616,7 +616,7 @@ describe User do
|
||||
user.take_votes_from other_user
|
||||
|
||||
expect(Poll::Voter.where(user: other_user).count).to eq(0)
|
||||
expect(Poll::Voter.where(user: user).sort).to eq([v1, v2].sort)
|
||||
expect(Poll::Voter.where(user: user)).to match_array [v1, v2]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user