Commit 83b0a4b7 authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-fix-kroki-format-filtering' into 'master'

Fix disabling of Kroki optional formats

See merge request gitlab-org/gitlab!55665
parents 37d862c3 116905cb
---
title: Fix disabling of Kroki optional formats
merge_request: 55665
author:
type: fixed
...@@ -31,9 +31,6 @@ module Gitlab ...@@ -31,9 +31,6 @@ module Gitlab
DIAGRAMS_FORMATS DIAGRAMS_FORMATS
end 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 # Diagrams that require a companion container must be explicitly enabled from the settings
diagram_formats.select do |diagram_type| diagram_formats.select do |diagram_type|
current_settings.kroki_format_supported?(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