Commit 5a8f9821 authored by Nick Thomas's avatar Nick Thomas

Merge branch '244289-quickaction-with-codeblocks' into 'master'

Fix quickactions not working before codeblocks

See merge request gitlab-org/gitlab!46401
parents 119b6f30 92cdbb95
---
title: Fix QuickActions not working if written before a codeblock
merge_request: 46401
author:
type: fixed
......@@ -29,9 +29,9 @@ module Gitlab
# Anything, including `/cmd arg` which are ignored by this filter
# `
^.*`\n*
`\n*
.+?
\n*`$
\n*`
)
}mix.freeze
......
......@@ -264,6 +264,22 @@ RSpec.describe Gitlab::QuickActions::Extractor do
expect(msg).to eq 'Fixes #123'
end
it 'does not get confused if command comes before an inline code' do
msg = "/reopen\n`some inline code`\n/labels ~a\n`more inline code`"
msg, commands = extractor.extract_commands(msg)
expect(commands).to eq([['reopen'], ['labels', '~a']])
expect(msg).to eq "`some inline code`\n`more inline code`"
end
it 'does not get confused if command comes before a blockcode' do
msg = "/reopen\n```\nsome blockcode\n```\n/labels ~a\n```\nmore blockcode\n```"
msg, commands = extractor.extract_commands(msg)
expect(commands).to eq([['reopen'], ['labels', '~a']])
expect(msg).to eq "```\nsome blockcode\n```\n```\nmore blockcode\n```"
end
it 'does not extract commands inside a blockcode' do
msg = "Hello\r\n```\r\nThis is some text\r\n/close\r\n/assign @user\r\n```\r\n\r\nWorld"
expected = msg.delete("\r")
......
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