request_cache_spec.rb 796 B

12345678910111213141516171819202122232425262728293031
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Auth::RequestCache do
  4. describe '.fetch' do
  5. it 'does cache true values' do
  6. described_class.fetch_value('a') { true }
  7. value_a = described_class.fetch_value('a') { 'bb' }
  8. expect(value_a).to be(true)
  9. end
  10. it 'does cache false values' do
  11. described_class.fetch_value('a') { false }
  12. value_a = described_class.fetch_value('a') { 'bb' }
  13. expect(value_a).to be(false)
  14. end
  15. end
  16. describe '.clear' do
  17. it 'does clear after update of an object' do
  18. described_class.fetch_value('a') { true }
  19. expect { Ticket.first.touch }
  20. .to change { described_class.request_cache.key? 'a' }
  21. .to(false)
  22. end
  23. end
  24. end