From 18bd44d91fd347ff2ea33c0d6df3d05116f88ee1 Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 3 Jan 2017 18:00:35 +0100 Subject: [PATCH 01/24] do not use html in generation of unfeasibility reason --- db/dev_seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index ee7d1a471..69ac27c09 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -372,7 +372,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, From 2c343788d50f46fa61b7d729f843065685f7e6d9 Mon Sep 17 00:00:00 2001 From: kikito Date: Tue, 3 Jan 2017 18:11:59 +0100 Subject: [PATCH 02/24] Fixes typo --- app/views/budgets/investments/_header.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/budgets/investments/_header.html.erb b/app/views/budgets/investments/_header.html.erb index 1074fdf70..ba3e8d5b8 100644 --- a/app/views/budgets/investments/_header.html.erb +++ b/app/views/budgets/investments/_header.html.erb @@ -20,7 +20,7 @@
-

<%= @filter_geozone_name %>

+

<%= @heading.name %>

-
- - <%= f.select :geozone_id, geozone_select_options, {include_blank: t("geozones.none"), label: false} %> -
<%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %> @@ -65,12 +60,9 @@ <%= heading.price %> - - <%= geozone_name_from_id heading.geozone_id %> - <% end %> -
\ No newline at end of file +
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 8f27677e7..222d11c78 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -88,10 +88,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..d8c9036a8 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -88,10 +88,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/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index fccbd7785..70e85378d 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -153,7 +153,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 From e1367d4463ea578caba09012cde4fc5518b8dcc8 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 13:52:04 +0100 Subject: [PATCH 05/24] improves table of admin budgets index --- app/views/admin/budgets/index.html.erb | 42 ++++++++++++++++++-------- config/locales/admin.en.yml | 11 +++++-- config/locales/admin.es.yml | 11 +++++-- 3 files changed, 47 insertions(+), 17 deletions(-) diff --git a/app/views/admin/budgets/index.html.erb b/app/views/admin/budgets/index.html.erb index d4de771db..7bf4b0659 100644 --- a/app/views/admin/budgets/index.html.erb +++ b/app/views/admin/budgets/index.html.erb @@ -6,23 +6,39 @@ <%= render 'shared/filter_subnav', i18n_namespace: "admin.budgets.index" %> -

<%= page_entries_info @budgets %>

