Merge branch 'master' into feature/budget_phases

This commit is contained in:
BertoCQ
2018-01-16 17:47:47 +01:00
committed by GitHub
26 changed files with 166 additions and 76 deletions

View File

@@ -118,6 +118,43 @@ describe Budget do
end
end
describe "#current" do
it "returns nil if there is only one budget and it is still in drafting phase" do
budget = create(:budget, phase: "drafting")
expect(Budget.current).to eq(nil)
end
it "returns the budget if there is only one and not in drafting phase" do
budget = create(:budget, phase: "accepting")
expect(Budget.current).to eq(budget)
end
it "returns the last budget created that is not in drafting phase" do
old_budget = create(:budget, phase: "finished", created_at: 2.years.ago)
previous_budget = create(:budget, phase: "accepting", created_at: 1.year.ago)
current_budget = create(:budget, phase: "accepting", created_at: 1.month.ago)
next_budget = create(:budget, phase: "drafting", created_at: 1.week.ago)
expect(Budget.current).to eq(current_budget)
end
end
describe "#open" do
it "returns all budgets that are not in the finished phase" do
phases = Budget::PHASES - ["finished"]
phases.each do |phase|
budget = create(:budget, phase: phase)
expect(Budget.open).to include(budget)
end
end
end
describe "heading_price" do
let(:group) { create(:budget_group, budget: budget) }