diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-05 18:08:48 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-05 18:08:48 +0300 |
commit | eabf8fd774fef6a54903e5141138f47bdafeb331 (patch) | |
tree | c74ff99fa6765cbe091767e9827374ce44b0df50 /app/models/sentry_issue.rb | |
parent | 20d564f1064622ef0623434372ac3ceb03173331 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/sentry_issue.rb')
-rw-r--r-- | app/models/sentry_issue.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/app/models/sentry_issue.rb b/app/models/sentry_issue.rb index 1325bce6c43..30f4026e633 100644 --- a/app/models/sentry_issue.rb +++ b/app/models/sentry_issue.rb @@ -5,13 +5,22 @@ class SentryIssue < ApplicationRecord validates :issue, uniqueness: true, presence: true validates :sentry_issue_identifier, presence: true + validate :ensure_sentry_issue_identifier_is_unique_per_project after_create_commit :enqueue_sentry_sync_job def self.for_project_and_identifier(project, identifier) joins(:issue) .where(issues: { project_id: project.id }) - .find_by_sentry_issue_identifier(identifier) + .where(sentry_issue_identifier: identifier) + .order('issues.created_at').last + end + + def ensure_sentry_issue_identifier_is_unique_per_project + if issue && self.class.for_project_and_identifier(issue.project, sentry_issue_identifier).present? + # Custom message because field is hidden + errors.add(:_, _('is already associated to a GitLab Issue. New issue will not be associated.')) + end end def enqueue_sentry_sync_job |