adds validation on feasible_explanation

This commit is contained in:
rgarcia
2016-04-21 14:07:41 +02:00
parent f3aafcb29e
commit 521172bc19
2 changed files with 13 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ class SpendingProposal < ActiveRecord::Base
validates :title, presence: true
validates :author, presence: true
validates :description, presence: true
validates_presence_of :feasible_explanation, if: :valuation_finished?
validates :title, length: { in: 4..SpendingProposal.title_max_length }
validates :description, length: { maximum: SpendingProposal.description_max_length }

View File

@@ -42,6 +42,18 @@ describe SpendingProposal do
end
end
describe "#feasible_explanation" do
it "should be valid if valuation not finished" do
spending_proposal.valuation_finished = false
expect(spending_proposal).to be_valid
end
it "should not be valid if valuation finished" do
spending_proposal.valuation_finished = true
expect(spending_proposal).to_not be_valid
end
end
describe "dossier info" do
describe "#feasibility" do
it "can be feasible" do