diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2016-11-22 19:57:12 +0300 |
---|---|---|
committer | Alejandro Rodríguez <alejorro70@gmail.com> | 2016-11-24 18:41:27 +0300 |
commit | 8e9dd2fea64b30c26f69b78d17e1daef2241500e (patch) | |
tree | 21b2c357fda4398f4fba3cfb7098451f327274ed | |
parent | 63f3e63f79c9752aa08d8241a9f3b828a206503c (diff) |
Merge branch 'zj-fix-trailing-whitespace-issue-create' into 'master'
Issue creation now accepts trailing whitespace
See merge request !7633
-rw-r--r-- | lib/gitlab/chat_commands/issue_create.rb | 6 | ||||
-rw-r--r-- | spec/lib/gitlab/chat_commands/issue_create_spec.rb | 9 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/gitlab/chat_commands/issue_create.rb b/lib/gitlab/chat_commands/issue_create.rb index 98338ebfa27..99c1382af44 100644 --- a/lib/gitlab/chat_commands/issue_create.rb +++ b/lib/gitlab/chat_commands/issue_create.rb @@ -2,7 +2,9 @@ module Gitlab module ChatCommands class IssueCreate < IssueCommand def self.match(text) - /\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>.*)\z/.match(text) + # we can not match \n with the dot by passing the m modifier as than + # the title and description are not seperated + /\Aissue\s+create\s+(?<title>[^\n]*)\n*(?<description>(.|\n)*)/.match(text) end def self.help_message @@ -15,7 +17,7 @@ module Gitlab def execute(match) title = match[:title] - description = match[:description] + description = match[:description].to_s.rstrip Issues::CreateService.new(project, current_user, title: title, description: description).execute end diff --git a/spec/lib/gitlab/chat_commands/issue_create_spec.rb b/spec/lib/gitlab/chat_commands/issue_create_spec.rb index df0c317ccea..dd07cff9243 100644 --- a/spec/lib/gitlab/chat_commands/issue_create_spec.rb +++ b/spec/lib/gitlab/chat_commands/issue_create_spec.rb @@ -32,6 +32,15 @@ describe Gitlab::ChatCommands::IssueCreate, service: true do expect(Issue.last.description).to eq(description) end end + + context "with more newlines between the title and the description" do + let(:description) { "Surfin bird" } + let(:regex_match) { described_class.match("issue create bird is the word\n\n#{description}\n") } + + it 'creates the issue' do + expect { subject }.to change { project.issues.count }.by(1) + end + end end describe '.match' do |