- <% @budgets.each do |budget| %> - - - - + + + + + + + - <% end %> + + + <% @budgets.each do |budget| %> + + + + + + + + <% end %> +
- <%= link_to budget.name, admin_budget_budget_investments_path(budget_id: budget.id) %> - - <%= t("budget.phase.#{budget.phase}") %> - - <%= link_to t("admin.budgets.index.info_link"), admin_budget_path(budget) %> -
<%= t("admin.budgets.index.table_name") %><%= t("admin.budgets.index.table_phase") %><%= t("admin.budgets.index.table_investments") %><%= t("admin.budgets.index.table_edit_groups") %><%= t("admin.budgets.index.table_edit_budget") %>
+ <%= budget.name %> + + <%= t("budget.phase.#{budget.phase}") %> + + <%= link_to t("admin.budgets.index.budget_investments"), admin_budget_budget_investments_path(budget_id: budget.id) %> + + <%= link_to t("admin.budgets.index.edit_groups"), admin_budget_path(budget) %> + + <%= link_to t("admin.budgets.index.edit_budget"), edit_admin_budget_path(budget) %> +
<%= paginate @budgets %> \ No newline at end of file diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 8f27677e7..e34c2183c 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: diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 5f7f66ab6..8109251f1 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: From 08586d521b188e7c5871e6b068797d0ef48ef34e Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 13:54:07 +0100 Subject: [PATCH 06/24] Refactors heading.budget . adds heading.budget_id --- app/models/budget/heading.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/models/budget/heading.rb b/app/models/budget/heading.rb index ae5dc28ee..aef3eabc4 100644 --- a/app/models/budget/heading.rb +++ b/app/models/budget/heading.rb @@ -10,13 +10,7 @@ class Budget scope :order_by_group_name, -> { includes(:group).order('budget_groups.name', 'budget_headings.name') } - def budget - group.budget - end - - def budget=(resource) - group.budget = resource - end + delegate :budget, :budget_id, to: :group, allow_nil: true def name_scoped_by_group "#{group.name}: #{name}" From f5dcb51d37bcbf0df40424f947b0b7185f58ec5a Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 13:56:42 +0100 Subject: [PATCH 07/24] Adds valid_heading validation to budget line. Renames validation methods. --- app/models/budget/ballot/line.rb | 18 +++++++----------- spec/models/budget/ballot_spec.rb | 26 ++++++++++++++++---------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/models/budget/ballot/line.rb b/app/models/budget/ballot/line.rb index 83e388ee1..23c6aaef2 100644 --- a/app/models/budget/ballot/line.rb +++ b/app/models/budget/ballot/line.rb @@ -9,28 +9,24 @@ class Budget validates :ballot_id, :investment_id, :heading_id, :group_id, :budget_id, presence: true - validate :insufficient_funds - #needed? validate :different_geozone, :if => :district_proposal? - validate :unselected + validate :check_selected + validate :check_sufficient_funds + validate :check_valid_heading before_validation :set_denormalized_ids - def insufficient_funds + def check_sufficient_funds errors.add(:money, "insufficient funds") if ballot.amount_available(investment.heading) < investment.price.to_i end - def different_geozone - errors.add(:heading, "different heading assigned") if (ballot.heading.present? && investment.heading != ballot.heading) + def check_valid_heading + errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected") unless ballot.valid_heading?(self.heading) end - def unselected + def check_selected errors.add(:investment, "unselected investment") unless investment.selected? end - def heading_proposal? - investment.heading_id.present? - end - private def set_denormalized_ids 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) From b289e21992622a27eac61ce38046975ecb0189dc Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 13:56:54 +0100 Subject: [PATCH 08/24] Refactors valid_heading --- app/models/budget/ballot.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/app/models/budget/ballot.rb b/app/models/budget/ballot.rb index 8f466936c..8355232a8 100644 --- a/app/models/budget/ballot.rb +++ b/app/models/budget/ballot.rb @@ -36,14 +36,17 @@ class Budget self.groups.include?(group) end + def wrong_budget?(heading) + heading.budget_id != budget_id + end + + def different_heading_assigned?(heading) + other_heading_ids = heading.group.heading_ids - [heading.id] + lines.where(heading_id: other_heading_ids).exists? + end + def valid_heading?(heading) - group = heading.group - return false if group.budget_id != budget_id - - line = lines.where(heading_id: group.heading_ids).first - return false if line.present? && line.heading_id != heading.id - - true + !wrong_budget?(heading) && !different_heading_assigned?(heading) end def has_lines_with_no_heading? From 4ceeb68a9057802ea29683607edaf88a5d3b7566 Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 15:59:36 +0100 Subject: [PATCH 09/24] changes abilities extending valuation period --- app/models/abilities/administrator.rb | 2 +- app/models/abilities/valuator.rb | 3 ++- spec/models/abilities/administrator_spec.rb | 2 +- spec/models/abilities/valuator_spec.rb | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 582d6a9e0..5590d1939 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -46,7 +46,7 @@ module Abilities can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Heading can [:hide, :update, :toggle_selection], Budget::Investment - can :valuate, Budget::Investment, budget: { phase: 'valuating' } + can :valuate, Budget::Investment can :create, Budget::ValuatorAssignment can [:search, :edit, :update, :create, :index, :destroy], Banner diff --git a/app/models/abilities/valuator.rb b/app/models/abilities/valuator.rb index 1462e2630..614869665 100644 --- a/app/models/abilities/valuator.rb +++ b/app/models/abilities/valuator.rb @@ -5,7 +5,8 @@ module Abilities def initialize(user) valuator = user.valuator can [:read, :update, :valuate], SpendingProposal - can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids, budget: { phase: 'valuating' } + can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids + cannot [:update, :valuate], Budget::Investment, budget: { phase: 'finished' } 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 From 9c66fa0dc8f17ff269d644855d8fda8e8d7d447a Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 16:31:16 +0100 Subject: [PATCH 10/24] removes filter from valuation index page --- app/controllers/valuation/budgets_controller.rb | 4 +--- app/views/valuation/budgets/index.html.erb | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/controllers/valuation/budgets_controller.rb b/app/controllers/valuation/budgets_controller.rb index 3b470101f..0b7efe858 100644 --- a/app/controllers/valuation/budgets_controller.rb +++ b/app/controllers/valuation/budgets_controller.rb @@ -2,12 +2,10 @@ class Valuation::BudgetsController < Valuation::BaseController include FeatureFlags feature_flag :budgets - has_filters %w{current finished}, only: :index - load_and_authorize_resource def index - @budgets = Budget.send(@current_filter).order(created_at: :desc).page(params[:page]) + @budgets = @budgets.current.order(created_at: :desc).page(params[:page]) end end diff --git a/app/views/valuation/budgets/index.html.erb b/app/views/valuation/budgets/index.html.erb index 014633373..47571688f 100644 --- a/app/views/valuation/budgets/index.html.erb +++ b/app/views/valuation/budgets/index.html.erb @@ -1,7 +1,5 @@

