Refactor budget's phase max description lenght from Budget to Phase model

This commit is contained in:
Bertocq
2018-01-15 19:55:41 +01:00
parent 36e74d0ef2
commit f2228a908b
3 changed files with 3 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
class Budget
class Phase < ActiveRecord::Base
DESCRIPTION_MAX_LENGTH = 2000
belongs_to :budget
belongs_to :next_phase, class_name: 'Budget::Phase', foreign_key: :next_phase_id
@@ -7,7 +8,7 @@ class Budget
validates :budget, presence: true
validates :kind, presence: true, uniqueness: { scope: :budget }, inclusion: { in: Budget::PHASES }
validates :description, length: { maximum: Budget.description_max_length }
validates :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
validate :dates_range_valid?
scope :enabled, -> { where(enabled: true) }