debian-mirror-gitlab/spec/initializers/pages_storage_check_spec.rb

59 lines
1.5 KiB
Ruby
Raw Normal View History

2021-04-29 21:17:54 +05:30
# 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
2021-06-08 01:23:25 +05:30
stub_config(pages: { enabled: true, local_store: nil })
2021-04-29 21:17:54 +05:30
end
it { is_expected.to be_truthy }
end
context 'when pages is not enabled' do
before do
2021-06-08 01:23:25 +05:30
stub_config(pages: { enabled: false })
2021-04-29 21:17:54 +05:30
end
it { is_expected.to be_truthy }
end
context 'when pages is enabled' do
2021-06-08 01:23:25 +05:30
using RSpec::Parameterized::TableSyntax
where(:local_storage_enabled, :object_storage_enabled, :raises_exception) do
false | false | true
false | true | false
true | false | false
true | true | false
1 | 0 | false
nil | nil | true
2021-04-29 21:17:54 +05:30
end
2021-06-08 01:23:25 +05:30
with_them do
2021-04-29 21:17:54 +05:30
before do
2021-06-08 01:23:25 +05:30
stub_config(
pages: {
enabled: true,
local_store: { enabled: local_storage_enabled },
object_store: { enabled: object_storage_enabled }
}
)
2021-04-29 21:17:54 +05:30
end
2021-06-08 01:23:25 +05:30
it 'validates pages storage configuration' do
if raises_exception
2021-04-29 21:17:54 +05:30
expect { subject }.to raise_error(main_error_message)
2021-06-08 01:23:25 +05:30
else
2021-04-29 21:17:54 +05:30
expect(subject).to be_truthy
end
end
end
end
end