<%= t("valuation.budgets.index.title") %>

-<%= render 'shared/filter_subnav', i18n_namespace: "valuation.budgets.index" %> -

<%= page_entries_info @budgets %>

@@ -14,4 +12,4 @@ <% end %>
-<%= paginate @budgets %> \ No newline at end of file +<%= paginate @budgets %> From e9acf295b8d120f87344e64022498baae9b5562f Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 17:00:56 +0100 Subject: [PATCH 11/24] removes filter specs after removing filtering from valuation --- spec/features/valuation/budgets_spec.rb | 33 ------------------------- 1 file changed, 33 deletions(-) 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 From 46d96e5a189151b427d56ae4538c1e580be61ef8 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 17:02:27 +0100 Subject: [PATCH 12/24] improves styles for admin budgets show --- app/views/admin/budgets/_group.html.erb | 140 +++++++++++------------ app/views/admin/budgets/_groups.html.erb | 60 +++++----- app/views/admin/budgets/show.html.erb | 18 +-- 3 files changed, 104 insertions(+), 114 deletions(-) diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb index 3660fa0c1..2890ada2c 100644 --- a/app/views/admin/budgets/_group.html.erb +++ b/app/views/admin/budgets/_group.html.erb @@ -1,76 +1,74 @@ -
- - - - - +
- <%= group.name %> - <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %> -
+ + + + - <% if headings.blank? %> - - - - - <% else %> - - - - - - - - <% end %> - - - - - - - - <% headings.each do |heading| %> + <% if headings.blank? %> + - - - + <% else %> + + + + + + + + <% end %> + + + + -
+ <%= group.name %> + <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %> +
-
- <%= t("admin.budgets.form.no_heading") %> -
-
<%= t("admin.budgets.form.table_heading") %><%= t("admin.budgets.form.table_amount") %><%= t("admin.budgets.form.table_geozone") %>
- <%= heading.name %> - - <%= heading.price %> - - <%= geozone_name_from_id heading.geozone_id %> + +
+ <%= t("admin.budgets.form.no_heading") %> +
<%= t("admin.budgets.form.table_heading") %><%= t("admin.budgets.form.table_amount") %><%= t("admin.budgets.form.table_geozone") %>
-
\ No newline at end of file + + + + + <% headings.each do |heading| %> + + + <%= heading.name %> + + + <%= heading.price %> + + + <%= geozone_name_from_id heading.geozone_id %> + + + <% end %> + + + diff --git a/app/views/admin/budgets/_groups.html.erb b/app/views/admin/budgets/_groups.html.erb index ba785ee0c..f5dde3aa1 100644 --- a/app/views/admin/budgets/_groups.html.erb +++ b/app/views/admin/budgets/_groups.html.erb @@ -1,34 +1,32 @@ -
-

<%= t('admin.budgets.show.groups') %>

