mirror of
https://github.com/internetee/registry.git
synced 2025-07-27 21:16:12 +02:00
refactor
This commit is contained in:
parent
a11c0fca2d
commit
ea8fa01f9b
2 changed files with 0 additions and 7 deletions
|
@ -90,17 +90,14 @@ class OrgRegistrantPhoneCheckerJob < ApplicationJob
|
|||
def fetch_phone_number_from_company_register(company_code)
|
||||
cache_key = "company_register:#{company_code}:phone_numbers"
|
||||
|
||||
# Skip cache in test environment if environment variable is set
|
||||
return fetch_from_company_register(company_code) if Rails.env.test? && ENV['SKIP_COMPANY_REGISTER_CACHE']
|
||||
|
||||
# Try to get data from cache
|
||||
Rails.cache.fetch(cache_key, expires_in: CACHE_EXPIRES_IN) do
|
||||
fetch_from_company_register(company_code)
|
||||
end
|
||||
end
|
||||
|
||||
def fetch_from_company_register(company_code)
|
||||
# If not in cache, request API with retries
|
||||
with_retry(
|
||||
exceptions: API_EXCEPTIONS,
|
||||
logger: Rails.logger,
|
||||
|
|
|
@ -13,15 +13,11 @@ class OrgRegistrantPhoneCheckerJobTest < ActiveSupport::TestCase
|
|||
ident: '12345678'
|
||||
)
|
||||
|
||||
# Set environment variable to skip cache in tests
|
||||
ENV['SKIP_COMPANY_REGISTER_CACHE'] = 'true'
|
||||
|
||||
# Clear cache before each test to avoid interference
|
||||
Rails.cache.clear if defined?(Rails.cache)
|
||||
end
|
||||
|
||||
teardown do
|
||||
# Reset environment variable after tests
|
||||
ENV['SKIP_COMPANY_REGISTER_CACHE'] = nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue