Commit 116905cb authored by Stan Hu's avatar Stan Hu

Fix disabling of Kroki optional formats

https://gitlab.com/gitlab-org/gitlab/-/merge_requests/49304 added
optional Kroki formats, but these were not actually disabled by default.
parent 05c9b146
---
title: Fix disabling of Kroki optional formats
merge_request: 55665
author:
type: fixed
......@@ -31,9 +31,6 @@ module Gitlab
DIAGRAMS_FORMATS
end
# No additional diagram formats
return diagram_formats unless current_settings.kroki_formats.present?
# Diagrams that require a companion container must be explicitly enabled from the settings
diagram_formats.select do |diagram_type|
current_settings.kroki_format_supported?(diagram_type)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::Kroki do
using RSpec::Parameterized::TableSyntax
describe '.formats' do
def default_formats
%w[bytefield c4plantuml ditaa erd graphviz nomnoml plantuml svgbob umlet vega vegalite wavedrow].freeze
end
subject { described_class.formats(Gitlab::CurrentSettings) }
where(:enabled_formats, :expected_formats) do
'' | default_formats
'blockdiag' | default_formats + %w[actdiag blockdiag nwdiag packetdiag rackdiag seqdiag]
'bpmn' | default_formats + %w[bpmn]
'excalidraw' | default_formats + %w[excalidraw]
end
with_them do
before do
kroki_formats =
if enabled_formats.present?
{ enabled_formats => true }
else
{}
end
stub_application_setting(kroki_enabled: true, kroki_url: "http://localhost:8000", kroki_formats: kroki_formats)
end
it 'returns the expected formats' do
expect(subject).to match_array(expected_formats)
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