summaryrefslogtreecommitdiff
path: root/spec/models/project_services
diff options
context:
space:
mode:
authorHeinrich Lee Yu <heinrich@gitlab.com>2019-07-19 00:44:24 +0800
committerHeinrich Lee Yu <heinrich@gitlab.com>2019-07-22 13:35:52 +0800
commit589d1797d8dfdced2c6257597264bce0e2072c35 (patch)
treedd48ebd58932f2d2fab0725556db50298eea7aac /spec/models/project_services
parent695f4bb17d157ba2c7653a6aefa9bf09ecc2c583 (diff)
downloadgitlab-ce-589d1797d8dfdced2c6257597264bce0e2072c35.tar.gz
Handle trailing slashes when generating Jira URLs63833-fix-jira-issues-url
Applies to issues_url and new_issue_url
Diffstat (limited to 'spec/models/project_services')
-rw-r--r--spec/models/project_services/jira_service_spec.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 235cf314af5..02060699e9a 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -236,7 +236,7 @@ describe JiraService do
allow(JIRA::Resource::Remotelink).to receive(:all).and_return(nil)
expect { @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project)) }
- .not_to raise_error(NoMethodError)
+ .not_to raise_error
end
# Check https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links
@@ -606,6 +606,12 @@ describe JiraService do
expect(service.properties['api_url']).to eq('http://jira.sample/api')
end
end
+
+ it 'removes trailing slashes from url' do
+ service = described_class.new(url: 'http://jira.test.com/path/')
+
+ expect(service.url).to eq('http://jira.test.com/path')
+ end
end
describe 'favicon urls', :request_store do
@@ -621,4 +627,20 @@ describe JiraService do
expect(props[:object][:icon][:url16x16]).to match %r{^http://localhost/uploads/-/system/appearance/favicon/\d+/dk.png$}
end
end
+
+ context 'generating external URLs' do
+ let(:service) { described_class.new(url: 'http://jira.test.com/path/') }
+
+ describe '#issues_url' do
+ it 'handles trailing slashes' do
+ expect(service.issues_url).to eq('http://jira.test.com/path/browse/:id')
+ end
+ end
+
+ describe '#new_issue_url' do
+ it 'handles trailing slashes' do
+ expect(service.new_issue_url).to eq('http://jira.test.com/path/secure/CreateIssue.jspa')
+ end
+ end
+ end
end