1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
# 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
stub_config(pages: { enabled: true, local_store: nil })
end
it { is_expected.to be_truthy }
end
context 'when pages is not enabled' do
before do
stub_config(pages: { enabled: false })
end
it { is_expected.to be_truthy }
end
context 'when pages is enabled' do
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
end
with_them do
before do
stub_config(
pages: {
enabled: true,
local_store: { enabled: local_storage_enabled },
object_store: { enabled: object_storage_enabled }
}
)
end
it 'validates pages storage configuration' do
if raises_exception
expect { subject }.to raise_error(main_error_message)
else
expect(subject).to be_truthy
end
end
end
end
end
|