diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 18:06:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-16 18:06:17 +0300 |
commit | 00c78fb814d7ce00989ac04edd6cdaa3239da284 (patch) | |
tree | f04920f08eb4e481ce27bd1d96862676dff735dc /spec/models/note_spec.rb | |
parent | d2ffc30fd583e86d4122bb5061098f4f3ca7b3f1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r-- | spec/models/note_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 989024dee60..83c7464757f 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -981,4 +981,55 @@ describe Note do expect(note.parent).to be_nil end end + + describe 'scopes' do + let_it_be(:note1) { create(:note, note: 'Test 345') } + let_it_be(:note2) { create(:note, note: 'Test 789') } + + describe '#for_note_or_capitalized_note' do + it 'returns the expected matching note' do + notes = described_class.for_note_or_capitalized_note('Test 345') + + expect(notes.count).to eq(1) + expect(notes.first.id).to eq(note1.id) + end + + it 'returns the expected capitalized note' do + notes = described_class.for_note_or_capitalized_note('test 345') + + expect(notes.count).to eq(1) + expect(notes.first.id).to eq(note1.id) + end + + it 'does not support pattern matching' do + notes = described_class.for_note_or_capitalized_note('test%') + + expect(notes.count).to eq(0) + end + end + + describe '#like_note_or_capitalized_note' do + it 'returns the expected matching note' do + notes = described_class.like_note_or_capitalized_note('Test 345') + + expect(notes.count).to eq(1) + expect(notes.first.id).to eq(note1.id) + end + + it 'returns the expected capitalized note' do + notes = described_class.like_note_or_capitalized_note('test 345') + + expect(notes.count).to eq(1) + expect(notes.first.id).to eq(note1.id) + end + + it 'supports pattern matching' do + notes = described_class.like_note_or_capitalized_note('test%') + + expect(notes.count).to eq(2) + expect(notes.first.id).to eq(note1.id) + expect(notes.second.id).to eq(note2.id) + end + end + end end |