Commit 16d2c280 authored by Arturo Herrero's avatar Arturo Herrero

Merge branch 'chatops-multiline-messages' into 'master'

Support newlines for the chatops "run" command

See merge request gitlab-org/gitlab!56668
parents 26aafa97 4d226dec
---
title: Support newlines for the chatops "run" command
merge_request: 56668
author:
type: changed
......@@ -5,7 +5,7 @@ module Gitlab
# Slash command for triggering chatops jobs.
class Run < BaseCommand
def self.match(text)
/\Arun\s+(?<command>\S+)(\s+(?<arguments>.+))?\z/.match(text)
/\Arun\s+(?<command>\S+)(\s+(?<arguments>.+))?\z/m.match(text)
end
def self.help_message
......
......@@ -3,6 +3,26 @@
require 'spec_helper'
RSpec.describe Gitlab::SlashCommands::Run do
describe '.match' do
it 'returns true for a run command' do
expect(described_class.match('run foo')).to be_an_instance_of(MatchData)
end
it 'returns true for a run command with arguments' do
expect(described_class.match('run foo bar baz'))
.to be_an_instance_of(MatchData)
end
it 'returns true for a command containing newlines' do
expect(described_class.match("run foo\nbar\nbaz"))
.to be_an_instance_of(MatchData)
end
it 'returns false for an unrelated command' do
expect(described_class.match('foo bar')).to be_nil
end
end
describe '.available?' do
it 'returns true when builds are enabled for the project' do
project = double(:project, builds_enabled?: true)
......
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