From da5663403b2339b227e361d56392171847e86fff Mon Sep 17 00:00:00 2001 From: khoa-v-nguyen Date: Fri, 20 Dec 2024 12:29:25 -0700 Subject: [PATCH] Fix bug in HealthFacilitiesController#retrieve_patsr_approved_facilities --- .../ask_va_api/v0/health_facilities_controller.rb | 5 ++--- .../spec/requests/ask_va_api/v0/health_facilities_spec.rb | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/ask_va_api/app/controllers/ask_va_api/v0/health_facilities_controller.rb b/modules/ask_va_api/app/controllers/ask_va_api/v0/health_facilities_controller.rb index 3ae027333db..45201000688 100644 --- a/modules/ask_va_api/app/controllers/ask_va_api/v0/health_facilities_controller.rb +++ b/modules/ask_va_api/app/controllers/ask_va_api/v0/health_facilities_controller.rb @@ -18,7 +18,7 @@ def search end end - patsr_approved_codes = retrieve_patsr_approved_facilities.pluck(:FacilityCode) + patsr_approved_codes = retrieve_patsr_approved_facilities[:Data].pluck(:FacilityCode) filtered_results = WillPaginate::Collection.create( api_results.current_page, @@ -42,8 +42,7 @@ def show private def retrieve_patsr_approved_facilities - data = Crm::CacheData.new.fetch_and_cache_data(endpoint: 'Facilities', cache_key: 'Facilities', payload: {}) - JSON.parse(data, symbolize_names: true)[:Data] + Crm::CacheData.new.fetch_and_cache_data(endpoint: 'Facilities', cache_key: 'Facilities', payload: {}) end def api diff --git a/modules/ask_va_api/spec/requests/ask_va_api/v0/health_facilities_spec.rb b/modules/ask_va_api/spec/requests/ask_va_api/v0/health_facilities_spec.rb index 40b01d2980d..ce5e24013cf 100644 --- a/modules/ask_va_api/spec/requests/ask_va_api/v0/health_facilities_spec.rb +++ b/modules/ask_va_api/spec/requests/ask_va_api/v0/health_facilities_spec.rb @@ -79,7 +79,8 @@ let(:cache_data_instance) { Crm::CacheData.new } let(:patsr_facilities) do - File.read('modules/ask_va_api/config/locales/get_facilities_mock_data.json') + data = File.read('modules/ask_va_api/config/locales/get_facilities_mock_data.json') + JSON.parse(data, symbolize_names: true) end before do