2019-09-03 05:38:59 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class MilestoneRelease < ApplicationRecord
|
2021-01-27 07:09:01 -05:00
|
|
|
extend SuppressCompositePrimaryKeyWarning
|
|
|
|
|
2019-09-03 05:38:59 -04:00
|
|
|
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
|
|
|
|
|
2020-10-18 20:08:50 -04:00
|
|
|
return if milestone&.group_id
|
|
|
|
|
2020-03-03 04:07:54 -05:00
|
|
|
errors.add(:base, _('Release does not have the same project as the milestone'))
|
2019-09-03 05:38:59 -04:00
|
|
|
end
|
|
|
|
end
|
2020-10-18 20:08:50 -04:00
|
|
|
|
|
|
|
MilestoneRelease.prepend_if_ee('EE::MilestoneRelease')
|