-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Automated] Merged master into target k8s
- Loading branch information
Showing
2 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
modules/check_in/app/serializers/check_in/facilities/facilities_data_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module CheckIn | ||
module Facilities | ||
class FacilitiesDataSerializer | ||
include JSONAPI::Serializer | ||
|
||
set_id(&:id) | ||
|
||
attribute :name, :type, :classification, :timezone, :phone, :physicalAddress | ||
end | ||
end | ||
end |
144 changes: 144 additions & 0 deletions
144
modules/check_in/spec/serializers/check_in/facilities/facilities_data_serializer_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe CheckIn::Facilities::FacilitiesDataSerializer do | ||
subject { described_class } | ||
|
||
let(:facilities_data) do | ||
{ | ||
id: '442', | ||
facilitiesApiId: 'vha_442', | ||
vistaSite: '442', | ||
vastParent: '442', | ||
type: 'va_health_facility', | ||
name: 'Cheyenne VA Medical Center', | ||
classification: 'VA Medical Center (VAMC)', | ||
timezone: { | ||
timeZoneId: 'America/Denver' | ||
}, | ||
lat: 41.148026, | ||
long: -104.786255, | ||
website: 'https://www.va.gov/cheyenne-health-care/locations/cheyenne-va-medical-center/', | ||
phone: { | ||
main: '307-778-7550', | ||
fax: '307-778-7381', | ||
pharmacy: '866-420-6337', | ||
afterHours: '307-778-7550', | ||
patientAdvocate: '307-778-7550 x7573', | ||
mentalHealthClinic: '307-778-7349', | ||
enrollmentCoordinator: '307-778-7550 x7579' | ||
}, | ||
mailingAddress: { | ||
type: 'postal', | ||
line: [nil, nil, nil] | ||
}, | ||
physicalAddress: { | ||
type: 'physical', | ||
line: ['2360 East Pershing Boulevard', nil, nil], | ||
city: 'Cheyenne', | ||
state: 'WY', | ||
postalCode: '82001-5356' | ||
}, | ||
mobile: false, | ||
healthService: %w[Audiology Cardiology CaregiverSupport Covid19Vaccine DentalServices Dermatology EmergencyCare | ||
Gastroenterology Gynecology MentalHealthCare Nutrition Ophthalmology Optometry Orthopedics | ||
Podiatry PrimaryCare Urology WomensHealth], | ||
operatingStatus: { | ||
code: 'NORMAL' | ||
}, | ||
visn: '19' | ||
} | ||
end | ||
|
||
describe '#serializable_hash' do | ||
context 'when all the necessary fields exist' do | ||
let(:serialized_hash_response) do | ||
{ | ||
data: { | ||
id: '442', | ||
type: :facilities_data, | ||
attributes: { | ||
type: 'va_health_facility', | ||
name: 'Cheyenne VA Medical Center', | ||
classification: 'VA Medical Center (VAMC)', | ||
timezone: { | ||
timeZoneId: 'America/Denver' | ||
}, | ||
phone: { | ||
main: '307-778-7550', | ||
fax: '307-778-7381', | ||
pharmacy: '866-420-6337', | ||
afterHours: '307-778-7550', | ||
patientAdvocate: '307-778-7550 x7573', | ||
mentalHealthClinic: '307-778-7349', | ||
enrollmentCoordinator: '307-778-7550 x7579' | ||
}, | ||
physicalAddress: { | ||
type: 'physical', | ||
line: ['2360 East Pershing Boulevard', nil, nil], | ||
city: 'Cheyenne', | ||
state: 'WY', | ||
postalCode: '82001-5356' | ||
} | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'returns a serialized hash' do | ||
facilities_struct = OpenStruct.new(facilities_data) | ||
facilities_serializer = CheckIn::Facilities::FacilitiesDataSerializer.new(facilities_struct) | ||
|
||
expect(facilities_serializer.serializable_hash).to eq(serialized_hash_response) | ||
end | ||
end | ||
|
||
context 'when name does not exist' do | ||
let(:facilities_data_without_name) do | ||
facilities_data.except!(:name) | ||
facilities_data | ||
end | ||
|
||
let(:serialized_hash_response) do | ||
{ | ||
data: { | ||
id: '442', | ||
type: :facilities_data, | ||
attributes: { | ||
name: nil, | ||
type: 'va_health_facility', | ||
classification: 'VA Medical Center (VAMC)', | ||
timezone: { | ||
timeZoneId: 'America/Denver' | ||
}, | ||
phone: { | ||
main: '307-778-7550', | ||
fax: '307-778-7381', | ||
pharmacy: '866-420-6337', | ||
afterHours: '307-778-7550', | ||
patientAdvocate: '307-778-7550 x7573', | ||
mentalHealthClinic: '307-778-7349', | ||
enrollmentCoordinator: '307-778-7550 x7579' | ||
}, | ||
physicalAddress: { | ||
type: 'physical', | ||
line: ['2360 East Pershing Boulevard', nil, nil], | ||
city: 'Cheyenne', | ||
state: 'WY', | ||
postalCode: '82001-5356' | ||
} | ||
} | ||
} | ||
} | ||
end | ||
|
||
it 'returns a serialized hash with nil in name field' do | ||
facilities_struct = OpenStruct.new(facilities_data_without_name) | ||
facilities_serializer = CheckIn::Facilities::FacilitiesDataSerializer.new(facilities_struct) | ||
|
||
expect(facilities_serializer.serializable_hash).to eq(serialized_hash_response) | ||
end | ||
end | ||
end | ||
end |