2026-01-02 13:41:09 +00:00
|
|
|
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
2023-08-09 10:45:45 +00:00
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
|
|
RSpec.describe Auth::RequestCache do
|
2023-08-10 09:28:20 +00:00
|
|
|
describe '.fetch' do
|
|
|
|
|
it 'does cache true values' do
|
|
|
|
|
described_class.fetch_value('a') { true }
|
|
|
|
|
value_a = described_class.fetch_value('a') { 'bb' }
|
2023-08-09 10:45:45 +00:00
|
|
|
|
2023-08-10 09:28:20 +00:00
|
|
|
expect(value_a).to be(true)
|
|
|
|
|
end
|
2023-08-09 10:45:45 +00:00
|
|
|
|
2023-08-10 09:28:20 +00:00
|
|
|
it 'does cache false values' do
|
|
|
|
|
described_class.fetch_value('a') { false }
|
|
|
|
|
value_a = described_class.fetch_value('a') { 'bb' }
|
2023-08-09 10:45:45 +00:00
|
|
|
|
2023-08-10 09:28:20 +00:00
|
|
|
expect(value_a).to be(false)
|
2023-08-09 10:45:45 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2023-08-10 09:28:20 +00:00
|
|
|
describe '.clear' do
|
|
|
|
|
it 'does clear after update of an object' do
|
|
|
|
|
described_class.fetch_value('a') { true }
|
2024-09-12 09:09:36 +00:00
|
|
|
|
|
|
|
|
expect { Ticket.first.touch }
|
|
|
|
|
.to change { described_class.request_cache.key? 'a' }
|
|
|
|
|
.to(false)
|
2023-08-09 10:45:45 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|