diff --git a/app/views/admin/spending_proposals/index.html.erb b/app/views/admin/spending_proposals/index.html.erb index f50dea628..a4a1a68c6 100644 --- a/app/views/admin/spending_proposals/index.html.erb +++ b/app/views/admin/spending_proposals/index.html.erb @@ -9,6 +9,15 @@ label: false, class: "js-submit-on-change" } %> + +
+ <%= select_tag :valuator_id, + options_for_select(valuator_select_options, params[:valuator_id]), + { prompt: t("admin.spending_proposals.index.valuator_filter_all"), + label: false, + class: "js-submit-on-change" } %> +
+
<%= select_tag :geozone_id, options_for_select(geozone_select_options.unshift([t("geozones.none"), "all"]), params[:geozone_id]), diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 33d3c8434..3c4c2f24e 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -155,6 +155,7 @@ en: index: geozone_filter_all: All zones administrator_filter_all: All administrators + valuator_filter_all: All valuators tags_filter_all: All tags filters: valuation_open: Open diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index ec0fa5483..5d7017336 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -155,6 +155,7 @@ es: index: geozone_filter_all: Todos los ámbitos de actuación administrator_filter_all: Todos los administradores + valuator_filter_all: Todos los evaluadores tags_filter_all: Todas las etiquetas filters: valuation_open: Abiertas diff --git a/spec/features/admin/spending_proposals_spec.rb b/spec/features/admin/spending_proposals_spec.rb index fcfec8638..a14ff0316 100644 --- a/spec/features/admin/spending_proposals_spec.rb +++ b/spec/features/admin/spending_proposals_spec.rb @@ -143,6 +143,52 @@ feature 'Admin spending proposals' do end + scenario "Filtering by valuator", :js do + user = create(:user, username: 'Valuator 1') + valuator = create(:valuator, user: user) + + spending_proposal = create(:spending_proposal, title: "Realocate visitors") + spending_proposal.valuators << valuator + + create(:spending_proposal, title: "Destroy the city") + + visit admin_spending_proposals_path + expect(page).to have_link("Realocate visitors") + expect(page).to have_link("Destroy the city") + + select "Valuator 1", from: "valuator_id" + + expect(page).to have_content('There is 1 spending proposal') + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + + select "All valuators", from: "valuator_id" + + expect(page).to have_content('There are 2 spending proposals') + expect(page).to have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + + select "Valuator 1", from: "valuator_id" + expect(page).to have_content('There is 1 spending proposal') + click_link("Realocate visitors") + click_link("Back") + + expect(page).to have_content('There is 1 spending proposal') + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + + click_link("Realocate visitors") + click_on("Edit classification") + expect(page).to have_button("Update") + click_on("Back") + expect(page).to_not have_button("Update") + click_on("Back") + + expect(page).to have_content('There is 1 spending proposal') + expect(page).to_not have_link("Destroy the city") + expect(page).to have_link("Realocate visitors") + end + scenario "Current filter is properly highlighted" do filters_links = {'valuation_open' => 'Open', 'without_admin' => 'Without assigned admin',