<% if can? :show, @ballot %>
<%= link_to t("budget.investments.header.check_ballot"),
diff --git a/app/views/budgets/investments/_votes.html.erb b/app/views/budgets/investments/_votes.html.erb
index 77a95a221..e1dd2860c 100644
--- a/app/views/budgets/investments/_votes.html.erb
+++ b/app/views/budgets/investments/_votes.html.erb
@@ -21,7 +21,7 @@
method: "post",
remote: true,
"aria-hidden" => css_for_aria_hidden(reason) do %>
- <%= t("budget.investments.investment.vote") %>
+ <%= t("budget.investments.investment.give_support") %>
<% end %>
<% end %>
diff --git a/app/views/valuation/budget_investments/edit.html.erb b/app/views/valuation/budget_investments/edit.html.erb
index e03d850a4..16dc3b59d 100644
--- a/app/views/valuation/budget_investments/edit.html.erb
+++ b/app/views/valuation/budget_investments/edit.html.erb
@@ -1,4 +1,8 @@
-<%= link_to "#{t('valuation.budget_investments.show.title')} #{@investment.id}", valuation_budget_budget_investment_path(@budget, @investment), class: 'back' %>
+<%= link_to valuation_budget_budget_investment_path(@budget, @investment), class: 'back' do %>
+
+ <%= "#{t('valuation.budget_investments.show.title')} #{@investment.id}"%>
+<% end %>
+
<%= form_for(@investment, url: valuate_valuation_budget_budget_investment_path(@budget, @investment), html: {id: "valuation_budget_investment_edit_form"}) do |f| %>
diff --git a/app/views/valuation/budget_investments/index.html.erb b/app/views/valuation/budget_investments/index.html.erb
index 9b82f7f5a..1eea49493 100644
--- a/app/views/valuation/budget_investments/index.html.erb
+++ b/app/views/valuation/budget_investments/index.html.erb
@@ -1,4 +1,7 @@
-
<% @heading_filters.each_slice(8) do |slice| %>
@@ -18,25 +21,34 @@
<%= page_entries_info @investments %>
- <% @investments.each do |investment| %>
-
- |
- <%= investment.id %>
- |
-
- <%= link_to investment.title, valuation_budget_budget_investment_path(@budget, investment) %>
- |
-
- <%= link_to t("valuation.budget_investments.index.edit"), edit_valuation_budget_budget_investment_path(@budget, investment) %>
- |
-
- <%= assigned_valuators_info(investment.valuators) %>
- |
-
- <%= investment.heading.name %>
- |
+
+
+ | <%= t("valuation.budget_investments.index.table_id") %> |
+ <%= t("valuation.budget_investments.index.table_title") %> |
+ <%= t("valuation.budget_investments.index.table_heading_name") %> |
+ <%= t("valuation.budget_investments.index.table_actions") %> |
- <% end %>
+
+
+ <% @investments.each do |investment| %>
+
+ |
+ <%= investment.id %>
+ |
+
+ <%= link_to investment.title, valuation_budget_budget_investment_path(@budget, investment) %>
+ |
+
+ <%= investment.heading.name %>
+ |
+
+ <%= link_to t("valuation.budget_investments.index.edit"),
+ edit_valuation_budget_budget_investment_path(@budget, investment),
+ class: "button hollow expanded" %>
+ |
+
+ <% end %>
+
<%= paginate @investments %>
diff --git a/app/views/valuation/budget_investments/show.html.erb b/app/views/valuation/budget_investments/show.html.erb
index 602c53dda..f0eaed2c8 100644
--- a/app/views/valuation/budget_investments/show.html.erb
+++ b/app/views/valuation/budget_investments/show.html.erb
@@ -1,4 +1,7 @@
-<%= render "shared/back_link" %>
+<%= link_to valuation_budget_budget_investments_path do %>
+
+ <%= t('shared.back') %>
+<% end %>
<%= t("valuation.budget_investments.show.title") %> <%= @investment.id %>
<%= @investment.title %>
diff --git a/app/views/valuation/budgets/index.html.erb b/app/views/valuation/budgets/index.html.erb
index 014633373..5df21fc3e 100644
--- a/app/views/valuation/budgets/index.html.erb
+++ b/app/views/valuation/budgets/index.html.erb
@@ -1,17 +1,36 @@
<%= t("valuation.budgets.index.title") %>
-<%= render 'shared/filter_subnav', i18n_namespace: "valuation.budgets.index" %>
-
<%= page_entries_info @budgets %>
- <% @budgets.each do |budget| %>
-
- |
- <%= link_to budget.name, valuation_budget_budget_investments_path(budget_id: budget.id) %>
- |
+
+
+ | <%= t("valuation.budgets.index.table_name") %> |
+ <%= t("valuation.budgets.index.table_phase") %> |
+ <%= t("valuation.budgets.index.table_assigned_investments_valuation_open") %> |
+ <%= t("valuation.budgets.index.table_actions") %> |
- <% end %>
+
+
+ <% @budgets.each do |budget| %>
+
+ |
+ <%= budget.name %>
+ |
+
+ <%= t("budget.phase.#{budget.phase}") %>
+ |
+
+ <%= @investments_with_valuation_open[budget.id] %>
+ |
+
+ <%= link_to t("valuation.budgets.index.evaluate"),
+ valuation_budget_budget_investments_path(budget_id: budget.id),
+ class: "button hollow expanded" %>
+ |
+
+ <% end %>
+
-<%= paginate @budgets %>
\ No newline at end of file
+<%= paginate @budgets %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index 8f27677e7..dadcb7745 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -62,10 +62,17 @@ en:
index:
title: Participatory budgets
new_link: Create new budget
- info_link: Info
filters:
- open: Open
+ current: Open
finished: Finished
+ budget_investments: See budget investments
+ table_name: Name
+ table_phase: Phase
+ table_investments: Investments
+ table_edit_groups: Headings groups
+ table_edit_budget: Edit
+ edit_groups: Edit headings groups
+ edit_budget: Edit budget
create:
notice: New participatory budget created successfully!
update:
@@ -75,9 +82,9 @@ en:
new:
title: New participatory budget
show:
- phase: Current phase
- currency: Currency
- groups: Groups of budget headings
+ groups:
+ one: 1 Group of budget headings
+ other: "%{count} Groups of budget headings"
form:
group: Group name
no_groups: No groups created yet. Each user will be able to vote in only one heading per group.
@@ -88,10 +95,8 @@ en:
amount: Amount
save_heading: Save heading
no_heading: This group has no assigned heading.
- geozone: Scope of operation
table_heading: Heading
table_amount: Amount
- table_geozone: Scope of operation
budget_investments:
index:
heading_filter_all: All headings
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 5f7f66ab6..09959cfde 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -62,10 +62,17 @@ es:
index:
title: Presupuestos participativos
new_link: Crear nuevo presupuesto
- info_link: Info
filters:
- open: Abiertos
+ current: Abiertos
finished: Terminados
+ budget_investments: Ver propuestas de inversión
+ table_name: Nombre
+ table_phase: Fase
+ table_investments: Propuestas de inversión
+ table_edit_groups: Grupos de partidas
+ table_edit_budget: Editar
+ edit_groups: Editar grupos de partidas
+ edit_budget: Editar presupuesto
create:
notice: ¡Nueva campaña de presupuestos participativos creada con éxito!
update:
@@ -75,9 +82,9 @@ es:
new:
title: Nuevo presupuesto ciudadano
show:
- phase: Fase actual
- currency: Divisa
- groups: Grupos de partidas presupuestarias
+ groups:
+ one: 1 Grupo de partidas presupuestarias
+ other: "%{count} Grupos de partidas presupuestarias"
form:
group: Nombre del grupo
no_groups: No hay grupos creados todavía. Cada usuario podrá votar en una sola partida de cada grupo.
@@ -88,10 +95,8 @@ es:
amount: Cantidad
save_heading: Guardar partida
no_heading: Este grupo no tiene ninguna partida asignada.
- geozone: Ámbito de actuación
table_heading: Partida
table_amount: Cantidad
- table_geozone: Ámbito de actuación
budget_investments:
index:
heading_filter_all: Todas las partidas
diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml
index 0a87c818f..fa3aa3dd9 100644
--- a/config/locales/budgets.en.yml
+++ b/config/locales/budgets.en.yml
@@ -118,7 +118,7 @@ en:
one: 1 support
other: "%{count} supports"
zero: No supports
- vote: Vote
+ give_support: Support
header:
check_ballot: Check my ballot
different_heading_assigned_html: "You have active votes in another heading: %{heading_link}"
diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml
index f98940f43..ad7d1025e 100644
--- a/config/locales/budgets.es.yml
+++ b/config/locales/budgets.es.yml
@@ -117,7 +117,7 @@ es:
one: 1 apoyo
other: "%{count} apoyos"
zero: Sin apoyos
- vote: Votar
+ give_support: Apoyar
header:
check_ballot: Revisar mis votos
different_heading_assigned_html: "Ya apoyaste propuestas de otra sección del presupuesto: %{heading_link}"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 83988ab85..adfec0e84 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -441,7 +441,6 @@ en:
collective: Collective
flag: Flag as inappropriate
hide: Hide
- edit: Editar
print:
print_button: Print this info
search: Search
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 8fd9b2c37..06a68286b 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -445,7 +445,6 @@ es:
print_button: Imprimir esta información
search: Buscar
show: Mostrar
- edit: Editar
suggest:
debate:
found:
diff --git a/config/locales/valuation.en.yml b/config/locales/valuation.en.yml
index a5195deca..de19fea09 100644
--- a/config/locales/valuation.en.yml
+++ b/config/locales/valuation.en.yml
@@ -9,8 +9,13 @@ en:
index:
title: Participatory budgets
filters:
- open: Open
+ current: Open
finished: Finished
+ table_name: Name
+ table_phase: Phase
+ table_assigned_investments_valuation_open: Investment projects assigned with valuation open
+ table_actions: Actions
+ evaluate: Evaluate
budget_investments:
index:
headings_filter_all: All headings
@@ -18,12 +23,17 @@ en:
valuation_open: Open
valuating: Under valuation
valuation_finished: Valuation finished
+ assigned_to: "Assigned to %{valuator}"
title: Investment projects
- edit: Edit
+ edit: Edit dossier
valuators_assigned:
one: Assigned valuator
other: "%{count} valuators assigned"
no_valuators_assigned: No valuators assigned
+ table_id: ID
+ table_title: Title
+ table_heading_name: Heading name
+ table_actions: Actions
show:
back: Back
title: Investment project
diff --git a/config/locales/valuation.es.yml b/config/locales/valuation.es.yml
index 67302437b..b588c8521 100644
--- a/config/locales/valuation.es.yml
+++ b/config/locales/valuation.es.yml
@@ -9,8 +9,13 @@ es:
index:
title: Presupuestos participativos
filters:
- open: Abiertos
+ current: Abiertos
finished: Terminados
+ table_name: Nombre
+ table_phase: Fase
+ table_assigned_investments_valuation_open: Prop. Inv. asignadas en evaluación
+ table_actions: Acciones
+ evaluate: Evaluar
budget_investments:
index:
headings_filter_all: Todas las partidas
@@ -19,11 +24,16 @@ es:
valuating: En evaluación
valuation_finished: Evaluación finalizada
title: Propuestas de inversión
- edit: Editar
+ assigned_to: "Asignadas a %{valuator}"
+ edit: Editar informe
valuators_assigned:
one: Evaluador asignado
other: "%{count} evaluadores asignados"
no_valuators_assigned: Sin evaluador
+ table_id: ID
+ table_title: Título
+ table_heading_name: Nombre de la partida
+ table_actions: Acciones
show:
back: Volver
title: Propuesta de inversión
diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb
index d6f994cb2..3acc1154a 100644
--- a/db/dev_seeds.rb
+++ b/db/dev_seeds.rb
@@ -373,7 +373,7 @@ tags = Faker::Lorem.words(10)
description: "
#{Faker::Lorem.paragraphs.join('
')}
",
created_at: rand((Time.now - 1.week) .. Time.now),
feasibility: %w{undecided unfeasible feasible feasible feasible feasible}.sample,
- unfeasibility_explanation: "
#{Faker::Lorem.paragraphs.join('
')}
",
+ unfeasibility_explanation: Faker::Lorem.paragraph,
valuation_finished: [false, true].sample,
tag_list: tags.sample(3).join(','),
price: rand(1 .. 100) * 100000,
diff --git a/db/migrate/20170103170147_remove_geozone_id_from_budget_headings.rb b/db/migrate/20170103170147_remove_geozone_id_from_budget_headings.rb
new file mode 100644
index 000000000..bc8a9729c
--- /dev/null
+++ b/db/migrate/20170103170147_remove_geozone_id_from_budget_headings.rb
@@ -0,0 +1,5 @@
+class RemoveGeozoneIdFromBudgetHeadings < ActiveRecord::Migration
+ def change
+ remove_column :budget_headings, :geozone_id
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 98a2659dd..7ebc5f684 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: 20170102080432) do
+ActiveRecord::Schema.define(version: 20170103170147) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -107,9 +107,8 @@ ActiveRecord::Schema.define(version: 20170102080432) do
create_table "budget_headings", force: :cascade do |t|
t.integer "group_id"
- t.integer "geozone_id"
- t.string "name", limit: 50
- t.integer "price", limit: 8
+ t.string "name", limit: 50
+ t.integer "price", limit: 8
end
add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree
diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb
index fccbd7785..8f17c27d4 100644
--- a/spec/features/admin/budgets_spec.rb
+++ b/spec/features/admin/budgets_spec.rb
@@ -47,7 +47,7 @@ feature 'Admin budgets' do
expect(page).to_not have_content(budget4.name)
expect(page).to have_content(budget5.name)
- click_link 'Current'
+ click_link 'Open'
expect(page).to have_content(budget1.name)
expect(page).to have_content(budget2.name)
expect(page).to have_content(budget3.name)
@@ -55,8 +55,8 @@ feature 'Admin budgets' do
expect(page).to_not have_content(budget5.name)
end
- scenario 'Current filter is properly highlighted' do
- filters_links = {'current' => 'Current', 'finished' => 'Finished'}
+ scenario 'Open filter is properly highlighted' do
+ filters_links = {'current' => 'Open', 'finished' => 'Finished'}
visit admin_budgets_path
@@ -110,22 +110,29 @@ feature 'Admin budgets' do
visit admin_budgets_path
within("#budget_#{budget.id}") do
- click_link 'Info'
+ click_link 'Edit headings groups'
end
+ expect(page).to have_content '0 Groups of budget headings'
expect(page).to have_content 'No groups created yet.'
click_link 'Add new group'
- fill_in 'budget_group_name', with: 'General improvments'
+ fill_in 'budget_group_name', with: 'Health'
click_button 'Create group'
+ expect(page).to have_content '1 Group of budget headings'
+ expect(page).to have_content 'Health'
expect(page).to have_content 'Yearly participatory budget'
expect(page).to_not have_content 'No groups created yet.'
visit admin_budgets_path
- click_link 'Yearly participatory budget'
+ within("#budget_#{budget.id}") do
+ click_link 'Edit headings groups'
+ end
+ expect(page).to have_content '1 Group of budget headings'
+ expect(page).to have_content 'Health'
expect(page).to have_content 'Yearly participatory budget'
expect(page).to_not have_content 'No groups created yet.'
end
@@ -153,7 +160,6 @@ feature 'Admin budgets' do
expect(page).to have_content 'District 9 reconstruction'
expect(page).to have_content '6785'
- expect(page).to have_content 'All city'
end
end
diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb
index 097f0bd8f..39f443ce3 100644
--- a/spec/features/budgets/investments_spec.rb
+++ b/spec/features/budgets/investments_spec.rb
@@ -344,10 +344,8 @@ feature 'Budget Investments' do
global_group = create(:budget_group, budget: budget, name: 'Global Group')
global_heading = create(:budget_heading, group: global_group, name: 'Global Heading')
- carabanchel = create(:geozone, name: "Carabanchel")
- new_york = create(:geozone, name: "New York")
- carabanchel_heading = create(:budget_heading, group: group, geozone: carabanchel, name: carabanchel.name)
- new_york_heading = create(:budget_heading, group: group, geozone: new_york, name: new_york.name)
+ carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel")
+ new_york_heading = create(:budget_heading, group: group, name: "New York")
sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading)
diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb
index 627d6a391..bac7d1fe2 100644
--- a/spec/features/valuation/budget_investments_spec.rb
+++ b/spec/features/valuation/budget_investments_spec.rb
@@ -54,34 +54,6 @@ feature 'Valuation budget investments' do
expect(investment10.title).to appear_before(investment1.title)
end
- scenario 'Index shows assignments info' do
- investment1 = create(:budget_investment, budget: @budget)
- investment2 = create(:budget_investment, budget: @budget)
- investment3 = create(:budget_investment, budget: @budget)
-
- valuator1 = create(:valuator, user: create(:user))
- valuator2 = create(:valuator, user: create(:user))
- valuator3 = create(:valuator, user: create(:user))
-
- investment1.valuator_ids = [@valuator.id]
- investment2.valuator_ids = [@valuator.id, valuator1.id, valuator2.id]
- investment3.valuator_ids = [@valuator.id, valuator3.id]
-
- visit valuation_budget_budget_investments_path(@budget)
-
- within("#budget_investment_#{investment1.id}") do
- expect(page).to have_content("Rachel")
- end
-
- within("#budget_investment_#{investment2.id}") do
- expect(page).to have_content("3 valuators assigned")
- end
-
- within("#budget_investment_#{investment3.id}") do
- expect(page).to have_content("2 valuators assigned")
- end
- end
-
scenario "Index filtering by heading", :js do
group = create(:budget_group, budget: @budget)
heading1 = create(:budget_heading, name: "District 9", group: group)
@@ -262,7 +234,7 @@ feature 'Valuation budget investments' do
scenario 'Edit dossier' do
visit valuation_budget_budget_investments_path(@budget)
within("#budget_investment_#{@investment.id}") do
- click_link "Edit"
+ click_link "Edit dossier"
end
fill_in 'budget_investment_price', with: '12345'
@@ -381,7 +353,7 @@ feature 'Valuation budget investments' do
scenario 'Validates price formats' do
visit valuation_budget_budget_investments_path(@budget)
within("#budget_investment_#{@investment.id}") do
- click_link "Edit"
+ click_link "Edit dossier"
end
fill_in 'budget_investment_price', with: '12345,98'
diff --git a/spec/features/valuation/budgets_spec.rb b/spec/features/valuation/budgets_spec.rb
index 11c20f26e..23de4c9e9 100644
--- a/spec/features/valuation/budgets_spec.rb
+++ b/spec/features/valuation/budgets_spec.rb
@@ -34,39 +34,6 @@ feature 'Valuation budgets' do
expect(page).to have_content(budget3.name)
expect(page).to have_content(budget4.name)
expect(page).to_not have_content(budget5.name)
-
- click_link 'Finished'
- expect(page).to_not have_content(budget1.name)
- expect(page).to_not have_content(budget2.name)
- expect(page).to_not have_content(budget3.name)
- expect(page).to_not have_content(budget4.name)
- expect(page).to have_content(budget5.name)
-
- click_link 'Current'
- expect(page).to have_content(budget1.name)
- expect(page).to have_content(budget2.name)
- expect(page).to have_content(budget3.name)
- expect(page).to have_content(budget4.name)
- expect(page).to_not have_content(budget5.name)
- end
-
- scenario 'Current filter is properly highlighted' do
- filters_links = {'current' => 'Current', 'finished' => 'Finished'}
-
- visit valuation_budgets_path
-
- expect(page).to_not have_link(filters_links.values.first)
- filters_links.keys.drop(1).each { |filter| expect(page).to have_link(filters_links[filter]) }
-
- filters_links.each_pair do |current_filter, link|
- visit valuation_budgets_path(filter: current_filter)
-
- expect(page).to_not have_link(link)
-
- (filters_links.keys - [current_filter]).each do |filter|
- expect(page).to have_link(filters_links[filter])
- end
- end
end
end
diff --git a/spec/models/abilities/administrator_spec.rb b/spec/models/abilities/administrator_spec.rb
index 8f48153a8..8c4e8a1ef 100644
--- a/spec/models/abilities/administrator_spec.rb
+++ b/spec/models/abilities/administrator_spec.rb
@@ -66,6 +66,6 @@ describe "Abilities::Administrator" do
it { should be_able_to(:hide, Budget::Investment) }
it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'valuating'))) }
- it { should_not be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) }
+ it { should be_able_to(:valuate, create(:budget_investment, budget: create(:budget, phase: 'finished'))) }
end
diff --git a/spec/models/abilities/valuator_spec.rb b/spec/models/abilities/valuator_spec.rb
index fee24f6a8..c3735b43b 100644
--- a/spec/models/abilities/valuator_spec.rb
+++ b/spec/models/abilities/valuator_spec.rb
@@ -10,8 +10,8 @@ describe "Abilities::Valuator" do
let(:assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'valuating')) }
before(:each) { assigned_investment.valuators << valuator }
- let(:assigned_investment_not_valuating) { create(:budget_investment, budget: create(:budget, phase: 'finished')) }
- before(:each) { assigned_investment_not_valuating.valuators << valuator }
+ let(:finished_assigned_investment) { create(:budget_investment, budget: create(:budget, phase: 'finished')) }
+ before(:each) { finished_assigned_investment.valuators << valuator }
it { should be_able_to(:read, SpendingProposal) }
it { should be_able_to(:update, SpendingProposal) }
@@ -23,6 +23,6 @@ describe "Abilities::Valuator" do
it { should be_able_to(:update, assigned_investment) }
it { should be_able_to(:valuate, assigned_investment) }
- it { should_not be_able_to(:update, assigned_investment_not_valuating) }
- it { should_not be_able_to(:valuate, assigned_investment_not_valuating) }
+ it { should_not be_able_to(:update, finished_assigned_investment) }
+ it { should_not be_able_to(:valuate, finished_assigned_investment) }
end
diff --git a/spec/models/budget/ballot_spec.rb b/spec/models/budget/ballot_spec.rb
index e99a2276d..259a4a4f4 100644
--- a/spec/models/budget/ballot_spec.rb
+++ b/spec/models/budget/ballot_spec.rb
@@ -23,29 +23,35 @@ describe Budget::Ballot do
end
it "returns the amount spent on all investments assigned to a specific heading" do
- heading = create(:budget_heading)
- budget = heading.group.budget
- inv1 = create(:budget_investment, :selected, price: 10000, heading: heading)
- inv2 = create(:budget_investment, :selected, price: 20000, heading: create(:budget_heading, group: heading.group))
- inv3 = create(:budget_investment, :selected, price: 40000, heading: heading)
+ budget = create(:budget)
+ group1 = create(:budget_group, budget: budget)
+ group2 = create(:budget_group, budget: budget)
+ heading1 = create(:budget_heading, group: group1, price: 100000)
+ heading2 = create(:budget_heading, group: group2, price: 200000)
+ inv1 = create(:budget_investment, :selected, price: 10000, heading: heading1)
+ inv2 = create(:budget_investment, :selected, price: 20000, heading: heading2)
+ inv3 = create(:budget_investment, :selected, price: 40000, heading: heading1)
ballot = create(:budget_ballot, budget: budget)
ballot.investments << inv1 << inv2
- expect(ballot.amount_spent(heading)).to eq 10000
+ expect(ballot.amount_spent(heading1)).to eq 10000
+ expect(ballot.amount_spent(heading2)).to eq 20000
ballot.investments << inv3
- expect(ballot.amount_spent(heading)).to eq 50000
+ expect(ballot.amount_spent(heading1)).to eq 50000
+ expect(ballot.amount_spent(heading2)).to eq 20000
end
end
describe "#amount_available" do
it "returns how much is left after taking some investments" do
budget = create(:budget)
- group = create(:budget_group, budget: budget)
- heading1 = create(:budget_heading, group: group, price: 1000)
- heading2 = create(:budget_heading, group: group, price: 300)
+ group1 = create(:budget_group, budget: budget)
+ group2 = create(:budget_group, budget: budget)
+ heading1 = create(:budget_heading, group: group1, price: 1000)
+ heading2 = create(:budget_heading, group: group2, price: 300)
inv1 = create(:budget_investment, :selected, price: 100, heading: heading1)
inv2 = create(:budget_investment, :selected, price: 200, heading: heading2)
inv3 = create(:budget_investment, :selected, price: 400, heading: heading1)