Skip to content

Commit

Permalink
Merge pull request consuldemocracy#1404 from AyuntamientoMadrid/upstream
Browse files Browse the repository at this point in the history
Upstream
  • Loading branch information
voodoorai2000 committed Apr 4, 2018
2 parents 9bff8de + 05d56ec commit 278c4b4
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ GEM
actionmailer (>= 3.2)
letter_opener (~> 1.0)
railties (>= 3.2)
loofah (2.1.1)
loofah (2.2.2)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.7.0)
Expand Down Expand Up @@ -344,8 +344,8 @@ GEM
activesupport (>= 4.2.0, < 5.0)
nokogiri (~> 1.6)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-html-sanitizer (1.0.4)
loofah (~> 2.2, >= 2.2.2)
railties (4.2.10)
actionpack (= 4.2.10)
activesupport (= 4.2.10)
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/admin/budget_investments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
valuation_finished winners},
only: [:index, :toggle_selection])

has_orders %w{oldest}, only: [:show, :edit]

before_action :load_budget
before_action :load_investment, only: [:show, :edit, :update, :toggle_selection]
before_action :load_ballot, only: [:show, :index]
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/users/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update).push(:email)
end

def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update).push(:email)
end

def erase_params
params.require(:user).permit(:erase_reason)
end
Expand Down
5 changes: 5 additions & 0 deletions app/helpers/valuation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ def valuator_group_select_options
ValuatorGroup.order("name ASC").collect { |g| [ g.name, "group_#{g.id}"] }
end

def assigned_valuators(investment)
[investment.valuator_groups.collect(&:name) +
investment.valuators.collect(&:description_or_name)].flatten.join(', ')
end

def assigned_valuators_info(valuators)
case valuators.size
when 0
Expand Down
1 change: 1 addition & 0 deletions app/models/abilities/valuator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def initialize(user)
valuator = user.valuator

can [:read], SpendingProposal

can [:read, :update, :comment_valuation], Budget::Investment, id: valuator.assigned_investment_ids
can [:valuate], Budget::Investment, { id: valuator.assigned_investment_ids, valuation_finished: false }
cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: 'finished' }
Expand Down
1 change: 0 additions & 1 deletion app/views/admin/budget_investments/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<h2 class="inline-block"><%= @budget.name %> - <%= t("admin.budget_investments.index.title") %></h2>

<%= render "search_form" %>
<%= render "/shared/filter_subnav", i18n_namespace: "admin.budget_investments.index" %>

<div id="investments">
Expand Down
1 change: 1 addition & 0 deletions config/locales/en/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ en:
documents: "Documents"
see_documents: "See documents (%{count})"
no_documents: "Without documents"
valuator_groups: "Valuator Groups"
edit:
classification: Classification
compatibility: Compatibility
Expand Down
1 change: 1 addition & 0 deletions config/locales/es/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ es:
documents: "Documentos"
see_documents: "Ver documentos (%{count})"
no_documents: "Sin documentos"
valuator_groups: "Grupos de evaluadores"
edit:
classification: Clasificación
compatibility: Compatibilidad
Expand Down
31 changes: 30 additions & 1 deletion spec/features/admin/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,33 @@
end
end

scenario 'Display valuator group assignments' do
budget_investment1 = create(:budget_investment, budget: budget)
budget_investment2 = create(:budget_investment, budget: budget)
budget_investment3 = create(:budget_investment, budget: budget)

health_group = create(:valuator_group, name: "Health")
culture_group = create(:valuator_group, name: "Culture")

budget_investment1.valuator_groups << health_group
budget_investment2.valuator_group_ids = [health_group.id, culture_group.id]

visit admin_budget_budget_investments_path(budget_id: budget)

within("#budget_investment_#{budget_investment1.id}") do
expect(page).to have_content("Health")
end

within("#budget_investment_#{budget_investment2.id}") do
expect(page).to have_content("Health")
expect(page).to have_content("Culture")
end

within("#budget_investment_#{budget_investment3.id}") do
expect(page).to have_content("No valuators assigned")
end
end

scenario "Filtering by budget heading", :js do
group1 = create(:budget_group, name: "Streets", budget: budget)
group2 = create(:budget_group, name: "Parks", budget: budget)
Expand Down Expand Up @@ -237,6 +264,7 @@

select "Valuator 1", from: "valuator_or_group_id"
click_button 'Filter'

expect(page).to have_content('There is 1 investment')
expect(page).not_to have_link("Destroy the city")
expect(page).to have_link("Realocate visitors")
Expand All @@ -253,7 +281,8 @@
budget_investment2 = create(:budget_investment, title: "Build a theatre", budget: budget)
budget_investment2.valuator_groups << culture_group

visit admin_budget_budget_investments_path(budget_id: budget.id)
visit admin_budget_budget_investments_path(budget_id: budget)

expect(page).to have_link("Build a hospital")
expect(page).to have_link("Build a theatre")

Expand Down

0 comments on commit 278c4b4

Please sign in to comment.