diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/models/note_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r-- | spec/models/note_spec.rb | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 6e87ca6dcf7..364b80e8601 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -837,6 +837,16 @@ RSpec.describe Note do end end + describe '#for_project_snippet?' do + it 'returns true for a project snippet note' do + expect(build(:note_on_project_snippet).for_project_snippet?).to be true + end + + it 'returns false for a personal snippet note' do + expect(build(:note_on_personal_snippet).for_project_snippet?).to be false + end + end + describe '#for_personal_snippet?' do it 'returns false for a project snippet note' do expect(build(:note_on_project_snippet).for_personal_snippet?).to be_falsy @@ -890,35 +900,31 @@ RSpec.describe Note do describe '#cache_markdown_field' do let(:html) { '<p>some html</p>'} + before do + allow(Banzai::Renderer).to receive(:cacheless_render_field).and_call_original + end + context 'note for a project snippet' do let(:snippet) { create(:project_snippet) } - let(:note) { build(:note_on_project_snippet, project: snippet.project, noteable: snippet) } + let(:note) { create(:note_on_project_snippet, project: snippet.project, noteable: snippet) } - before do + it 'skips project check' do expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: false }).and_return(html) - - note.save - end + .with(note, :note, { skip_project_check: false }) - it 'creates a note' do - expect(note.note_html).to eq(html) + note.update!(note: html) end end context 'note for a personal snippet' do let(:snippet) { create(:personal_snippet) } - let(:note) { build(:note_on_personal_snippet, noteable: snippet) } + let(:note) { create(:note_on_personal_snippet, noteable: snippet) } - before do + it 'does not skip project check' do expect(Banzai::Renderer).to receive(:cacheless_render_field) - .with(note, :note, { skip_project_check: true }).and_return(html) - - note.save - end + .with(note, :note, { skip_project_check: true }) - it 'creates a note' do - expect(note.note_html).to eq(html) + note.update!(note: html) end end end |