Commit f3d4767d authored by Robert Speicher's avatar Robert Speicher

Rename `notice_added_references` to `create_new_cross_references!`

parent e4c698fd
...@@ -79,9 +79,9 @@ module Mentionable ...@@ -79,9 +79,9 @@ module Mentionable
end end
end end
# If the mentionable_text field is about to change, locate any *added* references and create cross references for # When a mentionable field is changed, creates cross-reference notes that
# them. Invoke from an observer's #before_save implementation. # don't already exist
def notice_added_references(p = project, a = author) def create_new_cross_references!(p = project, a = author)
changes = detect_mentionable_changes changes = detect_mentionable_changes
return if changes.empty? return if changes.empty?
......
...@@ -356,7 +356,7 @@ class Note < ActiveRecord::Base ...@@ -356,7 +356,7 @@ class Note < ActiveRecord::Base
end end
def set_references def set_references
notice_added_references(project, author) create_new_cross_references!(project, author)
end end
def editable? def editable?
......
...@@ -35,7 +35,7 @@ module Issues ...@@ -35,7 +35,7 @@ module Issues
create_title_change_note(issue, issue.previous_changes['title'].first) create_title_change_note(issue, issue.previous_changes['title'].first)
end end
issue.notice_added_references(issue.project, current_user) issue.create_new_cross_references!(issue.project, current_user)
execute_hooks(issue, 'update') execute_hooks(issue, 'update')
end end
......
...@@ -59,7 +59,7 @@ module MergeRequests ...@@ -59,7 +59,7 @@ module MergeRequests
merge_request.mark_as_unchecked merge_request.mark_as_unchecked
end end
merge_request.notice_added_references(merge_request.project, current_user) merge_request.create_new_cross_references!(merge_request.project, current_user)
execute_hooks(merge_request, 'update') execute_hooks(merge_request, 'update')
end end
......
...@@ -29,7 +29,7 @@ describe Issue, "Mentionable" do ...@@ -29,7 +29,7 @@ describe Issue, "Mentionable" do
end end
end end
describe '#notice_added_references' do describe '#create_new_cross_references!' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:issues) { create_list(:issue, 2, project: project) } let(:issues) { create_list(:issue, 2, project: project) }
...@@ -40,7 +40,7 @@ describe Issue, "Mentionable" do ...@@ -40,7 +40,7 @@ describe Issue, "Mentionable" do
expect(SystemNoteService).not_to receive(:cross_reference) expect(SystemNoteService).not_to receive(:cross_reference)
issue.description = 'New description' issue.description = 'New description'
issue.notice_added_references issue.create_new_cross_references!
end end
it 'notifies new references' do it 'notifies new references' do
...@@ -49,7 +49,7 @@ describe Issue, "Mentionable" do ...@@ -49,7 +49,7 @@ describe Issue, "Mentionable" do
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args) expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
issue.description = issues[1].to_reference issue.description = issues[1].to_reference
issue.notice_added_references issue.create_new_cross_references!
end end
end end
...@@ -60,7 +60,7 @@ describe Issue, "Mentionable" do ...@@ -60,7 +60,7 @@ describe Issue, "Mentionable" do
expect(SystemNoteService).not_to receive(:cross_reference) expect(SystemNoteService).not_to receive(:cross_reference)
issue.update_attributes(description: 'New description') issue.update_attributes(description: 'New description')
issue.notice_added_references issue.create_new_cross_references!
end end
it 'notifies new references' do it 'notifies new references' do
...@@ -69,7 +69,7 @@ describe Issue, "Mentionable" do ...@@ -69,7 +69,7 @@ describe Issue, "Mentionable" do
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args) expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
issue.update_attributes(description: issues[1].to_reference) issue.update_attributes(description: issues[1].to_reference)
issue.notice_added_references issue.create_new_cross_references!
end end
end end
......
...@@ -143,6 +143,6 @@ shared_examples 'an editable mentionable' do ...@@ -143,6 +143,6 @@ shared_examples 'an editable mentionable' do
end end
set_mentionable_text.call(new_text) set_mentionable_text.call(new_text)
subject.notice_added_references(project, author) subject.create_new_cross_references!(project, author)
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