adds balloting_or_later? method to Budget

This commit is contained in:
Juanjo Bazán
2017-05-09 17:27:58 +02:00
parent ea3057bc04
commit 33e8ebf043
2 changed files with 50 additions and 0 deletions

View File

@@ -67,6 +67,10 @@ class Budget < ActiveRecord::Base
phase == "finished" phase == "finished"
end end
def balloting_or_later?
balloting? || reviewing_ballots? || finished?
end
def on_hold? def on_hold?
reviewing? || valuating? || reviewing_ballots? reviewing? || valuating? || reviewing_ballots?
end end

View File

@@ -49,6 +49,52 @@ describe Budget do
budget.phase = "finished" budget.phase = "finished"
expect(budget).to be_finished expect(budget).to be_finished
end end
it "on_hold?" do
budget.phase = "accepting"
expect(budget).to_not be_on_hold
budget.phase = "reviewing"
expect(budget).to be_on_hold
budget.phase = "selecting"
expect(budget).to_not be_on_hold
budget.phase = "valuating"
expect(budget).to be_on_hold
budget.phase = "balloting"
expect(budget).to_not be_on_hold
budget.phase = "reviewing_ballots"
expect(budget).to be_on_hold
budget.phase = "finished"
expect(budget).to_not be_on_hold
end
it "balloting_or_later?" do
budget.phase = "accepting"
expect(budget).to_not be_balloting_or_later
budget.phase = "reviewing"
expect(budget).to_not be_balloting_or_later
budget.phase = "selecting"
expect(budget).to_not be_balloting_or_later
budget.phase = "valuating"
expect(budget).to_not be_balloting_or_later
budget.phase = "balloting"
expect(budget).to be_balloting_or_later
budget.phase = "reviewing_ballots"
expect(budget).to be_balloting_or_later
budget.phase = "finished"
expect(budget).to be_balloting_or_later
end
end end
describe "heading_price" do describe "heading_price" do