Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2018-08-06 16:45:24 +0300
committerSean McGivern <sean@mcgivern.me.uk>2018-08-06 16:45:24 +0300
commitad570fa6a1d6c981243ff1c64a8be2c8e369f207 (patch)
treeda7b5754959b9ff5c03049e60a5b8a3af1dd9897 /spec/models
parent77c75d2b1b4821b1f5fafd107e1925c225fb6a33 (diff)
parent32b88294d5a3b7bc22682c7942d8b3c4fa1502c6 (diff)
Merge branch 'issue_43602' into 'master'
Allow multiple JIRA transitions id split by comma or semicolon Closes #43602 See merge request gitlab-org/gitlab-ce!20939
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/project_services/jira_service_spec.rb53
1 files changed, 47 insertions, 6 deletions
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 6c637533c6b..ac9ff59b9b5 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -30,6 +30,10 @@ describe JiraService do
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
+ it { is_expected.to allow_value(nil).for(:jira_issue_transition_id) }
+ it { is_expected.to allow_value("1,2,3").for(:jira_issue_transition_id) }
+ it { is_expected.to allow_value("1;2;3").for(:jira_issue_transition_id) }
+ it { is_expected.not_to allow_value("a,b,cd").for(:jira_issue_transition_id) }
end
describe 'Validations' do
@@ -124,7 +128,7 @@ describe JiraService do
url: 'http://jira.example.com',
username: 'gitlab_jira_username',
password: 'gitlab_jira_password',
- jira_issue_transition_id: "custom-id"
+ jira_issue_transition_id: "999"
)
# These stubs are needed to test JiraService#close_issue.
@@ -226,12 +230,49 @@ describe JiraService do
).once
end
- it "calls the api with jira_issue_transition_id" do
- @jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
+ context '#close_issue' do
+ it "logs exception when transition id is not valid" do
+ allow(Rails.logger).to receive(:info)
+ WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).and_raise("Bad Request")
- expect(WebMock).to have_requested(:post, @transitions_url).with(
- body: /custom-id/
- ).once
+ @jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
+
+ expect(Rails.logger).to have_received(:info).with("JiraService Issue Transition failed message ERROR: http://jira.example.com - Bad Request")
+ end
+
+ it "calls the api with jira_issue_transition_id" do
+ @jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
+
+ expect(WebMock).to have_requested(:post, @transitions_url).with(
+ body: /999/
+ ).once
+ end
+
+ context "when have multiple transition ids" do
+ it "calls the api with transition ids separated by comma" do
+ allow(@jira_service).to receive_messages(jira_issue_transition_id: "1,2,3")
+
+ @jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
+
+ 1.upto(3) do |transition_id|
+ expect(WebMock).to have_requested(:post, @transitions_url).with(
+ body: /#{transition_id}/
+ ).once
+ end
+ end
+
+ it "calls the api with transition ids separated by semicolon" do
+ allow(@jira_service).to receive_messages(jira_issue_transition_id: "1;2;3")
+
+ @jira_service.close_issue(merge_request, ExternalIssue.new("JIRA-123", project))
+
+ 1.upto(3) do |transition_id|
+ expect(WebMock).to have_requested(:post, @transitions_url).with(
+ body: /#{transition_id}/
+ ).once
+ end
+ end
+ end
end
end