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

class GroupGroupLink < ApplicationRecord
  include Expirable

  belongs_to :shared_group, class_name: 'Group', foreign_key: :shared_group_id
  belongs_to :shared_with_group, class_name: 'Group', foreign_key: :shared_with_group_id

  validates :shared_group, presence: true
  validates :shared_group_id, uniqueness: { scope: [:shared_with_group_id],
                                            message: _('The group has already been shared with this group') }
  validates :shared_with_group, presence: true
  validates :group_access, inclusion: { in: Gitlab::Access.values },
                           presence: true

  def self.access_options
    Gitlab::Access.options
  end

  def self.default_access
    Gitlab::Access::DEVELOPER
  end
end