Commit 2120e2dd authored by Robert Speicher's avatar Robert Speicher Committed by Dmitriy Zaporozhets

Replace remaining references to `Note.create_cross_reference_note`

parent 213d1a47
......@@ -75,7 +75,7 @@ module Mentionable
refs.reject! { |ref| without.include?(ref) }
refs.each do |ref|
Note.create_cross_reference_note(ref, local_reference, a)
SystemNoteService.cross_reference(ref, local_reference, a)
end
end
......
......@@ -63,11 +63,6 @@ class Note < ActiveRecord::Base
after_update :set_references
class << self
# TODO (rspeicher): Update usages
def create_cross_reference_note(*args)
SystemNoteService.cross_reference(*args)
end
def discussions_from_notes(notes)
discussion_ids = []
discussions = []
......
......@@ -105,7 +105,7 @@ class GitPushService
author ||= commit_user(commit)
refs.each do |r|
Note.create_cross_reference_note(r, commit, author)
SystemNoteService.cross_reference(r, commit, author)
end
end
end
......
......@@ -15,7 +15,7 @@ module Notes
# Create a cross-reference note if this Note contains GFM that names an
# issue, merge request, or commit.
note.references.each do |mentioned|
Note.create_cross_reference_note(mentioned, note.noteable, note.author)
SystemNoteService.cross_reference(mentioned, note.noteable, note.author)
end
execute_hooks(note)
......
......@@ -13,7 +13,7 @@ module Notes
# Create a cross-reference note if this Note contains GFM that
# names an issue, merge request, or commit.
note.references.each do |mentioned|
Note.create_cross_reference_note(mentioned, note.noteable, note.author)
SystemNoteService.cross_reference(mentioned, note.noteable, note.author)
end
end
end
......
......@@ -23,7 +23,7 @@ describe Issue, "Mentionable" do
end
it 'correctly removes already-mentioned Commits' do
expect(Note).not_to receive(:create_cross_reference_note)
expect(SystemNoteService).not_to receive(:cross_reference)
issue.create_cross_references!(project, author, [commit2])
end
......
......@@ -166,15 +166,15 @@ describe GitPushService do
end
it "creates a note if a pushed commit mentions an issue" do
expect(Note).to receive(:create_cross_reference_note).with(issue, commit, commit_author)
expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, commit_author)
service.execute(project, user, @oldrev, @newrev, @ref)
end
it "only creates a cross-reference note if one doesn't already exist" do
Note.create_cross_reference_note(issue, commit, user)
SystemNoteService.cross_reference(issue, commit, user)
expect(Note).not_to receive(:create_cross_reference_note).with(issue, commit, commit_author)
expect(SystemNoteService).not_to receive(:cross_reference).with(issue, commit, commit_author)
service.execute(project, user, @oldrev, @newrev, @ref)
end
......@@ -184,7 +184,7 @@ describe GitPushService do
author_name: 'unknown name',
author_email: 'unknown@email.com'
)
expect(Note).to receive(:create_cross_reference_note).with(issue, commit, user)
expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, user)
service.execute(project, user, @oldrev, @newrev, @ref)
end
......@@ -193,7 +193,7 @@ describe GitPushService do
allow(project.repository).to receive(:commits_between).with(@blankrev, @newrev).and_return([])
allow(project.repository).to receive(:commits_between).with("master", @newrev).and_return([commit])
expect(Note).to receive(:create_cross_reference_note).with(issue, commit, commit_author)
expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, commit_author)
service.execute(project, user, @blankrev, @newrev, 'refs/heads/other')
end
......
......@@ -58,7 +58,7 @@ describe NotificationService do
end
it 'filters out "mentioned in" notes' do
mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author)
mentioned_note = SystemNoteService.cross_reference(mentioned_issue, issue, issue.author)
expect(Notify).not_to receive(:note_issue_email)
notification.new_note(mentioned_note)
......@@ -130,7 +130,7 @@ describe NotificationService do
end
it 'filters out "mentioned in" notes' do
mentioned_note = Note.create_cross_reference_note(mentioned_issue, issue, issue.author)
mentioned_note = SystemNoteService.cross_reference(mentioned_issue, issue, issue.author)
expect(Notify).not_to receive(:note_issue_email)
notification.new_note(mentioned_note)
......
......@@ -80,7 +80,7 @@ shared_examples 'a mentionable' do
ext_issue, ext_mr, ext_commit]
mentioned_objects.each do |referenced|
expect(Note).to receive(:create_cross_reference_note).
expect(SystemNoteService).to receive(:cross_reference).
with(referenced, subject.local_reference, author)
end
......@@ -88,7 +88,7 @@ shared_examples 'a mentionable' do
end
it 'detects existing cross-references' do
Note.create_cross_reference_note(mentioned_issue, subject.local_reference, author)
SystemNoteService.cross_reference(mentioned_issue, subject.local_reference, author)
expect(subject).to have_mentioned(mentioned_issue)
expect(subject).not_to have_mentioned(mentioned_mr)
......@@ -132,13 +132,13 @@ shared_examples 'an editable mentionable' do
# These three objects were already referenced, and should not receive new
# notes
[mentioned_issue, mentioned_commit, ext_issue].each do |oldref|
expect(Note).not_to receive(:create_cross_reference_note).
expect(SystemNoteService).not_to receive(:cross_reference).
with(oldref, any_args)
end
# These two issues are new and should receive reference notes
new_issues.each do |newref|
expect(Note).to receive(:create_cross_reference_note).
expect(SystemNoteService).to receive(:cross_reference).
with(newref, subject.local_reference, author)
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