Commit 9cbf66b8 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Fixes configuration changes leaking to other specs

Stubs the config instead of changing the global configuration object
which can affect succeeding specs
parent 91d1c713
...@@ -9,7 +9,7 @@ RSpec.describe 'pages storage check' do ...@@ -9,7 +9,7 @@ RSpec.describe 'pages storage check' do
context 'when local store does not exist yet' do context 'when local store does not exist yet' do
before do before do
Settings.pages['local_store'] = nil stub_config(pages: { enabled: true, local_store: nil })
end end
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
...@@ -17,78 +17,42 @@ RSpec.describe 'pages storage check' do ...@@ -17,78 +17,42 @@ RSpec.describe 'pages storage check' do
context 'when pages is not enabled' do context 'when pages is not enabled' do
before do before do
Settings.pages['enabled'] = false stub_config(pages: { enabled: false })
end end
it { is_expected.to be_truthy } it { is_expected.to be_truthy }
end end
context 'when pages is enabled' do context 'when pages is enabled' do
before do using RSpec::Parameterized::TableSyntax
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 where(:local_storage_enabled, :object_storage_enabled, :raises_exception) do
it 'is true' do false | false | true
Settings.pages['local_store']['enabled'] = true false | true | false
true | false | false
expect(subject).to be_truthy true | true | false
end 1 | 0 | false
end nil | nil | true
end end
context 'when pages object storage is enabled' do with_them do
before do before do
Settings.pages['object_store']['enabled'] = true stub_config(
pages: {
enabled: true,
local_store: { enabled: local_storage_enabled },
object_store: { enabled: object_storage_enabled }
}
)
end end
context 'when pages local storage is not enabled' do it 'validates pages storage configuration' do
it 'is true' do if raises_exception
Settings.pages['local_store']['enabled'] = false expect { subject }.to raise_error(main_error_message)
else
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 expect(subject).to be_truthy
end end
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 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