-
Notifications
You must be signed in to change notification settings - Fork 57
/
base_service_spec.rb
69 lines (56 loc) · 2.04 KB
/
base_service_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# frozen_string_literal: true
require 'rails_helper'
describe CheckIn::VAOS::BaseService do
subject { described_class.build(check_in_session:) }
let(:uuid) { 'd602d9eb-9a31-484f-9637-13ab0b507e0d' }
let(:check_in_session) { CheckIn::V2::Session.build(data: { uuid: }) }
let(:patient_icn) { '123' }
let(:token) { 'test_token' }
let(:request_id) { SecureRandom.uuid }
describe '.build' do
it 'returns an instance of Service' do
expect(subject).to be_an_instance_of(described_class)
end
end
describe '#initialize' do
before do
allow_any_instance_of(V2::Lorota::RedisClient).to receive(:icn).with(uuid:)
.and_return(patient_icn)
end
it 'has a check_in_session object' do
expect(subject.check_in_session).to be_a(CheckIn::V2::Session)
end
it 'has a patient icn' do
expect(subject.patient_icn).to eq(patient_icn)
end
end
describe '#config' do
it 'returns an instance of Configuration' do
expect(subject.config).to be_an_instance_of(CheckIn::VAOS::Configuration)
end
end
describe '#headers' do
before do
RequestStore.store['request_id'] = request_id
allow_any_instance_of(CheckIn::Map::TokenService).to receive(:token).and_return(token)
end
it 'returns correct headers' do
expect(subject.headers).to eq({ 'Referer' => 'https://review-instance.va.gov',
'X-VAMF-JWT' => token,
'X-Request-ID' => request_id })
end
end
describe '#referrer' do
context 'when ends in .gov' do
it 'returns the hostname with "vets" replaced with "va"' do
allow(Settings).to receive(:hostname).and_return('veteran.apps.vets.gov')
expect(subject.referrer).to eq('https://veteran.apps.va.gov')
end
end
context 'when does not end in .gov' do
it 'returns https://review-instance.va.gov' do
expect(subject.referrer).to eq('https://review-instance.va.gov')
end
end
end
end