adds specs for budged model
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Budget do
|
||||
it "validates the phase" do
|
||||
budget = create(:budget)
|
||||
describe "phase" do
|
||||
let(:budget) { create(:budget) }
|
||||
|
||||
it "is validated" do
|
||||
Budget::VALID_PHASES.each do |phase|
|
||||
budget.phase = phase
|
||||
expect(budget).to be_valid
|
||||
@@ -11,5 +13,40 @@ describe Budget do
|
||||
budget.phase = 'inexisting'
|
||||
expect(budget).to_not be_valid
|
||||
end
|
||||
|
||||
it "produces auxiliary methods" do
|
||||
budget.phase = "on_hold"
|
||||
expect(budget).to be_on_hold
|
||||
|
||||
budget.phase = "accepting"
|
||||
expect(budget).to be_accepting
|
||||
|
||||
budget.phase = "selecting"
|
||||
expect(budget).to be_selecting
|
||||
|
||||
budget.phase = "balloting"
|
||||
expect(budget).to be_balloting
|
||||
|
||||
budget.phase = "finished"
|
||||
expect(budget).to be_finished
|
||||
end
|
||||
end
|
||||
|
||||
describe "heading_price" do
|
||||
let(:budget) { create(:budget, price: 1000) }
|
||||
|
||||
it "returns the budget price if no heading is provided" do
|
||||
expect(budget.heading_price(nil)).to eq(1000)
|
||||
end
|
||||
|
||||
it "returns the heading price if the heading provided is part of the budget" do
|
||||
heading = create(:budget_heading, price: 100, budget: budget)
|
||||
expect(budget.heading_price(heading)).to eq(100)
|
||||
end
|
||||
|
||||
it "returns -1 if the heading provided is not part of the budget" do
|
||||
expect(budget.heading_price(create(:budget_heading))).to eq(-1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user