Commit 3b80cf52 authored by Robert Speicher's avatar Robert Speicher

Use to_reference in Mentionable shared examples

parent 8773f339
...@@ -10,12 +10,12 @@ def common_mentionable_setup ...@@ -10,12 +10,12 @@ def common_mentionable_setup
let(:mentioned_issue) { create(:issue, project: project) } let(:mentioned_issue) { create(:issue, project: project) }
let(:mentioned_mr) { create(:merge_request, :simple, source_project: project) } let(:mentioned_mr) { create(:merge_request, :simple, source_project: project) }
let(:mentioned_commit) { project.repository.commit } let(:mentioned_commit) { project.commit }
let(:ext_proj) { create(:project, :public) } let(:ext_proj) { create(:project, :public) }
let(:ext_issue) { create(:issue, project: ext_proj) } let(:ext_issue) { create(:issue, project: ext_proj) }
let(:ext_mr) { create(:merge_request, :simple, source_project: ext_proj) } let(:ext_mr) { create(:merge_request, :simple, source_project: ext_proj) }
let(:ext_commit) { ext_proj.repository.commit } let(:ext_commit) { ext_proj.commit }
# Override to add known commits to the repository stub. # Override to add known commits to the repository stub.
let(:extra_commits) { [] } let(:extra_commits) { [] }
...@@ -23,21 +23,19 @@ def common_mentionable_setup ...@@ -23,21 +23,19 @@ def common_mentionable_setup
# A string that mentions each of the +mentioned_.*+ objects above. Mentionables should add a self-reference # A string that mentions each of the +mentioned_.*+ objects above. Mentionables should add a self-reference
# to this string and place it in their +mentionable_text+. # to this string and place it in their +mentionable_text+.
let(:ref_string) do let(:ref_string) do
cross = ext_proj.path_with_namespace
<<-MSG.strip_heredoc <<-MSG.strip_heredoc
These references are new: These references are new:
Issue: ##{mentioned_issue.iid} Issue: #{mentioned_issue.to_reference}
Merge: !#{mentioned_mr.iid} Merge: #{mentioned_mr.to_reference}
Commit: #{mentioned_commit.id} Commit: #{mentioned_commit.to_reference}
This reference is a repeat and should only be mentioned once: This reference is a repeat and should only be mentioned once:
Repeat: ##{mentioned_issue.iid} Repeat: #{mentioned_issue.to_reference}
These references are cross-referenced: These references are cross-referenced:
Issue: #{cross}##{ext_issue.iid} Issue: #{ext_issue.to_reference(project)}
Merge: #{cross}!#{ext_mr.iid} Merge: #{ext_mr.to_reference(project)}
Commit: #{cross}@#{ext_commit.short_id} Commit: #{ext_commit.to_reference(project)}
This is a self-reference and should not be mentioned at all: This is a self-reference and should not be mentioned at all:
Self: #{backref_text} Self: #{backref_text}
...@@ -109,19 +107,17 @@ shared_examples 'an editable mentionable' do ...@@ -109,19 +107,17 @@ shared_examples 'an editable mentionable' do
it 'creates new cross-reference notes when the mentionable text is edited' do it 'creates new cross-reference notes when the mentionable text is edited' do
subject.save subject.save
cross = ext_proj.path_with_namespace
new_text = <<-MSG new_text = <<-MSG
These references already existed: These references already existed:
Issue: ##{mentioned_issue.iid} Issue: #{mentioned_issue.to_reference}
Commit: #{mentioned_commit.id} Commit: #{mentioned_commit.to_reference}
This cross-project reference already existed: This cross-project reference already existed:
Issue: #{cross}##{ext_issue.iid} Issue: #{ext_issue.to_reference(project)}
These two references are introduced in an edit: These two references are introduced in an edit:
Issue: ##{new_issues[0].iid} Issue: #{new_issues[0].to_reference}
Cross: #{cross}##{new_issues[1].iid} Cross: #{new_issues[1].to_reference(project)}
MSG MSG
# These three objects were already referenced, and should not receive new # These three objects were already referenced, and should not receive new
......
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