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