Commit 5011d83c authored by Yauhen Kotau's avatar Yauhen Kotau

Lowercase letters support and additional tests for YouTrack integration service

parent fdfa6f1e
...@@ -8,9 +8,9 @@ class YoutrackService < IssueTrackerService ...@@ -8,9 +8,9 @@ class YoutrackService < IssueTrackerService
# {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1 # {PROJECT-KEY}-{NUMBER} Examples: YT-1, PRJ-1
def self.reference_pattern(only_long: false) def self.reference_pattern(only_long: false)
if only_long if only_long
/(?<issue>\b[A-Z][A-Z0-9_]*-\d+)/ /(?<issue>\b[A-Z][A-Za-z0-9_]*-\d+)/
else else
/(?<issue>\b[A-Z][A-Z0-9_]*-\d+)|(#{Issue.reference_prefix}(?<issue>\d+))/ /(?<issue>\b[A-Z][A-Za-z0-9_]*-\d+)|(#{Issue.reference_prefix}(?<issue>\d+))/
end end
end end
......
...@@ -87,6 +87,7 @@ describe 'User activates issue tracker', :js do ...@@ -87,6 +87,7 @@ describe 'User activates issue tracker', :js do
end end
it_behaves_like 'external issue tracker activation', tracker: 'Redmine' it_behaves_like 'external issue tracker activation', tracker: 'Redmine'
it_behaves_like 'external issue tracker activation', tracker: 'YouTrack'
it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla' it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla'
it_behaves_like 'external issue tracker activation', tracker: 'Custom Issue Tracker' it_behaves_like 'external issue tracker activation', tracker: 'Custom Issue Tracker'
end end
...@@ -135,6 +135,20 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do ...@@ -135,6 +135,20 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
it_behaves_like "external issue tracker" it_behaves_like "external issue tracker"
end end
context "with underscores in the prefix" do
let(:issue) { ExternalIssue.new("PRJ_1-123", project) }
let(:reference) { issue.to_reference }
it_behaves_like "external issue tracker"
end
context "with lowercase letters in the prefix" do
let(:issue) { ExternalIssue.new("YTkPrj-123", project) }
let(:reference) { issue.to_reference }
it_behaves_like "external issue tracker"
end
context "with a single-letter prefix" do context "with a single-letter prefix" do
let(:issue) { ExternalIssue.new("T-123", project) } let(:issue) { ExternalIssue.new("T-123", project) }
let(:reference) { issue.to_reference } let(:reference) { issue.to_reference }
......
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