adds validation for price when investment is feasible

This commit is contained in:
Juanjo Bazán
2017-03-27 13:14:26 +02:00
parent 772656cf0b
commit 3c2ab9fb05
2 changed files with 29 additions and 1 deletions

View File

@@ -25,6 +25,7 @@ class Budget
validates :description, presence: true
validates :heading_id, presence: true
validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required?
validates_presence_of :price, if: :price_required?
validates :title, length: { in: 4..Budget::Investment.title_max_length }
validates :description, length: { maximum: Budget::Investment.description_max_length }
@@ -136,6 +137,10 @@ class Budget
unfeasible? && valuation_finished?
end
def price_required?
feasible? && valuation_finished?
end
def unfeasible_email_pending?
unfeasible_email_sent_at.blank? && unfeasible? && valuation_finished?
end