adds scopes for feasible values to spending props
This commit is contained in:
committed by
Juanjo Bazán
parent
a14cc1a575
commit
63e8950d6c
@@ -65,8 +65,7 @@ module CommentableActions
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def map
|
||||||
def map
|
|
||||||
@resource = resource_model.new
|
@resource = resource_model.new
|
||||||
@tag_cloud = tag_cloud
|
@tag_cloud = tag_cloud
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ class SpendingProposal < ActiveRecord::Base
|
|||||||
scope :managed, -> { valuation_open.where(valuation_assignments_count: 0).where("administrator_id IS NOT ?", nil) }
|
scope :managed, -> { valuation_open.where(valuation_assignments_count: 0).where("administrator_id IS NOT ?", nil) }
|
||||||
scope :valuating, -> { valuation_open.where("valuation_assignments_count > 0 AND valuation_finished = ?", false) }
|
scope :valuating, -> { valuation_open.where("valuation_assignments_count > 0 AND valuation_finished = ?", false) }
|
||||||
scope :valuation_finished, -> { where(valuation_finished: true) }
|
scope :valuation_finished, -> { where(valuation_finished: true) }
|
||||||
|
scope :feasible, -> { where(feasible: true) }
|
||||||
|
scope :unfeasible, -> { where(feasible: false) }
|
||||||
|
scope :not_unfeasible, -> { where("feasible IS ? OR feasible = ?", nil, true) }
|
||||||
|
|
||||||
scope :by_admin, -> (admin) { where(administrator_id: admin.presence) }
|
scope :by_admin, -> (admin) { where(administrator_id: admin.presence) }
|
||||||
scope :by_tag, -> (tag_name) { tagged_with(tag_name) }
|
scope :by_tag, -> (tag_name) { tagged_with(tag_name) }
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
<section class="row-full comments">
|
<section class="row-full comments">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="comments" class="small-12 column">
|
<div id="comments" class="small-12 column">
|
||||||
|
|
||||||
<h2>
|
<h2>
|
||||||
<%= t("proposals.show.comments_title") %>
|
<%= t("proposals.show.comments_title") %>
|
||||||
<span class="js-comments-count">(<%= @proposal.comments_count %>)</span>
|
<span class="js-comments-count">(<%= @proposal.comments_count %>)</span>
|
||||||
|
|||||||
@@ -227,6 +227,38 @@ describe SpendingProposal do
|
|||||||
expect(valuation_finished.first).to eq(spending_proposal3)
|
expect(valuation_finished.first).to eq(spending_proposal3)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "feasible" do
|
||||||
|
it "should return all feasible spending proposals" do
|
||||||
|
feasible_spending_proposal = create(:spending_proposal, feasible: true)
|
||||||
|
create(:spending_proposal)
|
||||||
|
|
||||||
|
expect(SpendingProposal.feasible).to eq [feasible_spending_proposal]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "unfeasible" do
|
||||||
|
it "should return all unfeasible spending proposals" do
|
||||||
|
unfeasible_spending_proposal = create(:spending_proposal, feasible: false)
|
||||||
|
create(:spending_proposal, feasible: true)
|
||||||
|
|
||||||
|
expect(SpendingProposal.unfeasible).to eq [unfeasible_spending_proposal]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "not_unfeasible" do
|
||||||
|
it "should return all not unfeasible spending proposals" do
|
||||||
|
not_unfeasible_spending_proposal_1 = create(:spending_proposal, feasible: true)
|
||||||
|
not_unfeasible_spending_proposal_2 = create(:spending_proposal)
|
||||||
|
create(:spending_proposal, feasible: false)
|
||||||
|
|
||||||
|
not_unfeasibles = SpendingProposal.not_unfeasible
|
||||||
|
|
||||||
|
expect(not_unfeasibles.size).to eq(2)
|
||||||
|
expect(not_unfeasibles.include?(not_unfeasible_spending_proposal_1)).to eq(true)
|
||||||
|
expect(not_unfeasibles.include?(not_unfeasible_spending_proposal_2)).to eq(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user