@ -160,7 +160,11 @@ RSpec.describe PrefillFieldsHelper, type: :helper do
# First call - cache miss
# First call - cache miss
result1 = helper . extract_ats_prefill_fields
result1 = helper . extract_ats_prefill_fields
expect ( result1 ) . to eq ( fields )
expect ( result1 ) . to eq ( fields )
expect ( Rails . logger ) . to have_received ( :debug ) . with ( a_string_matching ( / cache miss / ) )
# Verify cache miss was logged
expect ( Rails . logger ) . to have_received ( :debug ) . at_least ( :once ) do | & block |
block & . call & . include? ( 'cache miss' )
end
# Reset logger expectations
# Reset logger expectations
allow ( Rails . logger ) . to receive ( :debug )
allow ( Rails . logger ) . to receive ( :debug )
@ -168,7 +172,11 @@ RSpec.describe PrefillFieldsHelper, type: :helper do
# Second call - should be cache hit
# Second call - should be cache hit
result2 = helper . extract_ats_prefill_fields
result2 = helper . extract_ats_prefill_fields
expect ( result2 ) . to eq ( fields )
expect ( result2 ) . to eq ( fields )
expect ( Rails . logger ) . to have_received ( :debug ) . with ( a_string_matching ( / cache hit / ) )
# Verify cache hit was logged
expect ( Rails . logger ) . to have_received ( :debug ) . at_least ( :once ) do | & block |
block & . call & . include? ( 'cache hit' )
end
end
end
it 'caches empty results for parsing errors' do
it 'caches empty results for parsing errors' do
@ -185,10 +193,17 @@ RSpec.describe PrefillFieldsHelper, type: :helper do
cached_value = Rails . cache . read ( cache_key )
cached_value = Rails . cache . read ( cache_key )
expect ( cached_value ) . to eq ( [ ] )
expect ( cached_value ) . to eq ( [ ] )
# Reset logger expectations
allow ( Rails . logger ) . to receive ( :debug )
# Second call should return cached empty result
# Second call should return cached empty result
result2 = helper . extract_ats_prefill_fields
result2 = helper . extract_ats_prefill_fields
expect ( result2 ) . to eq ( [ ] )
expect ( result2 ) . to eq ( [ ] )
expect ( Rails . logger ) . to have_received ( :debug ) . with ( a_string_matching ( / cache hit / ) )
# Verify cache hit was logged
expect ( Rails . logger ) . to have_received ( :debug ) . at_least ( :once ) do | & block |
block & . call & . include? ( 'cache hit' )
end
end
end
it 'generates consistent cache keys for same input' do
it 'generates consistent cache keys for same input' do