Commit 12867628 authored by Arturo Herrero's avatar Arturo Herrero

Match Jira keys with trailing characters

parent b2ee26c9
...@@ -121,7 +121,7 @@ module Gitlab ...@@ -121,7 +121,7 @@ module Gitlab
# Based on Jira's project key format # Based on Jira's project key format
# https://confluence.atlassian.com/adminjiraserver073/changing-the-project-key-format-861253229.html # https://confluence.atlassian.com/adminjiraserver073/changing-the-project-key-format-861253229.html
def jira_issue_key_regex def jira_issue_key_regex
@jira_issue_key_regex ||= /[A-Z][A-Z_0-9]+-\d+\b/ @jira_issue_key_regex ||= /[A-Z][A-Z_0-9]+-\d+/
end end
def jira_transition_id_regex def jira_transition_id_regex
......
...@@ -69,11 +69,23 @@ describe JiraService do ...@@ -69,11 +69,23 @@ describe JiraService do
end end
describe '.reference_pattern' do describe '.reference_pattern' do
it_behaves_like 'allows project key on reference pattern' using RSpec::Parameterized::TableSyntax
it 'does not allow # on the code' do where(:key, :result) do
expect(described_class.reference_pattern.match('#123')).to be_nil '#123' | ''
expect(described_class.reference_pattern.match('1#23#12')).to be_nil '1#23#12' | ''
'JIRA-1234A' | 'JIRA-1234'
'JIRA-1234-some_tag' | 'JIRA-1234'
'JIRA-1234_some_tag' | 'JIRA-1234'
'EXT_EXT-1234' | 'EXT_EXT-1234'
'EXT3_EXT-1234' | 'EXT3_EXT-1234'
'3EXT_EXT-1234' | ''
end
with_them do
specify do
expect(described_class.reference_pattern.match(key).to_s).to eq(result)
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