summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-11-21 17:05:53 +0000
committerSean McGivern <sean@mcgivern.me.uk>2016-11-21 17:05:53 +0000
commitd3236af1ae8cbe6cc1a0b813789f7ba040550f02 (patch)
tree5e19cc2c98dd6480db53206efd840b7136f89d08 /spec/services
parent80eaed1651e6a278af87e015f6b414d4f943a352 (diff)
parent9c740133a3bb4e992ccd7e3801402e4eab537e29 (diff)
downloadgitlab-ce-d3236af1ae8cbe6cc1a0b813789f7ba040550f02.tar.gz
Merge branch 'issue_24303' into 'master'
Allow JIRA references for project snippets closes #24303 See merge request !7541
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/system_note_service_spec.rb65
1 files changed, 48 insertions, 17 deletions
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index 150e21574a1..2a5709c6322 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -543,7 +543,10 @@ describe SystemNoteService, services: true do
let(:comment_url) { jira_api_comment_url(jira_issue.id) }
let(:success_message) { "JiraService SUCCESS: Successfully posted to http://jira.example.net." }
- before { stub_jira_urls(jira_issue.id) }
+ before do
+ stub_jira_urls(jira_issue.id)
+ jira_service_settings
+ end
noteable_types = ["merge_requests", "commit"]
@@ -569,16 +572,16 @@ describe SystemNoteService, services: true do
end
end
- context 'in JIRA issue tracker' do
- before { jira_service_settings }
-
- describe "new reference" do
- subject { described_class.cross_reference(jira_issue, commit, author) }
+ describe "new reference" do
+ context 'for commits' do
+ it "creates comment" do
+ result = described_class.cross_reference(jira_issue, commit, author)
- it { is_expected.to eq(success_message) }
+ expect(result).to eq(success_message)
+ end
it "creates remote link" do
- subject
+ described_class.cross_reference(jira_issue, commit, author)
expect(WebMock).to have_requested(:post, jira_api_remote_link_url(jira_issue)).with(
body: hash_including(
@@ -593,18 +596,18 @@ describe SystemNoteService, services: true do
).once
end
end
- end
- context 'in commit' do
- context 'in JIRA issue tracker' do
- before { jira_service_settings }
+ context 'for issues' do
+ let(:issue) { create(:issue, project: project) }
- subject { described_class.cross_reference(jira_issue, issue, author) }
+ it "creates comment" do
+ result = described_class.cross_reference(jira_issue, issue, author)
- it { is_expected.to eq(success_message) }
+ expect(result).to eq(success_message)
+ end
it "creates remote link" do
- subject
+ described_class.cross_reference(jira_issue, issue, author)
expect(WebMock).to have_requested(:post, jira_api_remote_link_url(jira_issue)).with(
body: hash_including(
@@ -619,6 +622,32 @@ describe SystemNoteService, services: true do
).once
end
end
+
+ context 'for snippets' do
+ let(:snippet) { create(:snippet, project: project) }
+
+ it "creates comment" do
+ result = described_class.cross_reference(jira_issue, snippet, author)
+
+ expect(result).to eq(success_message)
+ end
+
+ it "creates remote link" do
+ described_class.cross_reference(jira_issue, snippet, author)
+
+ expect(WebMock).to have_requested(:post, jira_api_remote_link_url(jira_issue)).with(
+ body: hash_including(
+ GlobalID: "GitLab",
+ object: {
+ url: namespace_project_snippet_url(project.namespace, project, snippet),
+ title: "GitLab: Mentioned on snippet - #{snippet.title}",
+ icon: { title: "GitLab", url16x16: "https://gitlab.com/favicon.ico" },
+ status: { resolved: false }
+ }
+ )
+ ).once
+ end
+ end
end
describe "existing reference" do
@@ -627,9 +656,11 @@ describe SystemNoteService, services: true do
allow_any_instance_of(JIRA::Resource::Issue).to receive(:comments).and_return([OpenStruct.new(body: message)])
end
- subject { described_class.cross_reference(jira_issue, commit, author) }
+ it "does not return success message" do
+ result = described_class.cross_reference(jira_issue, commit, author)
- it { is_expected.not_to eq(success_message) }
+ expect(result).not_to eq(success_message)
+ end
it 'does not try to create comment and remote link' do
subject