Accept a valid ref for issue show

For example, now we support `/gitlab issue show #1`. Where the # used
to trip the regex.
This commit is contained in:
Z.J. van de Weg 2016-11-21 22:27:10 +01:00
parent 2914fa3919
commit d71ad49fc5
2 changed files with 9 additions and 1 deletions

View File

@ -2,7 +2,7 @@ module Gitlab
module ChatCommands
class IssueShow < IssueCommand
def self.match(text)
/\Aissue\s+show\s+(?<iid>\d+)/.match(text)
/\Aissue\s+show\s+#{Issue.reference_prefix}?(?<iid>\d+)/.match(text)
end
def self.help_message

View File

@ -19,6 +19,14 @@ describe Gitlab::ChatCommands::IssueShow, service: true do
it 'returns the issue' do
expect(subject.iid).to be issue.iid
end
context 'when its reference is given' do
let(:regex_match) { described_class.match("issue show #{issue.to_reference}") }
it 'shows the issue' do
expect(subject.iid).to be issue.iid
end
end
end
context 'the issue does not exist' do