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

class MilestoneRelease < ApplicationRecord
  extend SuppressCompositePrimaryKeyWarning

  belongs_to :milestone
  belongs_to :release

  validate :same_project_between_milestone_and_release

  private

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

    return if milestone&.group_id

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

MilestoneRelease.prepend_mod_with('MilestoneRelease')