summaryrefslogtreecommitdiff
path: root/app/models/merge_request_assignee.rb
blob: 73f8fe77b044fc0620b15b7b2a3d0900bc2b2e72 (plain)
1
2
3
4
5
6
7
8
9
10
# frozen_string_literal: true

class MergeRequestAssignee < ApplicationRecord
  belongs_to :merge_request, touch: true
  belongs_to :assignee, class_name: "User", foreign_key: :user_id, inverse_of: :merge_request_assignees

  validates :assignee, uniqueness: { scope: :merge_request_id }

  scope :in_projects, ->(project_ids) { joins(:merge_request).where("merge_requests.target_project_id in (?)", project_ids) }
end