about summary refs log tree commit diff
path: root/spec/models/setting_spec.rb
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2018-02-18 06:35:05 +0900
committerEugen Rochko <eugen@zeonfederated.com>2018-02-17 22:35:05 +0100
commit9b8a4484778fb55bcb2526992807a51270229b72 (patch)
tree7dad9ae3df644227645b7607a97776e8602a56dc /spec/models/setting_spec.rb
parenta71af984011ff98df2fa1b7f6c983706a91d99bf (diff)
Isolate each specs for cache store (#6450)
The cache store is explicitly used by some specs, but they were not
isolated and therefore not reliable. This fixes the issue by clearing
the cache after each specs.
Diffstat (limited to 'spec/models/setting_spec.rb')
-rw-r--r--spec/models/setting_spec.rb13
1 files changed, 8 insertions, 5 deletions
diff --git a/spec/models/setting_spec.rb b/spec/models/setting_spec.rb
index bbba5f98d..1cc528674 100644
--- a/spec/models/setting_spec.rb
+++ b/spec/models/setting_spec.rb
@@ -42,11 +42,6 @@ RSpec.describe Setting, type: :model do
         described_class[key]
       end
 
-      it 'calls Rails.cache.fetch' do
-        expect(Rails).to receive_message_chain(:cache, :fetch).with(cache_key)
-        described_class[key]
-      end
-
       context 'Rails.cache does not exists' do
         before do
           allow(RailsSettings::Settings).to receive(:object).with(key).and_return(object)
@@ -103,6 +98,14 @@ RSpec.describe Setting, type: :model do
           Rails.cache.write(cache_key, cache_value)
         end
 
+        it 'does not query the database' do
+          expect do |callback|
+            ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
+              described_class[key]
+            end
+          end.not_to yield_control
+        end
+
         it 'returns the cached value' do
           expect(described_class[key]).to eq cache_value
         end