adds without_validators filter
This commit is contained in:
@@ -2,7 +2,7 @@ class Admin::SpendingProposalsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
feature_flag :spending_proposals
|
||||
|
||||
has_filters %w{all without_admin}, only: :index
|
||||
has_filters %w{all without_admin without_valuators}, only: :index
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class SpendingProposal < ActiveRecord::Base
|
||||
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
|
||||
|
||||
scope :without_admin, -> { where(administrator_id: nil) }
|
||||
scope :without_valuators, -> { where(valuation_assignments_count: 0) }
|
||||
|
||||
def description
|
||||
super.try :html_safe
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<h2><%= t("admin.spending_proposals.index.title") %></h2>
|
||||
|
||||
<div class="small-12 medium-4 column right">
|
||||
<%= form_tag current_path_with_query_params(page: 1), method: :get, enforce_utf8: false do %>
|
||||
<%= form_tag admin_spending_proposals_path, method: :get, enforce_utf8: false do %>
|
||||
<%= select_tag :geozone_id, options_for_select(geozone_select_options.unshift([t("geozones.none"), "all"]), params[:geozone_id]),
|
||||
{ prompt: t("admin.spending_proposals.index.geozone_filter_all"),
|
||||
label: false,
|
||||
|
||||
@@ -142,6 +142,7 @@ en:
|
||||
filters:
|
||||
all: All
|
||||
without_admin: Without assigned admin
|
||||
without_valuators: Without valuator
|
||||
title: Investment projects for participatory budgeting
|
||||
admin_assigned: Assigned administrator
|
||||
no_admin_assigned: No admin assigned
|
||||
|
||||
@@ -142,6 +142,7 @@ es:
|
||||
filters:
|
||||
all: Todas
|
||||
without_admin: Sin administrador asignado
|
||||
without_valuators: Sin evaluador
|
||||
title: Propuestas de inversión para presupuestos participativos
|
||||
admin_assigned: Administrador asignado
|
||||
no_admin_assigned: Sin admin asignado
|
||||
|
||||
@@ -55,29 +55,43 @@ feature 'Admin spending proposals' do
|
||||
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Without assigned admin')
|
||||
expect(page).to have_link('Without valuator')
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'without_admin')
|
||||
expect(page).to_not have_link('Without assigned admin')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Without valuator')
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'without_valuators')
|
||||
expect(page).to_not have_link('Without valuator')
|
||||
expect(page).to have_link('Without assigned admin')
|
||||
expect(page).to have_link('All')
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'all')
|
||||
expect(page).to_not have_link('All')
|
||||
expect(page).to have_link('Without assigned admin')
|
||||
expect(page).to have_link('Without valuator')
|
||||
end
|
||||
|
||||
scenario "Filtering proposals" do
|
||||
create(:spending_proposal, title: "New idea")
|
||||
assigned = create(:spending_proposal, title: "Assigned idea", administrator: create(:administrator))
|
||||
valuating = create(:spending_proposal, title: "Evaluating...")
|
||||
valuating.valuators << create(:valuator)
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'all')
|
||||
|
||||
expect(page).to have_content("New idea")
|
||||
expect(page).to have_content("Assigned idea")
|
||||
expect(page).to have_content("Evaluating...")
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'without_admin')
|
||||
|
||||
expect(page).to have_content("New idea")
|
||||
expect(page).to have_content("Evaluating...")
|
||||
expect(page).to_not have_content("Assigned idea")
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'without_valuators')
|
||||
|
||||
expect(page).to have_content("Assigned idea")
|
||||
expect(page).to_not have_content("Evaluating...")
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
|
||||
@@ -74,6 +74,19 @@ describe SpendingProposal do
|
||||
expect(without_admin.first).to eq(spending_proposal1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "without_valuators" do
|
||||
it "should return all spending proposals without assigned valuators" do
|
||||
spending_proposal1 = create(:spending_proposal)
|
||||
spending_proposal2 = create(:spending_proposal)
|
||||
spending_proposal1.valuators << create(:valuator)
|
||||
|
||||
without_admin = SpendingProposal.without_valuators
|
||||
|
||||
expect(without_admin.size).to eq(1)
|
||||
expect(without_admin.first).to eq(spending_proposal2)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user