From 7ee9c0d04231bd3315e1689ba42251b7360be2a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 26 Sep 2019 13:56:27 +0200 Subject: [PATCH] Remove obsolete method to get voted headings This method isn't used since commit e47cbe2a, where we replaced it with `headings_voted_within_group`. --- app/models/budget/investment.rb | 4 ---- spec/models/budget/investment_spec.rb | 29 --------------------------- 2 files changed, 33 deletions(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index c80b060fa..3fdef6286 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -289,10 +289,6 @@ class Budget user.headings_voted_within_group(group).count < group.max_votable_headings 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) user.headings_voted_within_group(group).where(id: heading.id).exists? end diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 863daa426..29ec5876b 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -858,35 +858,6 @@ describe Budget::Investment do 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 let(:user) { create(:user) }