diff options
author | Vinnie Okada <vokada@mrvinn.com> | 2014-10-03 00:48:35 -0500 |
---|---|---|
committer | Vinnie Okada <vokada@mrvinn.com> | 2014-10-03 12:30:20 -0500 |
commit | 088987e2dd4b7ad8d62ebd34448dbe194df7812d (patch) | |
tree | b06d59aed2f34ffdb2f7740dcf858409c7b837ee /spec/models | |
parent | 2c46c4523fc8aa41cb60e4840af16fdd595f7dd2 (diff) | |
download | gitlab-ce-088987e2dd4b7ad8d62ebd34448dbe194df7812d.tar.gz |
Make Mentionables work for cross-project refs
Add a note to merge requests and issues when they're mentioned by a
merge request, issue, or commit in another project.
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/commit_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb index 1673184cbe4..6f201adc4e8 100644 --- a/spec/models/commit_spec.rb +++ b/spec/models/commit_spec.rb @@ -53,11 +53,23 @@ eos describe '#closes_issues' do let(:issue) { create :issue, project: project } + let(:other_project) { create :project, :public } + let(:other_issue) { create :issue, project: other_project } it 'detects issues that this commit is marked as closing' do - commit.stub(issue_closing_regex: /^([Cc]loses|[Ff]ixes) #\d+/, safe_message: "Fixes ##{issue.iid}") + stub_const('Gitlab::ClosingIssueExtractor::ISSUE_CLOSING_REGEX', + /Fixes #\d+/) + commit.stub(safe_message: "Fixes ##{issue.iid}") commit.closes_issues(project).should == [issue] end + + it 'does not detect issues from other projects' do + ext_ref = "#{other_project.path_with_namespace}##{other_issue.iid}" + stub_const('Gitlab::ClosingIssueExtractor::ISSUE_CLOSING_REGEX', + /^([Cc]loses|[Ff]ixes)/) + commit.stub(safe_message: "Fixes #{ext_ref}") + commit.closes_issues(project).should be_empty + end end it_behaves_like 'a mentionable' do diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index da51100e0d7..c88a03beb0c 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -264,8 +264,8 @@ describe Note do let(:project) { create :project } let(:author) { create :user } let(:issue) { create :issue } - let(:commit0) { double 'commit0', gfm_reference: 'commit 123456' } - let(:commit1) { double 'commit1', gfm_reference: 'commit 654321' } + let(:commit0) { project.repository.commit } + let(:commit1) { project.repository.commit('HEAD~2') } before do Note.create_cross_reference_note(issue, commit0, author, project) |