Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/customer_relations/issue_contact.rb')
-rw-r--r--app/models/customer_relations/issue_contact.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/models/customer_relations/issue_contact.rb b/app/models/customer_relations/issue_contact.rb
new file mode 100644
index 00000000000..98faf8d6644
--- /dev/null
+++ b/app/models/customer_relations/issue_contact.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class CustomerRelations::IssueContact < ApplicationRecord
+ self.table_name = "issue_customer_relations_contacts"
+
+ belongs_to :issue, optional: false, inverse_of: :customer_relations_contacts
+ belongs_to :contact, optional: false, inverse_of: :issue_contacts
+
+ validate :contact_belongs_to_issue_group
+
+ private
+
+ def contact_belongs_to_issue_group
+ return unless contact&.group_id
+ return unless issue&.project&.namespace_id
+ return if contact.group_id == issue.project.namespace_id
+
+ errors.add(:base, _('The contact does not belong to the same group as the issue'))
+ end
+end