Skip to content

Commit

Permalink
Adding facility_type in CIE Logger util
Browse files Browse the repository at this point in the history
  • Loading branch information
kanchanasuriya committed Mar 25, 2024
1 parent 729fc84 commit ee9faf8
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
module CheckIn
module V0
class TravelClaimsController < CheckIn::ApplicationController
before_action :before_logger, only: %i[show create]
after_action :after_logger, only: %i[show create]

def create
check_in_session = CheckIn::V2::Session.build(data: { uuid: permitted_params[:uuid] }, jwt: low_auth_token)

Expand Down
8 changes: 7 additions & 1 deletion modules/check_in/lib/check_in/utils/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def common
uuid:,
controller: ctrl_name,
action: ctrl_action,
initiated_by:
initiated_by:,
facility_type:
}
end

Expand Down Expand Up @@ -73,6 +74,11 @@ def initiated_by
''
end
end

def facility_type
ctrl.params[:facility_type] || ctrl.params.dig(:session, :facility_type) ||
ctrl.params.dig(:travel_claims, :facility_type)
end
end
end
end
94 changes: 71 additions & 23 deletions modules/check_in/spec/lib/utils/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,56 @@
end

describe '#before' do
let(:controller) do
double('FooController',
controller_name: 'sessions',
action_name: 'show',
response: { body: '' },
params: { id: '123' },
permitted_params: {})
end
let(:resp) do
{
workflow: 'Min-Auth',
uuid: '123',
controller: 'sessions',
action: 'show',
initiated_by: '',
filter: :before_action
}
context 'when endpoint called without facility_type' do
let(:controller) do
double('FooController',
controller_name: 'sessions',
action_name: 'show',
response: { body: '' },
params: { id: '123' },
permitted_params: {})
end
let(:resp) do
{
workflow: 'Min-Auth',
uuid: '123',
controller: 'sessions',
action: 'show',
initiated_by: '',
facility_type: nil,
filter: :before_action
}
end

it 'returns the before info hash with nil facility_type' do
expect(described_class.build(controller).before).to eq(resp)
end
end

it 'returns the before info hash' do
expect(described_class.build(controller).before).to eq(resp)
context 'when endpoint called with facility_type' do
let(:controller) do
double('FooController',
controller_name: 'sessions',
action_name: 'show',
response: { body: '' },
params: { id: '123', facility_type: 'oh' },
permitted_params: {})
end
let(:resp) do
{
workflow: 'Min-Auth',
uuid: '123',
controller: 'sessions',
action: 'show',
initiated_by: '',
facility_type: 'oh',
filter: :before_action
}
end

it 'returns the before info hash with nil facility_type' do
expect(described_class.build(controller).before).to eq(resp)
end
end
end

Expand All @@ -49,7 +78,7 @@
}
end

context 'when set_e_checkin_started_called = false' do
context 'when set_e_checkin_started_called = false without facility_type' do
let(:controller) do
double('FooController',
controller_name: 'patient_check_ins',
Expand All @@ -59,15 +88,15 @@
permitted_params: { uuid: '345' })
end
let(:resp_with_initiated_by_vetext) do
resp.merge(initiated_by: 'vetext')
resp.merge(initiated_by: 'vetext', facility_type: nil)
end

it 'returns the after info hash with initiated_by set with vetext' do
expect(described_class.build(controller).after).to eq(resp_with_initiated_by_vetext)
end
end

context 'when set_e_checkin_started_called = true' do
context 'when set_e_checkin_started_called = true without facility_type' do
let(:controller) do
double('FooController',
controller_name: 'patient_check_ins',
Expand All @@ -77,7 +106,25 @@
permitted_params: { uuid: '123' })
end
let(:resp_with_initiated_by_veteran) do
resp.merge(initiated_by: 'veteran')
resp.merge(initiated_by: 'veteran', facility_type: nil)
end

it 'returns the after info hash with initiated_by set with vetext' do
expect(described_class.build(controller).after).to eq(resp_with_initiated_by_veteran)
end
end

context 'when set_e_checkin_started_called = true with oh facility_type' do
let(:controller) do
double('FooController',
controller_name: 'patient_check_ins',
action_name: 'show',
response: double('ResponseBody', body: '{"a":"b", "status":"success 200", "c":"d"}'),
params: { id: '123', set_e_checkin_started_called: true, facility_type: 'oh' },
permitted_params: { uuid: '123' })
end
let(:resp_with_initiated_by_veteran) do
resp.merge(initiated_by: 'veteran', facility_type: 'oh')
end

it 'returns the after info hash with initiated_by set with vetext' do
Expand All @@ -94,6 +141,7 @@
controller: 'patient_check_ins',
action: 'create',
api_status: 'success 200',
facility_type: nil,
filter: :after_action
}
end
Expand Down

0 comments on commit ee9faf8

Please sign in to comment.