|
47 | 47 | created_at: Time.zone.parse("2021-02-07T13:28:17.271+00:00") |
48 | 48 | ) |
49 | 49 | end |
50 | | - let!(:stubbed_request) do |
51 | | - stub_request( |
52 | | - :post, |
53 | | - "https://sandbox.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4/Immunization" |
54 | | - ).to_return( |
55 | | - status: 201, |
56 | | - body: "", |
57 | | - headers: { |
58 | | - location: |
59 | | - "https://sandbox.api.service.nhs.uk/immunisation-fhir-api/Immunization/ffff1111-eeee-2222-dddd-3333eeee4444" |
60 | | - } |
61 | | - ) |
62 | | - end |
63 | 50 |
|
64 | 51 | describe "record_immunisation" do |
65 | | - before { Flipper.enable(:immunisations_fhir_api_integration) } |
| 52 | + let!(:request_stub) do |
| 53 | + stub_request( |
| 54 | + :post, |
| 55 | + "https://sandbox.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4/Immunization" |
| 56 | + ).to_return( |
| 57 | + status: 201, |
| 58 | + body: "", |
| 59 | + headers: { |
| 60 | + location: |
| 61 | + "https://sandbox.api.service.nhs.uk/immunisation-fhir-api/Immunization/ffff1111-eeee-2222-dddd-3333eeee4444" |
| 62 | + } |
| 63 | + ) |
| 64 | + end |
66 | 65 |
|
67 | 66 | it "sends the correct JSON payload" do |
68 | 67 | expected_body = |
69 | 68 | File.read(Rails.root.join("spec/fixtures/fhir/immunisation.json")).chomp |
70 | 69 |
|
71 | | - # stree-ignore |
72 | | - stubbed_request = |
73 | | - stub_request( |
74 | | - :post, "https://sandbox.api.service.nhs.uk/immunisation-fhir-api/FHIR/R4/Immunization" |
| 70 | + request_stub.with do |request| |
| 71 | + expect(request.headers).to include( |
| 72 | + { |
| 73 | + "Accept" => "application/fhir+json", |
| 74 | + "Content-Type" => "application/fhir+json" |
| 75 | + } |
75 | 76 | ) |
76 | | - .with { |request| |
77 | | - expect(request.headers["Accept"]).to eq "application/fhir+json" |
78 | | - expect( |
79 | | - request.headers["Content-Type"] |
80 | | - ).to eq "application/fhir+json" |
81 | 77 | expect(request.body).to eq expected_body |
82 | 78 | true |
83 | | - } |
84 | | - .to_return(status: 201, |
85 | | - body: "", |
86 | | - headers: { |
87 | | - location: |
88 | | - "https://sandbox.api.service.nhs.uk/immunisation-fhir-api/Immunization/ffff1111-eeee-2222-dddd-3333eeee4444" |
89 | | - }) |
| 79 | + end |
90 | 80 |
|
91 | 81 | described_class.record_immunisation(vaccination_record) |
92 | 82 |
|
93 | | - expect(stubbed_request).to have_been_made |
| 83 | + expect(request_stub).to have_been_made |
94 | 84 | end |
95 | 85 |
|
96 | 86 | it "stores the id from the response" do |
|
0 commit comments