Commit fcb70d9b authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'osw-remote-multi-line-suggestions-ff' into 'master'

Remove multi-line suggestions feature flag

Closes #59178

See merge request gitlab-org/gitlab-ce!27219
parents 95bbcf08 81da9337
......@@ -6,15 +6,11 @@ module Banzai
class SuggestionFilter < HTML::Pipeline::Filter
# Class used for tagging elements that should be rendered
TAG_CLASS = 'js-render-suggestion'.freeze
SUGGESTION_REGEX = Gitlab::Diff::SuggestionsParser::SUGGESTION_CONTEXT
def call
return doc unless suggestions_filter_enabled?
doc.search('pre.suggestion > code').each do |node|
# TODO: Remove once multi-line suggestions FF get removed (#59178).
remove_multi_line_params(node.parent)
node.add_class(TAG_CLASS)
end
......@@ -30,14 +26,6 @@ module Banzai
def project
context[:project]
end
def remove_multi_line_params(node)
return if Feature.enabled?(:multi_line_suggestions, project)
if node[SyntaxHighlightFilter::LANG_PARAMS_ATTR]&.match?(SUGGESTION_REGEX)
node.remove_attribute(SyntaxHighlightFilter::LANG_PARAMS_ATTR)
end
end
end
end
end
......@@ -28,30 +28,11 @@ describe Banzai::Filter::SuggestionFilter do
let(:data_attr) { Banzai::Filter::SyntaxHighlightFilter::LANG_PARAMS_ATTR }
let(:input) { %(<pre class="code highlight js-syntax-highlight suggestion" #{data_attr}="-3+2"><code>foo\n</code></pre>) }
context 'feature disabled' do
before do
stub_feature_flags(multi_line_suggestions: false)
end
it 'removes data-lang-params if it matches a multi-line suggestion param' do
doc = filter(input, default_context)
pre = doc.css('pre').first
expect(pre[data_attr]).to be_nil
end
end
context 'feature enabled' do
before do
stub_feature_flags(multi_line_suggestions: true)
end
it 'keeps data-lang-params' do
it 'element has correct data-lang-params' do
doc = filter(input, default_context)
pre = doc.css('pre').first
expect(pre[data_attr]).to eq('-3+2')
end
end
end
end
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