- <% if groups.blank? %> -
- <%= t("admin.budgets.form.no_groups") %> - <%= link_to t("admin.budgets.form.add_group"), "#", - class: "js-toggle-link", - data: { "toggle-selector" => "#new-group-form" } %> -
- <% else %> - <%= link_to t("admin.budgets.form.add_group"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#new-group-form" } %> - <% end %> +

<%= t('admin.budgets.show.groups') %>

+<% if groups.blank? %> +
+ <%= t("admin.budgets.form.no_groups") %> + <%= link_to t("admin.budgets.form.add_group"), "#", + class: "js-toggle-link", + data: { "toggle-selector" => "#new-group-form" } %> +
+<% else %> + <%= link_to t("admin.budgets.form.add_group"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#new-group-form" } %> +<% end %> - <%= form_for [:admin, @budget, Budget::Group.new], html: {id: "new-group-form", style: "display:none"}, remote: true do |f| %> -
- - - - <%= f.text_field :name, - label: false, - maxlength: 50, - placeholder: t("admin.budgets.form.group") %> -
- <%= f.submit t("admin.budgets.form.create_group"), class: "button success" %> -
+<%= form_for [:admin, @budget, Budget::Group.new], html: {id: "new-group-form", style: "display:none"}, remote: true do |f| %> +
+ + + + <%= f.text_field :name, + label: false, + maxlength: 50, + placeholder: t("admin.budgets.form.group") %> +
+ <%= f.submit t("admin.budgets.form.create_group"), class: "button success" %>
- <% end %> +
+<% end %> - <% groups.each do |group| %> -
- <%= render "admin/budgets/group", group: group, headings: group.headings %> -
- <% end %> -
\ No newline at end of file +<% groups.each do |group| %> +
+ <%= render "admin/budgets/group", group: group, headings: group.headings %> +
+<% end %> diff --git a/app/views/admin/budgets/show.html.erb b/app/views/admin/budgets/show.html.erb index 4468f7599..1f3292019 100644 --- a/app/views/admin/budgets/show.html.erb +++ b/app/views/admin/budgets/show.html.erb @@ -1,16 +1,10 @@ -
-
-

<%= @budget.name %> <%= link_to(t('shared.edit'), edit_admin_budget_path(@budget)) %>

+<%= link_to admin_budgets_path do %> + + <%= t('shared.back') %> +<% end %> - <%= @budget.description %> +

<%= @budget.name %>

-

- <%= t('admin.budgets.show.phase') %>: <%= t("budget.phase.#{@budget.phase}") %> | - <%= t('admin.budgets.show.currency') %>: <%= @budget.currency_symbol %> -

-
-
- -
+
<%= render "groups", groups: @budget.groups %>
From 02359c8e2aeffc22b8fa5a1c23985752d3497e97 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 17:04:37 +0100 Subject: [PATCH 13/24] improves styles for admin budgets edit --- app/views/admin/budgets/_form.html.erb | 6 ++++-- app/views/admin/budgets/edit.html.erb | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index 22a774b76..5d323b45c 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -3,10 +3,12 @@ <%= f.text_field :name, maxlength: Budget.title_max_length %> <% Budget::PHASES.each do |phase| %> - <%= f.cktext_area "description_#{phase}", maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %> +
+ <%= f.cktext_area "description_#{phase}", maxlength: Budget.description_max_length, ckeditor: { language: I18n.locale } %> +
<% end %> -
+
<%= f.select :phase, budget_phases_select_options %>
diff --git a/app/views/admin/budgets/edit.html.erb b/app/views/admin/budgets/edit.html.erb index 6fd1e3e1f..34672bf7a 100644 --- a/app/views/admin/budgets/edit.html.erb +++ b/app/views/admin/budgets/edit.html.erb @@ -1,3 +1,8 @@ +<%= link_to admin_budgets_path do %> + + <%= t('shared.back') %> +<% end %> +

<%= t("admin.budgets.edit.title") %>

From 8aa982725e277480509d1649bcb4cc8437b521a3 Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 17:10:56 +0100 Subject: [PATCH 14/24] Renames "Vote" to "Give support" during the support phase --- app/views/budgets/investments/_votes.html.erb | 2 +- config/locales/budgets.en.yml | 2 +- config/locales/budgets.es.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 974f412eb..29dad936f 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 1a9f9554b..99ec69ae6 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}" From 74a361690de4be83be585b961d1050557aa2f77b Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 17:33:09 +0100 Subject: [PATCH 15/24] improves styles for valuation budgets --- .../budget_investments/index.html.erb | 50 ++++++++++++------- app/views/valuation/budgets/index.html.erb | 35 ++++++++++--- config/locales/valuation.en.yml | 13 ++++- config/locales/valuation.es.yml | 13 ++++- 4 files changed, 81 insertions(+), 30 deletions(-) diff --git a/app/views/valuation/budget_investments/index.html.erb b/app/views/valuation/budget_investments/index.html.erb index 9b82f7f5a..b44a129aa 100644 --- a/app/views/valuation/budget_investments/index.html.erb +++ b/app/views/valuation/budget_investments/index.html.erb @@ -1,4 +1,7 @@ -

<%= @budget.name %> - <%= t("valuation.budget_investments.index.title") %>

+

+ <%= @budget.name %> - <%= t("valuation.budget_investments.index.title") %> + (Asignadas a EVALUADOR) +

<% @heading_filters.each_slice(8) do |slice| %> @@ -18,25 +21,34 @@

<%= page_entries_info @investments %>

- <% @investments.each do |investment| %> - - - - - - + + + + + + - <% end %> + + + <% @investments.each do |investment| %> + + + + + + + <% end %> +
- <%= 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") %>
+ <%= 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" %> +
<%= paginate @investments %> diff --git a/app/views/valuation/budgets/index.html.erb b/app/views/valuation/budgets/index.html.erb index 014633373..0db30c335 100644 --- a/app/views/valuation/budgets/index.html.erb +++ b/app/views/valuation/budgets/index.html.erb @@ -5,13 +5,34 @@

<%= page_entries_info @budgets %>

- <% @budgets.each do |budget| %> - - + + + + + + - <% end %> + + + <% @budgets.each do |budget| %> + + + + + + + <% end %> +
- <%= 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_headings") %><%= t("valuation.budgets.index.table_actions") %>
+ <%= budget.name %> + + <%= t("budget.phase.#{budget.phase}") %> + + 3 partidas + + <%= link_to t("valuation.budgets.index.evaluate"), + valuation_budget_budget_investments_path(budget_id: budget.id), + class: "button hollow expanded" %> +
-<%= paginate @budgets %> \ No newline at end of file +<%= paginate @budgets %> diff --git a/config/locales/valuation.en.yml b/config/locales/valuation.en.yml index a5195deca..4aafe160b 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_headings: Assigned headings + table_actions: Actions + evaluate: Evaluate budget_investments: index: headings_filter_all: All headings @@ -19,11 +24,15 @@ en: valuating: Under valuation valuation_finished: Valuation finished 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..641f9c003 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_headings: Partidas asignadas + table_actions: Acciones + evaluate: Evaluar budget_investments: index: headings_filter_all: Todas las partidas @@ -19,11 +24,15 @@ es: valuating: En evaluación valuation_finished: Evaluación finalizada title: Propuestas de inversión - edit: Editar + 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 From fa7d6c18fd99906be7c50e9baa710207d493c127 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 17:33:59 +0100 Subject: [PATCH 16/24] fixes back links on valuation budgets --- app/views/valuation/budget_investments/edit.html.erb | 6 +++++- app/views/valuation/budget_investments/show.html.erb | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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 %> +

<%= t("valuation.budget_investments.edit.dossier") %>

<%= 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/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 %>

From 32c11c098146ff55668ada5497008fc0d7b8d080 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 17:36:03 +0100 Subject: [PATCH 17/24] removes unused i18n keys --- config/locales/admin.en.yml | 2 -- config/locales/admin.es.yml | 2 -- config/locales/en.yml | 1 - config/locales/es.yml | 1 - 4 files changed, 6 deletions(-) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index e34c2183c..e0decfc3a 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -82,8 +82,6 @@ en: new: title: New participatory budget show: - phase: Current phase - currency: Currency groups: Groups of budget headings form: group: Group name diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 8109251f1..28d9164aa 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -82,8 +82,6 @@ es: new: title: Nuevo presupuesto ciudadano show: - phase: Fase actual - currency: Divisa groups: Grupos de partidas presupuestarias form: group: Nombre del grupo 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: From 0835a7aba628275f69ba96efba9ba019dc3a4d0d Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 18:24:15 +0100 Subject: [PATCH 18/24] fixes valuation subtitle in budget investments index --- app/views/valuation/budget_investments/index.html.erb | 2 +- config/locales/valuation.en.yml | 1 + config/locales/valuation.es.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/valuation/budget_investments/index.html.erb b/app/views/valuation/budget_investments/index.html.erb index b44a129aa..1eea49493 100644 --- a/app/views/valuation/budget_investments/index.html.erb +++ b/app/views/valuation/budget_investments/index.html.erb @@ -1,6 +1,6 @@

<%= @budget.name %> - <%= t("valuation.budget_investments.index.title") %> - (Asignadas a EVALUADOR) + <%= t('valuation.budget_investments.index.assigned_to', valuator: current_user.name) %>

diff --git a/config/locales/valuation.en.yml b/config/locales/valuation.en.yml index 4aafe160b..b28446a77 100644 --- a/config/locales/valuation.en.yml +++ b/config/locales/valuation.en.yml @@ -23,6 +23,7 @@ en: valuation_open: Open valuating: Under valuation valuation_finished: Valuation finished + assigned_to: "Assigned to %{valuator}" title: Investment projects edit: Edit dossier valuators_assigned: diff --git a/config/locales/valuation.es.yml b/config/locales/valuation.es.yml index 641f9c003..b8a9d6a3f 100644 --- a/config/locales/valuation.es.yml +++ b/config/locales/valuation.es.yml @@ -24,6 +24,7 @@ es: valuating: En evaluación valuation_finished: Evaluación finalizada title: Propuestas de inversión + assigned_to: "Asignadas a %{valuator}" edit: Editar informe valuators_assigned: one: Evaluador asignado From 635de83f866eda6d97604764fef4c004c9e7d19c Mon Sep 17 00:00:00 2001 From: kikito Date: Wed, 4 Jan 2017 18:48:01 +0100 Subject: [PATCH 19/24] prints the right value in budgets table --- app/controllers/valuation/budgets_controller.rb | 8 +++++++- app/views/valuation/budgets/index.html.erb | 4 ++-- config/locales/valuation.en.yml | 2 +- config/locales/valuation.es.yml | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/valuation/budgets_controller.rb b/app/controllers/valuation/budgets_controller.rb index 0b7efe858..744b0d4bf 100644 --- a/app/controllers/valuation/budgets_controller.rb +++ b/app/controllers/valuation/budgets_controller.rb @@ -6,6 +6,12 @@ class Valuation::BudgetsController < Valuation::BaseController def index @budgets = @budgets.current.order(created_at: :desc).page(params[:page]) + @investments_with_valuation_open = {} + @budgets.each do |b| + @investments_with_valuation_open[b.id] = b.investments + .by_valuator(current_user.valuator.try(:id)) + .valuation_open + .count + end end - end diff --git a/app/views/valuation/budgets/index.html.erb b/app/views/valuation/budgets/index.html.erb index 4f2b7ffa6..5df21fc3e 100644 --- a/app/views/valuation/budgets/index.html.erb +++ b/app/views/valuation/budgets/index.html.erb @@ -7,7 +7,7 @@ <%= t("valuation.budgets.index.table_name") %> <%= t("valuation.budgets.index.table_phase") %> - <%= t("valuation.budgets.index.table_assigned_headings") %> + <%= t("valuation.budgets.index.table_assigned_investments_valuation_open") %> <%= t("valuation.budgets.index.table_actions") %> @@ -21,7 +21,7 @@ <%= t("budget.phase.#{budget.phase}") %> - 3 partidas + <%= @investments_with_valuation_open[budget.id] %> <%= link_to t("valuation.budgets.index.evaluate"), diff --git a/config/locales/valuation.en.yml b/config/locales/valuation.en.yml index b28446a77..de19fea09 100644 --- a/config/locales/valuation.en.yml +++ b/config/locales/valuation.en.yml @@ -13,7 +13,7 @@ en: finished: Finished table_name: Name table_phase: Phase - table_assigned_headings: Assigned headings + table_assigned_investments_valuation_open: Investment projects assigned with valuation open table_actions: Actions evaluate: Evaluate budget_investments: diff --git a/config/locales/valuation.es.yml b/config/locales/valuation.es.yml index b8a9d6a3f..b588c8521 100644 --- a/config/locales/valuation.es.yml +++ b/config/locales/valuation.es.yml @@ -13,7 +13,7 @@ es: finished: Terminados table_name: Nombre table_phase: Fase - table_assigned_headings: Partidas asignadas + table_assigned_investments_valuation_open: Prop. Inv. asignadas en evaluación table_actions: Acciones evaluate: Evaluar budget_investments: From a42c1387cfc96c4990ad3f39bf99fc6dfe6c9270 Mon Sep 17 00:00:00 2001 From: Alberto Garcia Cabeza Date: Wed, 4 Jan 2017 19:38:49 +0100 Subject: [PATCH 20/24] fixes specs --- spec/features/admin/budgets_spec.rb | 10 +++++----- spec/features/valuation/budget_investments_spec.rb | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 70e85378d..a23ff765f 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,7 +110,7 @@ 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 'No groups created yet.' @@ -124,7 +124,7 @@ feature 'Admin budgets' do expect(page).to_not have_content 'No groups created yet.' visit admin_budgets_path - click_link 'Yearly participatory budget' + click_link 'Edit budget' expect(page).to have_content 'Yearly participatory budget' expect(page).to_not have_content 'No groups created yet.' diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 627d6a391..ad68ee732 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -262,7 +262,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 +381,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' From 9e2afeb503abef61da8d4d04dc5223169297def7 Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 5 Jan 2017 11:26:46 +0100 Subject: [PATCH 21/24] removes deprecated spec (valuators are not shown in valuation table) --- .../valuation/budget_investments_spec.rb | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index ad68ee732..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) From 2a792a5499dcce6e98b455655082bc735e44f14b Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 5 Jan 2017 12:05:40 +0100 Subject: [PATCH 22/24] attempts to fix failing spec in travis --- spec/features/admin/budgets_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index a23ff765f..7a8658cdd 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -117,15 +117,17 @@ feature 'Admin budgets' do 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 '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 'Edit budget' + 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 From 5eec8c7da2065d494e52dbeaf7a5a649f41ae9aa Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 5 Jan 2017 12:32:36 +0100 Subject: [PATCH 23/24] attempts to fix travis again --- app/views/admin/budgets/_groups.html.erb | 2 +- config/locales/admin.en.yml | 4 +++- config/locales/admin.es.yml | 4 +++- spec/features/admin/budgets_spec.rb | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/views/admin/budgets/_groups.html.erb b/app/views/admin/budgets/_groups.html.erb index f5dde3aa1..537659fec 100644 --- a/app/views/admin/budgets/_groups.html.erb +++ b/app/views/admin/budgets/_groups.html.erb @@ -1,4 +1,4 @@ -

<%= t('admin.budgets.show.groups') %>

+

<%= t('admin.budgets.show.groups', count: groups.count) %>

<% if groups.blank? %>
<%= t("admin.budgets.form.no_groups") %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 4aec846cb..dadcb7745 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -82,7 +82,9 @@ en: new: title: New participatory budget show: - 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. diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index f79f76a17..09959cfde 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -82,7 +82,9 @@ es: new: title: Nuevo presupuesto ciudadano show: - 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. diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 7a8658cdd..27a15ad0f 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -113,6 +113,7 @@ feature 'Admin budgets' do 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' @@ -120,6 +121,7 @@ feature 'Admin budgets' do 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.' @@ -127,6 +129,7 @@ feature 'Admin budgets' do visit admin_budgets_path click_link 'Edit budget' + 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.' From 5f108944a89ebcea586beed8a6056af4f0e697d9 Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 5 Jan 2017 12:49:53 +0100 Subject: [PATCH 24/24] final attempt at fixing travis --- spec/features/admin/budgets_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 27a15ad0f..8f17c27d4 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -127,7 +127,9 @@ feature 'Admin budgets' do expect(page).to_not have_content 'No groups created yet.' visit admin_budgets_path - click_link 'Edit 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'