summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2017-11-21 14:49:07 +0000
committerSean McGivern <sean@mcgivern.me.uk>2017-11-21 14:49:07 +0000
commitf562e69eab0d7bac8ea20d29c3df981289dd8cdb (patch)
tree9a4a9849c0e9e6bc833cf4e2d6ca801adf7c2887 /spec
parent9024875e1f81a3aab3c0879d33a4cea912ce833d (diff)
parentc900c21eef9235306d7d0da42b07aa2de346e263 (diff)
downloadgitlab-ce-f562e69eab0d7bac8ea20d29c3df981289dd8cdb.tar.gz
Merge branch '39461-notes-api-for-issues-no-longer-returns-label-additions-removals' into 'master'
Resolve "Notes API for issues no longer returns label additions/removals" Closes #39461 See merge request gitlab-org/gitlab-ce!15080
Diffstat (limited to 'spec')
-rw-r--r--spec/models/note_spec.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 1ecb50586c7..6e7e8c4c570 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -231,6 +231,37 @@ describe Note do
end
end
+ describe '#cross_reference?' do
+ it 'falsey for user-generated notes' do
+ note = create(:note, system: false)
+
+ expect(note.cross_reference?).to be_falsy
+ end
+
+ context 'when the note might contain cross references' do
+ SystemNoteMetadata::TYPES_WITH_CROSS_REFERENCES.each do |type|
+ let(:note) { create(:note, :system) }
+ let!(:metadata) { create(:system_note_metadata, note: note, action: type) }
+
+ it 'delegates to the cross-reference regex' do
+ expect(note).to receive(:matches_cross_reference_regex?).and_return(false)
+
+ note.cross_reference?
+ end
+ end
+ end
+
+ context 'when the note cannot contain cross references' do
+ let(:commit_note) { build(:note, note: 'mentioned in 1312312313 something else.', system: true) }
+ let(:label_note) { build(:note, note: 'added ~2323232323', system: true) }
+
+ it 'scan for a `mentioned in` prefix' do
+ expect(commit_note.cross_reference?).to be_truthy
+ expect(label_note.cross_reference?).to be_falsy
+ end
+ end
+ end
+
describe 'clear_blank_line_code!' do
it 'clears a blank line code before validation' do
note = build(:note, line_code: ' ')