Remove obsolete method to get voted headings
This method isn't used since commit e47cbe2a, where we replaced it with
`headings_voted_within_group`.
This commit is contained in:
@@ -289,10 +289,6 @@ class Budget
|
|||||||
user.headings_voted_within_group(group).count < group.max_votable_headings
|
user.headings_voted_within_group(group).count < group.max_votable_headings
|
||||||
end
|
end
|
||||||
|
|
||||||
def headings_voted_by_user(user)
|
|
||||||
user.votes.for_budget_investments(budget.investments.where(group: group)).votables.map(&:heading_id).uniq
|
|
||||||
end
|
|
||||||
|
|
||||||
def voted_in?(heading, user)
|
def voted_in?(heading, user)
|
||||||
user.headings_voted_within_group(group).where(id: heading.id).exists?
|
user.headings_voted_within_group(group).where(id: heading.id).exists?
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -858,35 +858,6 @@ describe Budget::Investment do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#headings_voted_by_user" do
|
|
||||||
it "returns the headings voted by a user" do
|
|
||||||
user1 = create(:user)
|
|
||||||
user2 = create(:user)
|
|
||||||
|
|
||||||
budget = create(:budget)
|
|
||||||
group = create(:budget_group, budget: budget)
|
|
||||||
|
|
||||||
new_york = create(:budget_heading, group: group)
|
|
||||||
san_franciso = create(:budget_heading, group: group)
|
|
||||||
another_heading = create(:budget_heading, group: group)
|
|
||||||
|
|
||||||
new_york_investment = create(:budget_investment, heading: new_york)
|
|
||||||
san_franciso_investment = create(:budget_investment, heading: san_franciso)
|
|
||||||
another_investment = create(:budget_investment, heading: san_franciso)
|
|
||||||
|
|
||||||
create(:vote, votable: new_york_investment, voter: user1)
|
|
||||||
create(:vote, votable: san_franciso_investment, voter: user1)
|
|
||||||
|
|
||||||
expect(another_investment.headings_voted_by_user(user1)).to include(new_york.id)
|
|
||||||
expect(another_investment.headings_voted_by_user(user1)).to include(san_franciso.id)
|
|
||||||
expect(another_investment.headings_voted_by_user(user1)).not_to include(another_heading.id)
|
|
||||||
|
|
||||||
expect(another_investment.headings_voted_by_user(user2)).not_to include(new_york.id)
|
|
||||||
expect(another_investment.headings_voted_by_user(user2)).not_to include(san_franciso.id)
|
|
||||||
expect(another_investment.headings_voted_by_user(user2)).not_to include(another_heading.id)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "#voted_in?" do
|
describe "#voted_in?" do
|
||||||
|
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
|
|||||||
Reference in New Issue
Block a user