summaryrefslogtreecommitdiff
path: root/spec/services/notes/update_service_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/notes/update_service_spec.rb')
-rw-r--r--spec/services/notes/update_service_spec.rb50
1 files changed, 40 insertions, 10 deletions
diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb
index 70dea99de4a..47b8ba0cd72 100644
--- a/spec/services/notes/update_service_spec.rb
+++ b/spec/services/notes/update_service_spec.rb
@@ -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)
@@ -36,18 +47,18 @@ RSpec.describe Notes::UpdateService do
end
end
- context 'suggestions' do
- it 'refreshes note suggestions' do
- markdown = <<-MARKDOWN.strip_heredoc
- ```suggestion
- foo
- ```
+ context 'with system note' do
+ before do
+ note.update_column(:system, true)
+ end
- ```suggestion
- bar
- ```
- MARKDOWN
+ it 'does not update the note' do
+ expect { update_note(note: 'new text') }.not_to change { note.reload.note }
+ end
+ end
+ context 'suggestions' do
+ it 'refreshes note suggestions' do
suggestion = create(:suggestion)
note = suggestion.note
@@ -191,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