adds valuation status filtering to admin
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 without_valuators}, only: :index
|
||||
has_filters %w{all without_admin without_valuators valuating valuation_finished}, only: :index
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ class SpendingProposal < ActiveRecord::Base
|
||||
|
||||
scope :without_admin, -> { where(administrator_id: nil) }
|
||||
scope :without_valuators, -> { where(valuation_assignments_count: 0) }
|
||||
scope :valuating, -> { where("valuation_assignments_count > 0 AND valuation_finished = ?", false) }
|
||||
scope :valuation_finished, -> { where(valuation_finished: true) }
|
||||
|
||||
def description
|
||||
super.try :html_safe
|
||||
|
||||
@@ -143,6 +143,8 @@ en:
|
||||
all: All
|
||||
without_admin: Without assigned admin
|
||||
without_valuators: Without valuator
|
||||
valuating: Under valuation
|
||||
valuation_finished: Valuation finished
|
||||
title: Investment projects for participatory budgeting
|
||||
admin_assigned: Assigned administrator
|
||||
no_admin_assigned: No admin assigned
|
||||
|
||||
@@ -143,6 +143,8 @@ es:
|
||||
all: Todas
|
||||
without_admin: Sin administrador asignado
|
||||
without_valuators: Sin evaluador
|
||||
valuating: En evaluación
|
||||
valuation_finished: Evaluación finalizada
|
||||
title: Propuestas de inversión para presupuestos participativos
|
||||
admin_assigned: Administrador asignado
|
||||
no_admin_assigned: Sin admin asignado
|
||||
|
||||
@@ -80,24 +80,46 @@ 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')
|
||||
expect(page).to have_link('Under valuation')
|
||||
expect(page).to have_link('Valuation finished')
|
||||
|
||||
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')
|
||||
expect(page).to have_link('Under valuation')
|
||||
expect(page).to have_link('Valuation finished')
|
||||
|
||||
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')
|
||||
expect(page).to have_link('Under valuation')
|
||||
expect(page).to have_link('Valuation finished')
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'valuating')
|
||||
expect(page).to_not have_link('Under valuation')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Without assigned admin')
|
||||
expect(page).to have_link('Without valuator')
|
||||
expect(page).to have_link('Valuation finished')
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'valuation_finished')
|
||||
expect(page).to_not have_link('Valuation finished')
|
||||
expect(page).to have_link('All')
|
||||
expect(page).to have_link('Without assigned admin')
|
||||
expect(page).to have_link('Without valuator')
|
||||
expect(page).to have_link('Under valuation')
|
||||
|
||||
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')
|
||||
expect(page).to have_link('Under valuation')
|
||||
expect(page).to have_link('Valuation finished')
|
||||
end
|
||||
|
||||
scenario "Filtering proposals" do
|
||||
scenario "Index filtering by assignment status" do
|
||||
assigned = create(:spending_proposal, title: "Assigned idea", administrator: create(:administrator))
|
||||
valuating = create(:spending_proposal, title: "Evaluating...")
|
||||
valuating.valuators << create(:valuator)
|
||||
@@ -118,6 +140,28 @@ feature 'Admin spending proposals' do
|
||||
expect(page).to_not have_content("Evaluating...")
|
||||
end
|
||||
|
||||
scenario "Index filtering by valuation status" do
|
||||
valuating = create(:spending_proposal, title: "Ongoing valuation")
|
||||
valuated = create(:spending_proposal, title: "Old idea", valuation_finished: true)
|
||||
valuating.valuators << create(:valuator)
|
||||
valuated.valuators << create(:valuator)
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'all')
|
||||
|
||||
expect(page).to have_content("Ongoing valuation")
|
||||
expect(page).to have_content("Old idea")
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'valuating')
|
||||
|
||||
expect(page).to have_content("Ongoing valuation")
|
||||
expect(page).to_not have_content("Old idea")
|
||||
|
||||
visit admin_spending_proposals_path(filter: 'valuation_finished')
|
||||
|
||||
expect(page).to_not have_content("Ongoing valuation")
|
||||
expect(page).to have_content("Old idea")
|
||||
end
|
||||
|
||||
scenario 'Show' do
|
||||
administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org'))
|
||||
valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org'))
|
||||
|
||||
@@ -87,6 +87,38 @@ describe SpendingProposal do
|
||||
expect(without_admin.first).to eq(spending_proposal2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "valuating" do
|
||||
it "should return all spending proposals with assigned valuator but valuation not finished" do
|
||||
spending_proposal1 = create(:spending_proposal)
|
||||
spending_proposal2 = create(:spending_proposal)
|
||||
spending_proposal3 = create(:spending_proposal, valuation_finished: true)
|
||||
|
||||
spending_proposal2.valuators << create(:valuator)
|
||||
spending_proposal3.valuators << create(:valuator)
|
||||
|
||||
without_admin = SpendingProposal.valuating
|
||||
|
||||
expect(without_admin.size).to eq(1)
|
||||
expect(without_admin.first).to eq(spending_proposal2)
|
||||
end
|
||||
end
|
||||
|
||||
describe "valuation_finished" do
|
||||
it "should return all spending proposals with valuation finished" do
|
||||
spending_proposal1 = create(:spending_proposal)
|
||||
spending_proposal2 = create(:spending_proposal)
|
||||
spending_proposal3 = create(:spending_proposal, valuation_finished: true)
|
||||
|
||||
spending_proposal2.valuators << create(:valuator)
|
||||
spending_proposal3.valuators << create(:valuator)
|
||||
|
||||
without_admin = SpendingProposal.valuation_finished
|
||||
|
||||
expect(without_admin.size).to eq(1)
|
||||
expect(without_admin.first).to eq(spending_proposal3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user