diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/models/event_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/models/event_spec.rb')
-rw-r--r-- | spec/models/event_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 96baeab6809..015a86cb28b 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -111,6 +111,45 @@ RSpec.describe Event do expect(found).not_to include(false_positive) end end + + describe '.for_fingerprint' do + let_it_be(:with_fingerprint) { create(:event, fingerprint: 'aaa') } + + before_all do + create(:event) + create(:event, fingerprint: 'bbb') + end + + it 'returns none if there is no fingerprint' do + expect(described_class.for_fingerprint(nil)).to be_empty + expect(described_class.for_fingerprint('')).to be_empty + end + + it 'returns none if there is no match' do + expect(described_class.for_fingerprint('not-found')).to be_empty + end + + it 'can find a given event' do + expect(described_class.for_fingerprint(with_fingerprint.fingerprint)) + .to contain_exactly(with_fingerprint) + end + end + end + + describe '#fingerprint' do + it 'is unique scoped to target' do + issue = create(:issue) + mr = create(:merge_request) + + expect { create_list(:event, 2, target: issue, fingerprint: '1234') } + .to raise_error(include('fingerprint')) + + expect do + create(:event, target: mr, fingerprint: 'abcd') + create(:event, target: issue, fingerprint: 'abcd') + create(:event, target: issue, fingerprint: 'efgh') + end.not_to raise_error + end end describe "Push event" do |