diff options
Diffstat (limited to 'app/models/iteration.rb')
-rw-r--r-- | app/models/iteration.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/iteration.rb b/app/models/iteration.rb index 0b59cf047f7..3495f099064 100644 --- a/app/models/iteration.rb +++ b/app/models/iteration.rb @@ -4,6 +4,7 @@ class Iteration < ApplicationRecord self.table_name = 'sprints' attr_accessor :skip_future_date_validation + attr_accessor :skip_project_validation STATE_ENUM_MAP = { upcoming: 1, @@ -24,6 +25,7 @@ class Iteration < ApplicationRecord validate :dates_do_not_overlap, if: :start_or_due_dates_changed? validate :future_date, if: :start_or_due_dates_changed?, unless: :skip_future_date_validation + validate :no_project, unless: :skip_project_validation scope :upcoming, -> { with_state(:upcoming) } scope :started, -> { with_state(:started) } @@ -113,6 +115,12 @@ class Iteration < ApplicationRecord errors.add(:due_date, s_("Iteration|cannot be more than 500 years in the future")) if due_date > 500.years.from_now end end + + def no_project + return unless project_id.present? + + errors.add(:project_id, s_("is not allowed. We do not currently support project-level iterations")) + end end Iteration.prepend_if_ee('EE::Iteration') |