gitlab-org--gitlab-foss/app/models/milestone_release.rb
Etienne Baqué a43ab8d6a4 Added relationships between Release and Milestone
Modified schema via migrations.
Added one-to-one relationship between the two models.
Added changelog file
2019-09-03 09:38:59 +00:00

17 lines
444 B
Ruby

# frozen_string_literal: true
class MilestoneRelease < ApplicationRecord
belongs_to :milestone
belongs_to :release
validates :milestone_id, uniqueness: { scope: [:release_id] }
validate :same_project_between_milestone_and_release
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