Skip to content

Commit

Permalink
Rename notice_added_references to create_new_cross_references!
Browse files Browse the repository at this point in the history
  • Loading branch information
rspeicher committed Jul 14, 2015
1 parent e4c698f commit f3d4767
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions app/models/concerns/mentionable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def create_cross_references!(p = project, a = author, without = [])
end
end

# If the mentionable_text field is about to change, locate any *added* references and create cross references for
# them. Invoke from an observer's #before_save implementation.
def notice_added_references(p = project, a = author)
# When a mentionable field is changed, creates cross-reference notes that
# don't already exist
def create_new_cross_references!(p = project, a = author)
changes = detect_mentionable_changes

return if changes.empty?
Expand Down
2 changes: 1 addition & 1 deletion app/models/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def reset_events_cache
end

def set_references
notice_added_references(project, author)
create_new_cross_references!(project, author)
end

def editable?
Expand Down
2 changes: 1 addition & 1 deletion app/services/issues/update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def execute(issue)
create_title_change_note(issue, issue.previous_changes['title'].first)
end

issue.notice_added_references(issue.project, current_user)
issue.create_new_cross_references!(issue.project, current_user)
execute_hooks(issue, 'update')
end

Expand Down
2 changes: 1 addition & 1 deletion app/services/merge_requests/update_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def execute(merge_request)
merge_request.mark_as_unchecked
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')
end

Expand Down
10 changes: 5 additions & 5 deletions spec/models/concerns/mentionable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
end
end

describe '#notice_added_references' do
describe '#create_new_cross_references!' do
let(:project) { create(:project) }
let(:issues) { create_list(:issue, 2, project: project) }

Expand All @@ -40,7 +40,7 @@
expect(SystemNoteService).not_to receive(:cross_reference)

issue.description = 'New description'
issue.notice_added_references
issue.create_new_cross_references!
end

it 'notifies new references' do
Expand All @@ -49,7 +49,7 @@
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)

issue.description = issues[1].to_reference
issue.notice_added_references
issue.create_new_cross_references!
end
end

Expand All @@ -60,7 +60,7 @@
expect(SystemNoteService).not_to receive(:cross_reference)

issue.update_attributes(description: 'New description')
issue.notice_added_references
issue.create_new_cross_references!
end

it 'notifies new references' do
Expand All @@ -69,7 +69,7 @@
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)

issue.update_attributes(description: issues[1].to_reference)
issue.notice_added_references
issue.create_new_cross_references!
end
end

Expand Down
2 changes: 1 addition & 1 deletion spec/support/mentionable_shared_examples.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,6 @@ def common_mentionable_setup
end

set_mentionable_text.call(new_text)
subject.notice_added_references(project, author)
subject.create_new_cross_references!(project, author)
end
end

0 comments on commit f3d4767

Please sign in to comment.