Merge branch 'fix-jira-mention-spec' into 'master'

Fix JIRA mention spec

Fixes spec that was skipped in 10de4261f0.

The expected behavior with commits mentioning issues, is that when the commit _closes_ the issue, the issue only gets the "closed by commit X" comment, and not also the "mentioned in commit X" comment.

With JIRA, it used to get both, and now does no longer.

The spec was updated to test the new ("correct") behavior.

See merge request !36
This commit is contained in:
Robert Speicher
2015-10-16 20:26:56 +00:00
3 changed files with 32 additions and 28 deletions
-3
View File
@@ -933,6 +933,3 @@ DEPENDENCIES
virtus (~> 1.0.1)
webmock (~> 1.21.0)
wikicloth (= 0.8.1)
BUNDLED WITH
1.10.6
+1 -1
View File
@@ -96,7 +96,7 @@ class GitPushService
Issues::CloseService.new(project, authors[commit], {}).execute(issue, commit)
end
end
commit.create_cross_references!(authors[commit], closed_issues)
end
end
+31 -24
View File
@@ -274,7 +274,7 @@ describe GitPushService do
allow(closing_commit).to receive_messages({
issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern),
safe_message: "this is some work.\n\ncloses JIRA-1",
safe_message: message,
author_name: commit_author.name,
author_email: commit_author.email
})
@@ -286,33 +286,40 @@ describe GitPushService do
jira_tracker.destroy!
end
it "should initiate one api call to jira server to close the issue" do
message = {
update: {
comment: [{
add: {
body: "Issue solved with [#{closing_commit.id}|http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}]."
}
}]
},
transition: {
id: '2'
}
}.to_json
context "mentioning an issue" do
let(:message) { "this is some work.\n\nrelated to JIRA-1" }
service.execute(project, user, @oldrev, @newrev, @ref)
expect(WebMock).to have_requested(:post, jira_api_transition_url).with(
body: message
).once
it "should initiate one api call to jira server to mention the issue" do
service.execute(project, user, @oldrev, @newrev, @ref)
expect(WebMock).to have_requested(:post, jira_api_comment_url).with(
body: /mentioned this issue in/
).once
end
end
it "should initiate one api call to jira server to mention the issue" do
skip "This spec was broken during the CE-to-EE merge and needs to be fixed. See https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/34"
service.execute(project, user, @oldrev, @newrev, @ref)
context "closing an issue" do
let(:message) { "this is some work.\n\ncloses JIRA-1" }
expect(WebMock).to have_requested(:post, jira_api_comment_url).with(
body: /mentioned this issue in/
).once
it "should initiate one api call to jira server to close the issue" do
body = {
update: {
comment: [{
add: {
body: "Issue solved with [#{closing_commit.id}|http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}]."
}
}]
},
transition: {
id: '2'
}
}.to_json
service.execute(project, user, @oldrev, @newrev, @ref)
expect(WebMock).to have_requested(:post, jira_api_transition_url).with(
body: body
).once
end
end
end
end