summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2017-10-19 15:07:18 +0300
committerKamil Trzcinski <ayufan@ayufan.eu>2017-10-19 15:07:35 +0300
commit64fd9814fdbcd2edf6a282568c645c5b2c0663e2 (patch)
tree5d5b682af1d39987ca4bccc17b620fbe3e6633c9 /spec/models
parent1090514ab407b7faa894cbd9b6cd769c376a9b5d (diff)
downloadgitlab-ce-64fd9814fdbcd2edf6a282568c645c5b2c0663e2.tar.gz
Prevent ApplicationSetting to cache nil value
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/application_setting_spec.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 6945c90cb9b..30495fd4f5e 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -220,6 +220,21 @@ describe ApplicationSetting do
expect(described_class.current).to eq(:last)
end
end
+
+ context 'when an ApplicationSetting is not yet present' do
+ it 'does not cache nil object' do
+ # when missing settings a nil object is returned, but not cached
+ allow(described_class).to receive(:last).and_return(nil).twice
+ expect(described_class.current).to be_nil
+
+ # when the settings are set the method returns a valid object
+ allow(described_class).to receive(:last).and_return(:last)
+ expect(described_class.current).to eq(:last)
+
+ # subsequent calls get everything from cache
+ expect(described_class.current).to eq(:last)
+ end
+ end
end
context 'restrict creating duplicates' do