diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-05 15:08:48 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-05 15:08:48 +0000 |
commit | eabf8fd774fef6a54903e5141138f47bdafeb331 (patch) | |
tree | c74ff99fa6765cbe091767e9827374ce44b0df50 /spec/models/sentry_issue_spec.rb | |
parent | 20d564f1064622ef0623434372ac3ceb03173331 (diff) | |
download | gitlab-ce-eabf8fd774fef6a54903e5141138f47bdafeb331.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/sentry_issue_spec.rb')
-rw-r--r-- | spec/models/sentry_issue_spec.rb | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/spec/models/sentry_issue_spec.rb b/spec/models/sentry_issue_spec.rb index 022cfd4734e..b4c1cf57761 100644 --- a/spec/models/sentry_issue_spec.rb +++ b/spec/models/sentry_issue_spec.rb @@ -13,6 +13,20 @@ describe SentryIssue do it { is_expected.to validate_presence_of(:issue) } it { is_expected.to validate_uniqueness_of(:issue) } it { is_expected.to validate_presence_of(:sentry_issue_identifier) } + + it 'allows duplicated sentry_issue_identifier' do + duplicate_sentry_issue = build(:sentry_issue, sentry_issue_identifier: sentry_issue.sentry_issue_identifier) + + expect(duplicate_sentry_issue).to be_valid + end + + it 'validates uniqueness of sentry_issue_identifier per project' do + second_issue = create(:issue, project: sentry_issue.issue.project) + duplicate_sentry_issue = build(:sentry_issue, issue: second_issue, sentry_issue_identifier: sentry_issue.sentry_issue_identifier) + + expect(duplicate_sentry_issue).to be_invalid + expect(duplicate_sentry_issue.errors.full_messages.first).to include('is already associated') + end end describe 'callbacks' do @@ -28,13 +42,16 @@ describe SentryIssue do end describe '.for_project_and_identifier' do - let!(:sentry_issue) { create(:sentry_issue) } - let(:project) { sentry_issue.issue.project } - let(:identifier) { sentry_issue.sentry_issue_identifier } - let!(:second_sentry_issue) { create(:sentry_issue) } + it 'finds the most recent per project and sentry_issue_identifier' do + sentry_issue = create(:sentry_issue) + create(:sentry_issue) + project = sentry_issue.issue.project + sentry_issue_3 = build(:sentry_issue, issue: create(:issue, project: project), sentry_issue_identifier: sentry_issue.sentry_issue_identifier) + sentry_issue_3.save(validate: false) - subject { described_class.for_project_and_identifier(project, identifier) } + result = described_class.for_project_and_identifier(project, sentry_issue.sentry_issue_identifier) - it { is_expected.to eq(sentry_issue) } + expect(result).to eq(sentry_issue_3) + end end end |