Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
70 lines
2.1 KiB
Ruby
70 lines
2.1 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe CacheKeys do
|
|
let(:test_model) do
|
|
Struct.new(:id) do
|
|
include CacheKeys
|
|
|
|
def fetch_value_for_key(_id, _key)
|
|
'value'
|
|
end
|
|
end.new(1)
|
|
end
|
|
|
|
before do
|
|
allow(Redis::Alfred).to receive(:delete)
|
|
allow(Redis::Alfred).to receive(:set)
|
|
allow(Redis::Alfred).to receive(:setex)
|
|
allow(Rails.configuration.dispatcher).to receive(:dispatch)
|
|
end
|
|
|
|
describe '#cache_keys' do
|
|
it 'returns a hash of cache keys' do
|
|
expected_keys = test_model.class.cacheable_models.map do |model|
|
|
[model.name.underscore.to_sym, 'value']
|
|
end.to_h
|
|
|
|
expect(test_model.cache_keys).to eq(expected_keys)
|
|
end
|
|
end
|
|
|
|
describe '#update_cache_key' do
|
|
it 'updates the cache key' do
|
|
allow(Time).to receive(:now).and_return(Time.parse('2023-05-29 00:00:00 UTC'))
|
|
test_model.update_cache_key('label')
|
|
expect(Redis::Alfred).to have_received(:setex).with('idb-cache-key-account-1-label', kind_of(Integer), CacheKeys::CACHE_KEYS_EXPIRY)
|
|
end
|
|
|
|
it 'dispatches a cache update event' do
|
|
test_model.update_cache_key('label')
|
|
expect(Rails.configuration.dispatcher).to have_received(:dispatch).with(
|
|
CacheKeys::ACCOUNT_CACHE_INVALIDATED,
|
|
kind_of(ActiveSupport::TimeWithZone),
|
|
cache_keys: test_model.cache_keys,
|
|
account: test_model
|
|
)
|
|
end
|
|
end
|
|
|
|
describe '#reset_cache_keys' do
|
|
it 'invalidates all cache keys for cacheable models' do
|
|
test_model.reset_cache_keys
|
|
test_model.class.cacheable_models.each do |model|
|
|
expect(Redis::Alfred).to have_received(:setex).with("idb-cache-key-account-1-#{model.name.underscore}", kind_of(Integer),
|
|
CacheKeys::CACHE_KEYS_EXPIRY)
|
|
end
|
|
end
|
|
|
|
it 'dispatches a cache update event' do
|
|
test_model.reset_cache_keys
|
|
|
|
expect(Rails.configuration.dispatcher).to have_received(:dispatch).with(
|
|
CacheKeys::ACCOUNT_CACHE_INVALIDATED,
|
|
kind_of(ActiveSupport::TimeWithZone),
|
|
cache_keys: test_model.cache_keys,
|
|
account: test_model
|
|
)
|
|
end
|
|
end
|
|
end
|