Commit 96e2ff69 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch '58297-remove-extraneous-gitaly-calls-from-md-rendering' into 'master'

Remove extraneous DiffNote#supports_suggestion? calls

See merge request gitlab-org/gitlab-ce!29027
parents 4b086b74 9994a5c1
......@@ -90,7 +90,7 @@ class DiffNote < Note
end
def banzai_render_context(field)
super.merge(project: project, suggestions_filter_enabled: supports_suggestion?)
super.merge(suggestions_filter_enabled: true)
end
private
......
......@@ -38,7 +38,9 @@ class PreviewMarkdownService < BaseService
head_sha: params[:head_sha],
start_sha: params[:start_sha])
Gitlab::Diff::SuggestionsParser.parse(text, position: position, project: project)
Gitlab::Diff::SuggestionsParser.parse(text, position: position,
project: project,
supports_suggestion: params[:preview_suggestions])
end
def preview_sugestions?
......
---
title: Reduce Gitaly calls to improve performance when rendering suggestions
merge_request: 29027
author:
type: performance
......@@ -10,10 +10,12 @@ module Gitlab
# Returns an array of Gitlab::Diff::Suggestion which represents each
# suggestion in the given text.
#
def parse(text, position:, project:)
def parse(text, position:, project:, supports_suggestion: true)
return [] unless position.complete?
html = Banzai.render(text, project: nil, no_original_data: true)
html = Banzai.render(text, project: nil,
no_original_data: true,
suggestions_filter_enabled: supports_suggestion)
doc = Nokogiri::HTML(html)
suggestion_nodes = doc.search('pre.suggestion')
......
......@@ -56,7 +56,9 @@ describe PreviewMarkdownService do
expect(Gitlab::Diff::SuggestionsParser)
.to receive(:parse)
.with(text, position: position, project: merge_request.project)
.with(text, position: position,
project: merge_request.project,
supports_suggestion: true)
.and_call_original
result = service.execute
......
......@@ -96,7 +96,7 @@ describe Suggestions::CreateService do
it 'creates no suggestion when diff file is not found' do
expect_next_instance_of(DiffNote) do |diff_note|
expect(diff_note).to receive(:latest_diff_file).twice { nil }
expect(diff_note).to receive(:latest_diff_file).once { nil }
end
expect { subject.execute }.not_to change(Suggestion, :count)
......
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