Skip to content

Commit

Permalink
Merge pull request #3314 from consul/backport-without_valuator
Browse files Browse the repository at this point in the history
Consider having valuator group as having valuator
  • Loading branch information
javierm committed Feb 19, 2019
2 parents 44483c2 + bd67fcb commit 7c61f62
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/models/budget/investment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class Investment < ActiveRecord::Base

scope :valuation_open, -> { where(valuation_finished: false) }
scope :without_admin, -> { valuation_open.where(administrator_id: nil) }
scope :without_valuator, -> { valuation_open.where(valuator_assignments_count: 0) }
scope :without_valuator_group, -> { where(valuator_group_assignments_count: 0) }
scope :without_valuator, -> { valuation_open.without_valuator_group.where(valuator_assignments_count: 0) }
scope :under_valuation, -> { valuation_open.valuating.where("administrator_id IS NOT ?", nil) }
scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).where("administrator_id IS NOT ?", nil) }
scope :valuating, -> { valuation_open.where("valuator_assignments_count > 0 OR valuator_group_assignments_count > 0" ) }
Expand Down
17 changes: 14 additions & 3 deletions spec/features/admin/budget_investments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,19 +270,30 @@
end

scenario "Filtering by assignment status" do
assigned = create(:budget_investment, title: "Assigned idea", budget: budget, administrator: create(:administrator))
valuating = create(:budget_investment, title: "Evaluating...", budget: budget)
valuating.valuators.push(create(:valuator))
create(:budget_investment, title: "Assigned idea", budget: budget,
administrator: create(:administrator))
create(:budget_investment, title: "Evaluating...", budget: budget,
valuators: [create(:valuator)])
create(:budget_investment, title: "With group", budget: budget,
valuator_groups: [create(:valuator_group)])

visit admin_budget_budget_investments_path(budget_id: budget.id, filter: "valuation_open")

expect(page).to have_content("Assigned idea")
expect(page).to have_content("Evaluating...")
expect(page).to have_content("With group")

visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'without_admin')

expect(page).to have_content("Evaluating...")
expect(page).to have_content("With group")
expect(page).not_to have_content("Assigned idea")

visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'without_valuator')

expect(page).to have_content("Assigned idea")
expect(page).not_to have_content("Evaluating...")
expect(page).not_to have_content("With group")
end

scenario "Filtering by valuation status" do
Expand Down

0 comments on commit 7c61f62

Please sign in to comment.