summaryrefslogtreecommitdiff
path: root/app/models/milestone_release.rb
blob: f7127df339dc09d8cc71b8a61ac0358a9fd0a97f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class MilestoneRelease < ApplicationRecord
  belongs_to :milestone
  belongs_to :release

  validate :same_project_between_milestone_and_release

  # Keep until 2019-11-29
  self.ignored_columns += %i[id]

  private

  def same_project_between_milestone_and_release
    return if milestone&.project_id == release&.project_id

    errors.add(:base, 'does not have the same project as the milestone')
  end
end