summaryrefslogtreecommitdiff
path: root/spec/models/note_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-14 15:10:05 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-14 15:10:05 +0000
commit654daa2ccbf58f9f36d94bfafcaea323e350ccd3 (patch)
tree7de886a951c6fe86db3b60fe36708b5656e8d85e /spec/models/note_spec.rb
parenta42fc481401fd6c4900b79125c446c7e4c1c572e (diff)
downloadgitlab-ce-654daa2ccbf58f9f36d94bfafcaea323e350ccd3.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/note_spec.rb')
-rw-r--r--spec/models/note_spec.rb31
1 files changed, 27 insertions, 4 deletions
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 864f7221181..7edd7849bbe 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -1373,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
@@ -1386,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