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.
This commit is contained in:
committed by
Eugen Rochko
parent
a71af98401
commit
9b8a448477
@ -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
|
||||
|
Reference in New Issue
Block a user