summaryrefslogtreecommitdiff
path: root/spec/models/commit_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2015-12-04 20:58:45 +0000
committerRobert Speicher <robert@gitlab.com>2015-12-04 20:58:45 +0000
commitd2f9a9012d55a7dc9c8e9e61b946c52836a1d8f1 (patch)
tree2d9a005407b7556a8383b08d841feef49653d63b /spec/models/commit_spec.rb
parent3c8051776b25add2e2845344a328328db33d1671 (diff)
parentf9d954fae71d40a314a5812c1a7eec5a601d1575 (diff)
downloadgitlab-ce-d2f9a9012d55a7dc9c8e9e61b946c52836a1d8f1.tar.gz
Merge branch 'link-refs' into 'master'
Recognize issue/MR/snippet/commit links as references. Fixes #3744 and #3745 See merge request !1933
Diffstat (limited to 'spec/models/commit_spec.rb')
-rw-r--r--spec/models/commit_spec.rb21
1 files changed, 14 insertions, 7 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 90be9324951..974b52c1833 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -24,6 +24,17 @@ describe Commit do
end
end
+ describe '#reference_link_text' do
+ it 'returns a String reference to the object' do
+ expect(commit.reference_link_text).to eq commit.short_id
+ end
+
+ it 'supports a cross-project reference' do
+ cross = double('project')
+ expect(commit.reference_link_text(cross)).to eq "#{project.to_reference}@#{commit.short_id}"
+ end
+ end
+
describe '#title' do
it "returns no_commit_message when safe_message is blank" do
allow(commit).to receive(:safe_message).and_return('')
@@ -77,14 +88,10 @@ eos
let(:other_issue) { create :issue, project: other_project }
it 'detects issues that this commit is marked as closing' do
- allow(commit).to receive(:safe_message).and_return("Fixes ##{issue.iid}")
- expect(commit.closes_issues).to eq([issue])
- end
-
- it 'does not detect issues from other projects' do
ext_ref = "#{other_project.path_with_namespace}##{other_issue.iid}"
- allow(commit).to receive(:safe_message).and_return("Fixes #{ext_ref}")
- expect(commit.closes_issues).to be_empty
+ allow(commit).to receive(:safe_message).and_return("Fixes ##{issue.iid} and #{ext_ref}")
+ expect(commit.closes_issues).to include(issue)
+ expect(commit.closes_issues).to include(other_issue)
end
end