Commit 92cdbb95 authored by Mario de la Ossa's avatar Mario de la Ossa

Fix quickactions not working before codeblocks

QuickActions would not work if written before a codeblock due to
too-aggressive regex.
parent ebcc4595
---
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