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/note_spec.rb | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r-- | spec/models/note_spec.rb | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index e6e6a8c35cf..7edd7849bbe 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -471,6 +471,7 @@ RSpec.describe Note do note: "added label #{private_label.to_reference(ext_proj)}", system: true end + let!(:system_note_metadata) { create(:system_note_metadata, note: note, action: :label) } it_behaves_like "checks references" @@ -1372,11 +1373,11 @@ RSpec.describe Note do describe 'banzai_render_context' do let(:project) { build(:project_empty_repo) } + subject(:context) { noteable.banzai_render_context(:title) } + context 'when noteable is a merge request' do let(:noteable) { build :merge_request, target_project: project, source_project: project } - subject(:context) { noteable.banzai_render_context(:title) } - it 'sets the label_url_method in the context' do expect(context[:label_url_method]).to eq(:project_merge_requests_url) end @@ -1385,11 +1386,34 @@ RSpec.describe Note do context 'when noteable is an issue' do let(:noteable) { build :issue, project: project } - subject(:context) { noteable.banzai_render_context(:title) } - it 'sets the label_url_method in the context' do expect(context[:label_url_method]).to eq(:project_issues_url) end end + + context 'when noteable is a personal snippet' do + let(:noteable) { build(:personal_snippet) } + + it 'sets the parent user in the context' do + expect(context[:user]).to eq(noteable.author) + end + end + end + + describe '#parent_user' do + it 'returns the author of a personal snippet' do + note = build(:note_on_personal_snippet) + expect(note.parent_user).to eq(note.noteable.author) + end + + it 'returns nil for project snippet' do + note = build(:note_on_project_snippet) + expect(note.parent_user).to be_nil + end + + it 'returns nil when noteable is not a snippet' do + note = build(:note_on_issue) + expect(note.parent_user).to be_nil + end end end |