diff --git a/app/assets/javascripts/forms.js.coffee b/app/assets/javascripts/forms.js.coffee
index fab812400..edf4c525f 100644
--- a/app/assets/javascripts/forms.js.coffee
+++ b/app/assets/javascripts/forms.js.coffee
@@ -15,6 +15,11 @@ App.Forms =
toggleLink: ->
$('.js-toggle-link').unbind('click').on('click', ->
$($(this).data('toggle-selector')).toggle("down")
+ if $(this).data('toggle-text') isnt undefined
+ toggle_txt = $(this).text()
+ $(this).text( $(this).data('toggle-text') )
+ $(this).data('toggle-text', toggle_txt)
+
false
)
@@ -22,4 +27,4 @@ App.Forms =
App.Forms.disableEnter()
App.Forms.submitOnChange()
App.Forms.toggleLink()
- false
\ No newline at end of file
+ false
diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb
index 743faa166..8a7f33c3c 100644
--- a/app/controllers/admin/budget_investments_controller.rb
+++ b/app/controllers/admin/budget_investments_controller.rb
@@ -51,7 +51,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
def budget_investment_params
params.require(:budget_investment)
- .permit(:title, :description, :external_url, :heading_id, :administrator_id, :valuation_tag_list, valuator_ids: [])
+ .permit(:title, :description, :external_url, :heading_id, :administrator_id, :valuation_tag_list, :incompatible, valuator_ids: [])
end
def load_budget
diff --git a/app/controllers/budgets/results_controller.rb b/app/controllers/budgets/results_controller.rb
index d92232f67..8da1e9ef7 100644
--- a/app/controllers/budgets/results_controller.rb
+++ b/app/controllers/budgets/results_controller.rb
@@ -5,7 +5,8 @@ module Budgets
def show
authorize! :read_results, @budget
- @result = load_result
+ @investments = load_result.investments
+ @heading = heading
end
private
@@ -19,4 +20,4 @@ module Budgets
end
end
-end
\ No newline at end of file
+end
diff --git a/app/controllers/legislation/processes_controller.rb b/app/controllers/legislation/processes_controller.rb
index 002b5ea65..588ffdf9e 100644
--- a/app/controllers/legislation/processes_controller.rb
+++ b/app/controllers/legislation/processes_controller.rb
@@ -83,7 +83,12 @@ class Legislation::ProcessesController < Legislation::BaseController
private
+ def member_method?
+ params[:id].present?
+ end
+
def set_process
+ return if member_method?
@process = ::Legislation::Process.find(params[:process_id])
end
end
diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb
index 0d9c738b9..845d695bb 100644
--- a/app/models/budget/investment.rb
+++ b/app/models/budget/investment.rb
@@ -50,7 +50,9 @@ class Budget
scope :undecided, -> { where(feasibility: "undecided") }
scope :with_supports, -> { where('cached_votes_up > 0') }
scope :selected, -> { feasible.where(selected: true) }
- scope :winners, -> { selected.where(winner: true) }
+ scope :compatible, -> { where(incompatible: false) }
+ scope :incompatible, -> { where(incompatible: true) }
+ scope :winners, -> { selected.compatible.where(winner: true) }
scope :unselected, -> { not_unfeasible.where(selected: false) }
scope :last_week, -> { where("created_at >= ?", 7.days.ago)}
@@ -63,6 +65,7 @@ class Budget
scope :for_render, -> { includes(:heading) }
before_save :calculate_confidence_score
+ after_save :recalculate_heading_winners if :incompatible_changed?
before_validation :set_responsible_name
before_validation :set_denormalized_ids
@@ -200,6 +203,10 @@ class Budget
self.confidence_score = ScoreCalculator.confidence_score(total_votes, total_votes)
end
+ def recalculate_heading_winners
+ Budget::Result.new(budget, heading).calculate_winners if incompatible_changed? && winner? && incompatible?
+ end
+
def set_responsible_name
self.responsible_name = author.try(:document_number) if author.try(:document_number).present?
end
diff --git a/app/models/budget/result.rb b/app/models/budget/result.rb
index f835bce0c..aa6c4c7ac 100644
--- a/app/models/budget/result.rb
+++ b/app/models/budget/result.rb
@@ -10,7 +10,7 @@ class Budget
def calculate_winners
reset_winners
- investments.each do |investment|
+ investments.compatible.each do |investment|
@current_investment = investment
set_winner if inside_budget?
end
diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb
index 0c56e579c..fca3560a4 100644
--- a/app/views/admin/budget_investments/_investments.html.erb
+++ b/app/views/admin/budget_investments/_investments.html.erb
@@ -12,7 +12,9 @@
<%= t("admin.budget_investments.index.table_feasibility") %> |
<%= t("admin.budget_investments.index.table_valuation_finished") %> |
<%= t("admin.budget_investments.index.table_selection") %> |
- <%= t("admin.budget_investments.index.table_winner") %> |
+ <% if params[:filter] == 'selected' %>
+ <%= t("admin.budget_investments.index.table_incompatible") %> |
+ <% end %>
@@ -75,9 +77,11 @@
<% end %>
<% end %>
-
- <%= investment.winner? ? t('shared.yes'): t('shared.no') %>
- |
+ <% if params[:filter] == 'selected' %>
+
+ <%= investment.incompatible? ? t('shared.yes'): t('shared.no') %>
+ |
+ <% end %>
<% end %>
diff --git a/app/views/admin/budget_investments/edit.html.erb b/app/views/admin/budget_investments/edit.html.erb
index 17dd88665..0e9b6afc9 100644
--- a/app/views/admin/budget_investments/edit.html.erb
+++ b/app/views/admin/budget_investments/edit.html.erb
@@ -61,9 +61,20 @@
-
+
<%= t("admin.budget_investments.edit.compatibility") %>
+
+
+
+ <%= f.label :incompatible do %>
+ <%= f.check_box :incompatible, title: t('admin.budget_investments.edit.compatibility'), label: false %>
+ <%= t("admin.budget_investments.edit.mark_as_incompatible") %>
+ <% end %>
+
+
+
+
<%= f.submit(class: "button", value: t("admin.budget_investments.edit.submit_button")) %>
-
+
<% end %>
diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb
index f220c0955..95fc6c76a 100644
--- a/app/views/admin/budget_investments/show.html.erb
+++ b/app/views/admin/budget_investments/show.html.erb
@@ -56,3 +56,8 @@
<%= link_to t("admin.budget_investments.show.new_milestone"), new_admin_budget_budget_investment_budget_investment_milestone_path(@budget, @investment) %>
+
+<%= t("admin.budget_investments.show.compatibility.title") %>
+
+ <%= t("admin.budget_investments.show.compatibility.#{@investment.incompatible?}") %>
+
diff --git a/app/views/budgets/results/_results_table.html.erb b/app/views/budgets/results/_results_table.html.erb
index 9c40a1d22..993060562 100644
--- a/app/views/budgets/results/_results_table.html.erb
+++ b/app/views/budgets/results/_results_table.html.erb
@@ -1,14 +1,10 @@
-
+
+
- <%= heading.name %>
+ <%= title %>
- <%= link_to t("budgets.results.show_all_link"), "#",
- class: "js-toggle-link button hollow margin-bottom float-right",
- data: {'toggle-selector' => '.js-discarded',
- 'toggle-text' => t("budgets.results.hide_discarded_link")} %>
-
-
+
|
@@ -20,23 +16,19 @@
|
<%= t("budgets.results.price") %>
|
-
- <%= format_price(heading.price) %>
- <%= t("budgets.results.amount_available") %>
- |
+ <% if results_type == :compatible %>
+
+ <%= format_price(heading_price) %>
+ <%= t("budgets.results.amount_available") %>
+ |
+ <% end %>
- <% amount_available = heading.price %>
- <% @result.investments.each do |investment| %>
- <% if investment.winner? %>
-
- <% else %>
-
- <% end %>
+ <% amount_available = heading_price %>
+ <% investments.each do |investment| %>
+
|
<% if investment.winner? %>
@@ -51,8 +43,7 @@
<% end %>
- <%= link_to investment.title,
- budget_investment_path(@budget, investment) %>
+ <%= link_to investment.title, budget_investment_path(@budget, investment) %>
|
<%= investment.ballot_lines_count %>
@@ -60,11 +51,13 @@
|
<%= format_price investment.price %>
|
-
- <%= format_price amount_available - investment.price %>
- <% amount_available -= investment.price if investment.winner? %>
- |
+ <% if results_type == :compatible %>
+
+ <%= format_price amount_available - investment.price %>
+ <% amount_available -= investment.price if investment.winner? %>
+ |
+ <% end %>
<% end %>
diff --git a/app/views/budgets/results/show.html.erb b/app/views/budgets/results/show.html.erb
index d9253b785..2343e652c 100644
--- a/app/views/budgets/results/show.html.erb
+++ b/app/views/budgets/results/show.html.erb
@@ -1,6 +1,6 @@
<% provide :title, t("budgets.results.page_title", budget: @budget.name) %>
<% content_for :canonical do %>
- <%= render "shared/canonical", href: budget_results_url(@budget, heading_id: @result.heading) %>
+ <%= render "shared/canonical", href: budget_results_url(@budget, heading_id: @heading) %>
<% end %>
@@ -34,5 +34,16 @@
- <%= render 'results_table', heading: @result.heading %>
+ <%= link_to t("budgets.results.hide_discarded_link"), "#", class: "js-toggle-link button hollow margin-bottom", data: {'toggle-selector' => '.js-discarded', 'toggle-text' => t("budgets.results.show_all_link")} %>
+
+
+ <%= render 'results_table', results_type: :compatible,
+ title: @heading.name,
+ heading_price: @heading.price,
+ investments: @investments.compatible %>
+
+ <%= render 'results_table', results_type: :incompatible,
+ title: t("budgets.results.incompatibles"),
+ heading_price: @heading.price,
+ investments: @investments.incompatible %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index a8f65815f..999689492 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -120,6 +120,7 @@ en:
valuation_finished: Valuation finished
valuation_finished_feasible: Val. fin. Feasible
selected: Selected
+ winners: Winners
all: All
title: Investment projects
assigned_admin: Assigned administrator
@@ -140,7 +141,7 @@ en:
table_feasibility: "Feasibility"
table_valuation_finished: "Val. Fin."
table_selection: "Selection"
- table_winner: "Winner"
+ table_incompatible: "Incompatible"
show:
assigned_admin: Assigned administrator
assigned_valuators: Assigned valuators
@@ -158,8 +159,14 @@ en:
undefined: Undefined
milestone: Milestone
new_milestone: Create new milestone
+ compatibility:
+ title: Compatibility
+ "true": Incompatible
+ "false": Compatible
edit:
classification: Clasification
+ compatibility: Compatibility
+ mark_as_incompatible: Mark this investement project as incompatible
assigned_valuators: Valuators
select_heading: Select heading
submit_button: Update
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index d25bd2249..c77a95062 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -120,6 +120,7 @@ es:
valuation_finished: Evaluación finalizada
valuation_finished_feasible: Viables
selected: Seleccionadas
+ winners: Ganadoras
all: Todas
title: Propuestas de inversión
assigned_admin: Administrador asignado
@@ -140,7 +141,7 @@ es:
table_feasibility: "Viabilidad"
table_valuation_finished: "Ev. Fin."
table_selection: "Selección"
- table_winner: "Ganadora"
+ table_incompatible: "Incompatible"
show:
assigned_admin: Administrador asignado
assigned_valuators: Evaluadores asignados
@@ -158,8 +159,14 @@ es:
undefined: Sin definir
milestone: Seguimiento
new_milestone: Crear nuevo hito
+ compatibility:
+ title: Compatibilidad
+ "true": Incompatible
+ "false": Compatible
edit:
classification: Clasificación
+ compatibility: Compatibilidad
+ mark_as_incompatible: Marcar esta propuesta de inversión como incompatible
assigned_valuators: Evaluadores
select_heading: Seleccionar partida
submit_button: Actualizar
diff --git a/config/locales/admin.fr.yml b/config/locales/admin.fr.yml
index cba150184..0044a276f 100644
--- a/config/locales/admin.fr.yml
+++ b/config/locales/admin.fr.yml
@@ -140,7 +140,7 @@ fr:
table_feasibility: "Faisabilité"
table_valuation_finished: "Ev. Ter."
table_selection: "Sélection"
- table_winner: "Winner"
+ table_incompatible: "Incompatible"
show:
assigned_admin: Administrateur assigné
assigned_valuators: Évaluateur assigné
diff --git a/config/locales/admin.nl.yml b/config/locales/admin.nl.yml
index d831a8723..a359aebbe 100755
--- a/config/locales/admin.nl.yml
+++ b/config/locales/admin.nl.yml
@@ -140,7 +140,7 @@ nl:
table_feasibility: "Feasibility"
table_valuation_finished: "Val. Fin."
table_selection: "Selection"
- table_winner: "Winner"
+ table_incompatible: "Incompatible"
show:
assigned_admin: Assigned administrator
assigned_valuators: Assigned valuators
diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml
index 75a56c919..33ef8bb80 100644
--- a/config/locales/budgets.en.yml
+++ b/config/locales/budgets.en.yml
@@ -136,3 +136,4 @@ en:
amount_available: Available budget
accepted: "Accepted spending proposal: "
discarded: "Discarded spending proposal: "
+ incompatibles: Incompatibles
diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml
index 4c35d8902..029c0277a 100644
--- a/config/locales/budgets.es.yml
+++ b/config/locales/budgets.es.yml
@@ -136,3 +136,5 @@ es:
amount_available: Presupuesto disponible
accepted: "Propuesta de inversión aceptada: "
discarded: "Propuesta de inversión descartada: "
+ incompatibles: Incompatibles
+
diff --git a/config/routes.rb b/config/routes.rb
index dbf3e4709..bdf1e22f3 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -210,7 +210,6 @@ Rails.application.routes.draw do
end
end
-
resources :signature_sheets, only: [:index, :new, :create, :show]
resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do
diff --git a/db/migrate/20170703120055_add_incompatible_to_budget_investments.rb b/db/migrate/20170703120055_add_incompatible_to_budget_investments.rb
new file mode 100644
index 000000000..2fffc0802
--- /dev/null
+++ b/db/migrate/20170703120055_add_incompatible_to_budget_investments.rb
@@ -0,0 +1,5 @@
+class AddIncompatibleToBudgetInvestments < ActiveRecord::Migration
+ def change
+ add_column :budget_investments, :incompatible, :bool, default: false, index: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index a72f6ac5c..cb9a015e9 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20170702105956) do
+ActiveRecord::Schema.define(version: 20170703120055) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -95,8 +95,9 @@ ActiveRecord::Schema.define(version: 20170702105956) do
create_table "budget_ballots", force: :cascade do |t|
t.integer "user_id"
t.integer "budget_id"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.integer "ballot_lines_count", default: 0
end
create_table "budget_groups", force: :cascade do |t|
@@ -108,8 +109,8 @@ ActiveRecord::Schema.define(version: 20170702105956) do
create_table "budget_headings", force: :cascade do |t|
t.integer "group_id"
- t.string "name", limit: 50
- t.integer "price", limit: 8
+ t.string "name", limit: 50
+ t.integer "price", limit: 8
t.integer "population"
end
@@ -157,6 +158,7 @@ ActiveRecord::Schema.define(version: 20170702105956) do
t.integer "ballot_lines_count", default: 0
t.integer "previous_heading_id"
t.boolean "winner", default: false
+ t.boolean "incompatible", default: false
end
add_index "budget_investments", ["administrator_id"], name: "index_budget_investments_on_administrator_id", using: :btree
diff --git a/spec/factories.rb b/spec/factories.rb
index c207deefc..31ba2cec0 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -266,6 +266,7 @@ FactoryGirl.define do
unfeasibility_explanation ''
external_url 'http://external_documention.org'
terms_of_service '1'
+ incompatible false
trait :with_confidence_score do
before(:save) { |i| i.calculate_confidence_score }
@@ -300,6 +301,11 @@ FactoryGirl.define do
winner true
end
+ trait :incompatible do
+ selected
+ incompatible true
+ end
+
trait :unselected do
selected false
feasibility "feasible"
diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb
index 727cc3d6c..375a09770 100644
--- a/spec/features/admin/budget_investments_spec.rb
+++ b/spec/features/admin/budget_investments_spec.rb
@@ -311,7 +311,7 @@ feature 'Admin budget investments' do
context "Edit" do
- scenario "Change title, description or heading" do
+ scenario "Change title, incompatible, description or heading" do
budget_investment = create(:budget_investment)
create(:budget_heading, group: budget_investment.group, name: "Barbate")
@@ -321,12 +321,14 @@ feature 'Admin budget investments' do
fill_in 'budget_investment_title', with: 'Potatoes'
fill_in 'budget_investment_description', with: 'Carrots'
select "#{budget_investment.group.name}: Barbate", from: 'budget_investment[heading_id]'
+ check "budget_investment_incompatible"
click_button 'Update'
expect(page).to have_content 'Potatoes'
expect(page).to have_content 'Carrots'
expect(page).to have_content 'Barbate'
+ expect(page).to have_content 'Incompatible'
end
scenario "Add administrator" do
diff --git a/spec/features/budgets/results_spec.rb b/spec/features/budgets/results_spec.rb
index d2a32f992..cd9cb0912 100644
--- a/spec/features/budgets/results_spec.rb
+++ b/spec/features/budgets/results_spec.rb
@@ -8,8 +8,8 @@ feature 'Results' do
let!(:investment1) { create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900) }
let!(:investment2) { create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800) }
- let!(:investment3) { create(:budget_investment, :selected, heading: heading, price: 500, ballot_lines_count: 700) }
- let!(:investment4) { create(:budget_investment, :selected, heading: heading, price: 100, ballot_lines_count: 600) }
+ let!(:investment3) { create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700) }
+ let!(:investment4) { create(:budget_investment, :selected, heading: heading, price: 600, ballot_lines_count: 600) }
let!(:results) { Budget::Result.new(budget, heading).calculate_winners }
@@ -17,31 +17,32 @@ feature 'Results' do
visit budget_path(budget)
click_link "See results"
- within("#budget-investments-results") do
+ within("#budget-investments-compatible") do
expect(page).to have_content investment1.title
expect(page).to have_content investment2.title
- expect(page).to have_content investment3.title
- expect(page).to_not have_content investment4.title
+ expect(page).to have_content investment4.title
expect(investment1.title).to appear_before(investment2.title)
- expect(investment2.title).to appear_before(investment3.title)
+ expect(investment2.title).to appear_before(investment4.title)
+ end
+
+ within("#budget-investments-incompatible") do
+ expect(page).to have_content investment3.title
end
end
scenario "Displays non winner investments", :js do
visit budget_path(budget)
click_link "See results"
- click_link "Show all"
+ click_link "Hide discarded"
- within("#budget-investments-results") do
+ within("#budget-investments-compatible") do
expect(page).to have_content investment1.title
expect(page).to have_content investment2.title
- expect(page).to have_content investment3.title
- expect(page).to have_content investment4.title
+ expect(page).not_to have_content investment3.title
+ expect(page).not_to have_content investment4.title
expect(investment1.title).to appear_before(investment2.title)
- expect(investment2.title).to appear_before(investment3.title)
- expect(investment3.title).to appear_before(investment4.title)
end
end
diff --git a/spec/models/budget/result_spec.rb b/spec/models/budget/result_spec.rb
index f96428221..85eb14f3e 100644
--- a/spec/models/budget/result_spec.rb
+++ b/spec/models/budget/result_spec.rb
@@ -7,29 +7,48 @@ describe Budget::Result do
let(:group) { create(:budget_group, budget: budget) }
let(:heading) { create(:budget_heading, group: group, price: 1000) }
- it "calculates a budget's winner investments" do
- investment1 = create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900)
- investment2 = create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800)
- investment3 = create(:budget_investment, :selected, heading: heading, price: 500, ballot_lines_count: 700)
- investment4 = create(:budget_investment, :selected, heading: heading, price: 100, ballot_lines_count: 600)
+ context "When there is no winners" do
+ it "calculates the correct winner set" do
+ investment1 = create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900, winner: false)
+ investment2 = create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800, winner: false)
+ investment3 = create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700, winner: false)
+ investment4 = create(:budget_investment, :selected, heading: heading, price: 500, ballot_lines_count: 600, winner: false)
+ investment5 = create(:budget_investment, :selected, heading: heading, price: 100, ballot_lines_count: 500, winner: false)
- result = Budget::Result.new(budget, heading)
- result.calculate_winners
+ Budget::Result.new(budget, heading).calculate_winners
- expect(result.winners).to eq([investment1, investment2, investment3])
+ expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment4.id])
+ end
end
- it "resets winners before recalculating" do
- investment1 = create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900, winner: true)
- investment2 = create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800, winner: true)
- investment3 = create(:budget_investment, :selected, heading: heading, price: 500, ballot_lines_count: 700, winner: true)
- investment4 = create(:budget_investment, :selected, heading: heading, price: 100, ballot_lines_count: 600, winner: true)
+ context "When there are winners" do
+ it "removes winners and recalculates" do
+ investment1 = create(:budget_investment, :winner, heading: heading, price: 200, ballot_lines_count: 900)
+ investment2 = create(:budget_investment, :winner, heading: heading, price: 300, ballot_lines_count: 800)
+ investment3 = create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700, winner: true)
+ investment4 = create(:budget_investment, :winner, heading: heading, price: 500, ballot_lines_count: 600)
+ investment5 = create(:budget_investment, :winner, heading: heading, price: 100, ballot_lines_count: 500)
- result = Budget::Result.new(budget, heading)
- result.calculate_winners
+ Budget::Result.new(budget, heading).calculate_winners
- expect(result.winners).to eq([investment1, investment2, investment3])
+ expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment4.id])
+ end
+ end
+
+ context "When a winner is flagged as incompatible" do
+ it "recalculates winners leaving it out" do
+ investment1 = create(:budget_investment, :winner, heading: heading, price: 200, ballot_lines_count: 900)
+ investment2 = create(:budget_investment, :winner, heading: heading, price: 300, ballot_lines_count: 800)
+ investment3 = create(:budget_investment, :winner, heading: heading, price: 500, ballot_lines_count: 700)
+ investment4 = create(:budget_investment, :winner, heading: heading, price: 500, ballot_lines_count: 600)
+ investment5 = create(:budget_investment, :winner, heading: heading, price: 100, ballot_lines_count: 500)
+
+ investment3.incompatible = true
+ investment3.save
+
+ expect(heading.investments.winners.pluck(:id)).to match_array([investment1.id, investment2.id, investment4.id])
+ end
end
end
-end
\ No newline at end of file
+end