Commit 3962d33f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge cross-reference refactoring with EE code

parent b2d45bb5
...@@ -167,10 +167,8 @@ class SystemNoteService ...@@ -167,10 +167,8 @@ class SystemNoteService
if noteable.is_a?(ExternalIssue) if noteable.is_a?(ExternalIssue)
noteable.project.issues_tracker.create_cross_reference_note(noteable, mentioner, author) noteable.project.issues_tracker.create_cross_reference_note(noteable, mentioner, author)
else else
create(note_options) create_note(note_options)
end end
create_note(note_options)
end end
def self.cross_reference?(note_text) def self.cross_reference?(note_text)
......
This diff is collapsed.
...@@ -343,4 +343,68 @@ describe SystemNoteService do ...@@ -343,4 +343,68 @@ describe SystemNoteService do
end end
end end
end end
include JiraServiceHelper
describe 'JIRA integration' do
let(:project) { create(:project) }
let(:author) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:mergereq) { create(:merge_request, :simple, target_project: project, source_project: project) }
let(:jira_issue) { JiraIssue.new("JIRA-1", project)}
let(:jira_tracker) { project.create_jira_service if project.jira_service.nil? }
let(:commit) { project.commit }
context 'in JIRA issue tracker' do
before do
jira_service_settings
WebMock.stub_request(:post, jira_api_comment_url)
end
after do
jira_tracker.destroy!
end
describe "new reference" do
before do
WebMock.stub_request(:get, jira_api_comment_url).
to_return(:body => jira_issue_comments)
end
subject { Note.create_cross_reference_note(jira_issue, commit, author) }
it { is_expected.to eq(jira_status_message) }
end
describe "existing reference" do
before do
message = "[#{author.name}|http://localhost/u/#{author.username}] mentioned this issue in [a commit of #{project.path_with_namespace}|http://localhost/#{project.path_with_namespace}/commit/#{commit.id}]."
WebMock.stub_request(:get, jira_api_comment_url).
to_return(:body => "{\"comments\":[{\"body\":\"#{message}\"}]}")
end
subject { Note.create_cross_reference_note(jira_issue, commit, author) }
it { is_expected.not_to eq(jira_status_message) }
end
end
context 'issue from an issue' do
context 'in JIRA issue tracker' do
before do
jira_service_settings
WebMock.stub_request(:post, jira_api_comment_url)
WebMock.stub_request(:get, jira_api_comment_url).
to_return(:body => jira_issue_comments)
end
after do
jira_tracker.destroy!
end
subject { Note.create_cross_reference_note(jira_issue, issue, author) }
it { is_expected.to eq(jira_status_message) }
end
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