Commit 677c1cc8 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'vij-snippet-note-updates' into 'master'

Skip reference processing for PersonalSnippet Notes

See merge request gitlab-org/gitlab!39341
parents 18b29966 3b7130d3
......@@ -417,7 +417,7 @@ class Note < ApplicationRecord
end
def can_create_todo?
# Skip system notes, and notes on project snippet
# Skip system notes, and notes on snippets
!system? && !for_snippet?
end
......
......@@ -25,7 +25,7 @@ module Notes
note.note = content
end
unless only_commands
unless only_commands || note.for_personal_snippet?
note.create_new_cross_references!(current_user)
update_todos(note, old_mentioned_users)
......
......@@ -13,6 +13,17 @@ RSpec.describe Notes::UpdateService do
let(:issue) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: private_project) }
let(:note) { create(:note, project: project, noteable: issue, author: user, note: "Old note #{user2.to_reference}") }
let(:markdown) do
<<-MARKDOWN.strip_heredoc
```suggestion
foo
```
```suggestion
bar
```
MARKDOWN
end
before do
project.add_maintainer(user)
......@@ -48,16 +59,6 @@ RSpec.describe Notes::UpdateService do
context 'suggestions' do
it 'refreshes note suggestions' do
markdown = <<-MARKDOWN.strip_heredoc
```suggestion
foo
```
```suggestion
bar
```
MARKDOWN
suggestion = create(:suggestion)
note = suggestion.note
......@@ -201,5 +202,24 @@ RSpec.describe Notes::UpdateService do
end
end
end
context 'for a personal snippet' do
let_it_be(:snippet) { create(:personal_snippet, :public) }
let(:note) { create(:note, project: nil, noteable: snippet, author: user, note: "Note on a snippet with reference #{issue.to_reference}" ) }
it 'does not create todos' do
expect { update_note({ note: "Mentioning user #{user2}" }) }.not_to change { note.todos.count }
end
it 'does not create suggestions' do
expect { update_note({ note: "Updated snippet with markdown suggestion #{markdown}" }) }
.not_to change { note.suggestions.count }
end
it 'does not create mentions' do
expect(note).not_to receive(:create_new_cross_references!)
update_note({ note: "Updated with new reference: #{issue.to_reference}" })
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment