summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-03-05 23:11:43 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-03-05 23:11:43 +0000
commit13d327df4f3c52505bf8ec1144f2dedb6a351ad6 (patch)
tree546e42fe159cde302b5e4d0b923d399e79bfbf71 /spec
parent9a70fcd2e277721bbe7b9a0c92ed925ddea201b6 (diff)
downloadgitlab-ce-13d327df4f3c52505bf8ec1144f2dedb6a351ad6.tar.gz
Add latest changes from gitlab-org/gitlab@13-9-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/deprecation_toolkit_env.rb1
-rw-r--r--spec/lib/gitlab/kroki_spec.rb38
-rw-r--r--spec/models/application_setting_spec.rb26
-rw-r--r--spec/services/application_settings/update_service_spec.rb1
4 files changed, 66 insertions, 0 deletions
diff --git a/spec/deprecation_toolkit_env.rb b/spec/deprecation_toolkit_env.rb
index d2ff2d2cb37..10eaaf13aaa 100644
--- a/spec/deprecation_toolkit_env.rb
+++ b/spec/deprecation_toolkit_env.rb
@@ -61,6 +61,7 @@ module DeprecationToolkitEnv
batch-loader-1.4.0/lib/batch_loader/graphql.rb
carrierwave-1.3.1/lib/carrierwave/sanitized_file.rb
activerecord-6.0.3.4/lib/active_record/relation.rb
+ asciidoctor-2.0.12/lib/asciidoctor/extensions.rb
]
end
diff --git a/spec/lib/gitlab/kroki_spec.rb b/spec/lib/gitlab/kroki_spec.rb
new file mode 100644
index 00000000000..31d3edd158b
--- /dev/null
+++ b/spec/lib/gitlab/kroki_spec.rb
@@ -0,0 +1,38 @@
+# 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 wavedrom].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
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 9a4dd2c799b..5658057f588 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -650,6 +650,32 @@ RSpec.describe ApplicationSetting do
end
end
+ describe '#asset_proxy_whitelist' do
+ context 'when given an Array' do
+ it 'sets the domains and adds current running host' do
+ setting.asset_proxy_whitelist = ['example.com', 'assets.example.com']
+ expect(setting.asset_proxy_whitelist).to eq(['example.com', 'assets.example.com', 'localhost'])
+ end
+ end
+
+ context 'when given a String' do
+ it 'sets multiple domains with spaces' do
+ setting.asset_proxy_whitelist = 'example.com *.example.com'
+ expect(setting.asset_proxy_whitelist).to eq(['example.com', '*.example.com', 'localhost'])
+ end
+
+ it 'sets multiple domains with newlines and a space' do
+ setting.asset_proxy_whitelist = "example.com\n *.example.com"
+ expect(setting.asset_proxy_whitelist).to eq(['example.com', '*.example.com', 'localhost'])
+ end
+
+ it 'sets multiple domains with commas' do
+ setting.asset_proxy_whitelist = "example.com, *.example.com"
+ expect(setting.asset_proxy_whitelist).to eq(['example.com', '*.example.com', 'localhost'])
+ end
+ end
+ end
+
describe '#asset_proxy_allowlist' do
context 'when given an Array' do
it 'sets the domains and adds current running host' do
diff --git a/spec/services/application_settings/update_service_spec.rb b/spec/services/application_settings/update_service_spec.rb
index 1352a595ba4..258b3d25aee 100644
--- a/spec/services/application_settings/update_service_spec.rb
+++ b/spec/services/application_settings/update_service_spec.rb
@@ -123,6 +123,7 @@ RSpec.describe ApplicationSettings::UpdateService do
it_behaves_like 'invalidates markdown cache', { asset_proxy_url: 'http://test.com' }
it_behaves_like 'invalidates markdown cache', { asset_proxy_secret_key: 'another secret' }
it_behaves_like 'invalidates markdown cache', { asset_proxy_allowlist: ['domain.com'] }
+ it_behaves_like 'invalidates markdown cache', { asset_proxy_whitelist: ['domain.com'] }
context 'when also setting the local_markdown_version' do
let(:params) { { asset_proxy_enabled: true, local_markdown_version: 12 } }