summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/current_settings_spec.rb
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2017-01-21 22:55:35 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2017-01-21 22:55:35 +0000
commitbaeaa97ef49558a303b0bd7b6cc9ce4ccfc13d1d (patch)
treec009601bc21af2f88f0d246427d5fbe3db5e5bb2 /spec/lib/gitlab/current_settings_spec.rb
parentf6f52b43b59641f5e0c6f7aa47b1354ca3aeee32 (diff)
downloadgitlab-ce-baeaa97ef49558a303b0bd7b6cc9ce4ccfc13d1d.tar.gz
Revert "Merge branch 'dont-persist-application-settings-in-test-env' into 'master'"
This reverts merge request !8573
Diffstat (limited to 'spec/lib/gitlab/current_settings_spec.rb')
-rw-r--r--spec/lib/gitlab/current_settings_spec.rb68
1 files changed, 20 insertions, 48 deletions
diff --git a/spec/lib/gitlab/current_settings_spec.rb b/spec/lib/gitlab/current_settings_spec.rb
index b01c4805a34..004341ffd02 100644
--- a/spec/lib/gitlab/current_settings_spec.rb
+++ b/spec/lib/gitlab/current_settings_spec.rb
@@ -1,64 +1,36 @@
require 'spec_helper'
describe Gitlab::CurrentSettings do
- include StubENV
-
- before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
- end
-
describe '#current_application_settings' do
- context 'with DB available' do
- before do
- allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(true)
- end
-
- it 'attempts to use cached values first' do
- expect(ApplicationSetting).to receive(:current)
- expect(ApplicationSetting).not_to receive(:last)
-
- expect(current_application_settings).to be_a(ApplicationSetting)
- end
+ it 'attempts to use cached values first' do
+ allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(true)
+ expect(ApplicationSetting).to receive(:current).and_return(::ApplicationSetting.create_from_defaults)
+ expect(ApplicationSetting).not_to receive(:last)
- it 'falls back to DB if Redis returns an empty value' do
- expect(ApplicationSetting).to receive(:last).and_call_original
-
- expect(current_application_settings).to be_a(ApplicationSetting)
- end
+ expect(current_application_settings).to be_a(ApplicationSetting)
+ end
- it 'falls back to DB if Redis fails' do
- expect(ApplicationSetting).to receive(:current).and_raise(::Redis::BaseError)
- expect(ApplicationSetting).to receive(:last).and_call_original
+ it 'does not attempt to connect to DB or Redis' do
+ allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(false)
+ expect(ApplicationSetting).not_to receive(:current)
+ expect(ApplicationSetting).not_to receive(:last)
- expect(current_application_settings).to be_a(ApplicationSetting)
- end
+ expect(current_application_settings).to eq fake_application_settings
end
- context 'with DB unavailable' do
- before do
- allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(false)
- end
+ it 'falls back to DB if Redis returns an empty value' do
+ allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(true)
+ expect(ApplicationSetting).to receive(:last).and_call_original
- it 'returns an in-memory ApplicationSetting object' do
- expect(ApplicationSetting).not_to receive(:current)
- expect(ApplicationSetting).not_to receive(:last)
-
- expect(current_application_settings).to be_a(OpenStruct)
- end
+ expect(current_application_settings).to be_a(ApplicationSetting)
end
- context 'when ENV["IN_MEMORY_APPLICATION_SETTINGS"] is true' do
- before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'true')
- end
-
- it 'returns an in-memory ApplicationSetting object' do
- expect(ApplicationSetting).not_to receive(:current)
- expect(ApplicationSetting).not_to receive(:last)
+ it 'falls back to DB if Redis fails' do
+ allow_any_instance_of(Gitlab::CurrentSettings).to receive(:connect_to_db?).and_return(true)
+ expect(ApplicationSetting).to receive(:current).and_raise(::Redis::BaseError)
+ expect(ApplicationSetting).to receive(:last).and_call_original
- expect(current_application_settings).to be_a(ApplicationSetting)
- expect(current_application_settings).not_to be_persisted
- end
+ expect(current_application_settings).to be_a(ApplicationSetting)
end
end
end