Commit 03f16a95 authored by Marin Jankovski's avatar Marin Jankovski

Add git push service spec in case jira service is enabled.

parent c4b97dc2
...@@ -201,9 +201,10 @@ describe GitPushService do ...@@ -201,9 +201,10 @@ describe GitPushService do
let(:commit_author) { create :user } let(:commit_author) { create :user }
let(:closing_commit) { project.repository.commit } let(:closing_commit) { project.repository.commit }
context "for default gitlab issue tracker" do
before do before do
closing_commit.stub({ closing_commit.stub({
issue_closing_regex: /^([Cc]loses|[Ff]ixes) #\d+/, issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern),
safe_message: "this is some work.\n\ncloses ##{issue.iid}", safe_message: "this is some work.\n\ncloses ##{issue.iid}",
author_name: commit_author.name, author_name: commit_author.name,
author_email: commit_author.email author_email: commit_author.email
...@@ -235,5 +236,57 @@ describe GitPushService do ...@@ -235,5 +236,57 @@ describe GitPushService do
Issue.find(issue.id).should be_opened Issue.find(issue.id).should be_opened
end end
end end
context "for jira issue tracker" do
let(:api_url) { 'http://jira.example/rest/api/2/issue/JIRA-1/transitions' }
let(:jira_tracker) { project.create_jira_service if project.jira_service.nil? }
before do
properties = {
"title"=>"JIRA tracker",
"project_url"=>"http://jira.example/issues/?jql=project=A",
"issues_url"=>"http://jira.example/browse/JIRA-1",
"new_issue_url"=>"http://jira.example/secure/CreateIssue.jspa"
}
jira_tracker.update_attributes(properties: properties, active: true)
WebMock.stub_request(:post, api_url)
closing_commit.stub({
issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern),
safe_message: "this is some work.\n\ncloses JIRA-1",
author_name: commit_author.name,
author_email: commit_author.email
})
project.repository.stub(commits_between: [closing_commit])
end
after do
jira_tracker.destroy!
end
it "should initiate one api call to jira server" do
message = {
'update' => {
'comment' => [{
'add' => {
'body' => "Issue solved with http://localhost/#{project.path_with_namespace}/commit/#{closing_commit.id}"
}
}]
},
'transition' => {
'id' => '2'
}
}.to_json
service.execute(project, user, @oldrev, @newrev, @ref)
WebMock.should have_requested(:post, api_url).with(
body: message
).once
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