summaryrefslogtreecommitdiff
path: root/spec/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'spec/initializers')
-rw-r--r--spec/initializers/active_record_locking_spec.rb4
-rw-r--r--spec/initializers/fog_google_https_private_urls_spec.rb2
-rw-r--r--spec/initializers/json_validator_patch_spec.rb39
-rw-r--r--spec/initializers/kramdown_patch_spec.rb38
-rw-r--r--spec/initializers/pages_storage_check_spec.rb94
5 files changed, 98 insertions, 79 deletions
diff --git a/spec/initializers/active_record_locking_spec.rb b/spec/initializers/active_record_locking_spec.rb
index e979fa0b793..735ef7b916b 100644
--- a/spec/initializers/active_record_locking_spec.rb
+++ b/spec/initializers/active_record_locking_spec.rb
@@ -11,13 +11,13 @@ RSpec.describe 'ActiveRecord locking' do
end
it 'can be updated' do
- issue.update(title: "New title")
+ issue.update!(title: "New title")
expect(issue.reload.lock_version).to eq(new_lock_version)
end
it 'can be deleted' do
- expect { issue.destroy }.to change { Issue.count }.by(-1)
+ expect { issue.destroy! }.to change { Issue.count }.by(-1)
end
end
diff --git a/spec/initializers/fog_google_https_private_urls_spec.rb b/spec/initializers/fog_google_https_private_urls_spec.rb
index 4825525a3d8..f7b21bf850e 100644
--- a/spec/initializers/fog_google_https_private_urls_spec.rb
+++ b/spec/initializers/fog_google_https_private_urls_spec.rb
@@ -13,11 +13,13 @@ RSpec.describe 'Fog::Storage::GoogleXML::File', :fog_requests do
end
let(:file) do
+ # rubocop:disable Rails/SaveBang
directory = storage.directories.create(key: 'data')
directory.files.create(
body: 'Hello World!',
key: 'hello_world.txt'
)
+ # rubocop:enable Rails/SaveBang
end
it 'delegates to #get_https_url' do
diff --git a/spec/initializers/json_validator_patch_spec.rb b/spec/initializers/json_validator_patch_spec.rb
deleted file mode 100644
index 5d90364ae92..00000000000
--- a/spec/initializers/json_validator_patch_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-require 'rspec-parameterized'
-
-RSpec.describe 'JSON validator patch' do
- using RSpec::Parameterized::TableSyntax
-
- let(:schema) { '{"format": "string"}' }
-
- subject { JSON::Validator.validate(schema, data) }
-
- context 'with invalid JSON' do
- where(:data) do
- [
- 'https://example.com',
- '/tmp/test.txt'
- ]
- end
-
- with_them do
- it 'does not attempt to open a file or URI' do
- allow(File).to receive(:read).and_call_original
- allow(URI).to receive(:open).and_call_original
- expect(File).not_to receive(:read).with(data)
- expect(URI).not_to receive(:open).with(data)
- expect(subject).to be true
- end
- end
- end
-
- context 'with valid JSON' do
- let(:data) { %({ 'somekey': 'value' }) }
-
- it 'validates successfully' do
- expect(subject).to be true
- end
- end
-end
diff --git a/spec/initializers/kramdown_patch_spec.rb b/spec/initializers/kramdown_patch_spec.rb
deleted file mode 100644
index 49dda9252bb..00000000000
--- a/spec/initializers/kramdown_patch_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'Kramdown patch for syntax highlighting formatters' do
- subject { Kramdown::Document.new(options + "\n" + code).to_html }
-
- let(:code) do
- <<-RUBY
-~~~ ruby
- def what?
- 42
- end
-~~~
- RUBY
- end
-
- context 'with invalid formatter' do
- let(:options) { %({::options auto_ids="false" footnote_nr="5" syntax_highlighter="rouge" syntax_highlighter_opts="{formatter: CSV, line_numbers: true\\}" /}) }
-
- it 'falls back to standard HTML and disallows CSV' do
- expect(CSV).not_to receive(:new)
- expect(::Rouge::Formatters::HTML).to receive(:new).and_call_original
-
- expect(subject).to be_present
- end
- end
-
- context 'with valid formatter' do
- let(:options) { %({::options auto_ids="false" footnote_nr="5" syntax_highlighter="rouge" syntax_highlighter_opts="{formatter: HTMLLegacy\\}" /}) }
-
- it 'allows formatter' do
- expect(::Rouge::Formatters::HTMLLegacy).to receive(:new).and_call_original
-
- expect(subject).to be_present
- end
- end
-end
diff --git a/spec/initializers/pages_storage_check_spec.rb b/spec/initializers/pages_storage_check_spec.rb
new file mode 100644
index 00000000000..a76002dbdcf
--- /dev/null
+++ b/spec/initializers/pages_storage_check_spec.rb
@@ -0,0 +1,94 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'pages storage check' do
+ let(:main_error_message) { "Please enable at least one of the two Pages storage strategy (local_store or object_store) in your config/gitlab.yml." }
+
+ subject(:initializer) { load Rails.root.join('config/initializers/pages_storage_check.rb') }
+
+ context 'when local store does not exist yet' do
+ before do
+ Settings.pages['local_store'] = nil
+ end
+
+ it { is_expected.to be_truthy }
+ end
+
+ context 'when pages is not enabled' do
+ before do
+ Settings.pages['enabled'] = false
+ end
+
+ it { is_expected.to be_truthy }
+ end
+
+ context 'when pages is enabled' do
+ before do
+ Settings.pages['enabled'] = true
+ Settings.pages['local_store'] = Settingslogic.new({})
+ end
+
+ context 'when pages object storage is not enabled' do
+ before do
+ Settings.pages['object_store']['enabled'] = false
+ end
+
+ context 'when pages local storage is not enabled' do
+ it 'raises an exception' do
+ Settings.pages['local_store']['enabled'] = false
+
+ expect { subject }.to raise_error(main_error_message)
+ end
+ end
+
+ context 'when pages local storage is enabled' do
+ it 'is true' do
+ Settings.pages['local_store']['enabled'] = true
+
+ expect(subject).to be_truthy
+ end
+ end
+ end
+
+ context 'when pages object storage is enabled' do
+ before do
+ Settings.pages['object_store']['enabled'] = true
+ end
+
+ context 'when pages local storage is not enabled' do
+ it 'is true' do
+ Settings.pages['local_store']['enabled'] = false
+
+ expect(subject).to be_truthy
+ end
+ end
+
+ context 'when pages local storage is enabled' do
+ it 'is true' do
+ Settings.pages['local_store']['enabled'] = true
+
+ expect(subject).to be_truthy
+ end
+ end
+ end
+
+ context 'when using integers instead of booleans' do
+ it 'is true' do
+ Settings.pages['local_store']['enabled'] = 1
+ Settings.pages['object_store']['enabled'] = 0
+
+ expect(subject).to be_truthy
+ end
+ end
+
+ context 'when both enabled attributes are not set' do
+ it 'raises an exception' do
+ Settings.pages['local_store']['enabled'] = nil
+ Settings.pages['object_store']['enabled'] = nil
+
+ expect { subject }.to raise_error(main_error_message)
+ end
+ end
+ end
+end