|
29 | 29 | context "when the vaccination record isn't syncable" do |
30 | 30 | before do |
31 | 31 | allow(vaccination_record).to receive( |
32 | | - :syncable_to_nhs_immunisations_api? |
| 32 | + :correct_source_for_nhs_immunisations_api? |
33 | 33 | ).and_return(false) |
34 | 34 | end |
35 | 35 |
|
|
71 | 71 | end |
72 | 72 | end |
73 | 73 |
|
74 | | - describe "syncable_to_nhs_immunisations_api scope" do |
75 | | - subject { VaccinationRecord.syncable_to_nhs_immunisations_api } |
| 74 | + describe "with_correct_source_for_nhs_immunisations_api scope" do |
| 75 | + subject { VaccinationRecord.with_correct_source_for_nhs_immunisations_api } |
| 76 | + |
| 77 | + before { Flipper.enable(:sync_national_reporting_to_imms_api) } |
76 | 78 |
|
77 | 79 | let!(:vaccination_record) do |
78 | 80 | create(:vaccination_record, programme:, session:) |
|
83 | 85 |
|
84 | 86 | it { should include(vaccination_record) } |
85 | 87 | it { should_not include(vaccination_record_outside_of_session) } |
| 88 | + |
| 89 | + context "when vaccination record was uploaded through national reporting portal" do |
| 90 | + let!(:vaccination_record) do |
| 91 | + create(:vaccination_record, :sourced_from_bulk_upload, programme:) |
| 92 | + end |
| 93 | + |
| 94 | + it { should include(vaccination_record) } |
| 95 | + |
| 96 | + context "with the sync_national_reporting_to_imms_api feature flag disabled" do |
| 97 | + before { Flipper.disable(:sync_national_reporting_to_imms_api) } |
| 98 | + |
| 99 | + let!(:vaccination_record) do |
| 100 | + create(:vaccination_record, :sourced_from_bulk_upload, programme:) |
| 101 | + end |
| 102 | + |
| 103 | + it { should_not include(vaccination_record) } |
| 104 | + end |
| 105 | + end |
| 106 | + |
| 107 | + context "when vaccination record was part of a historical upload" do |
| 108 | + let!(:vaccination_record) do |
| 109 | + create(:vaccination_record, source: :historical_upload, programme:) |
| 110 | + end |
| 111 | + |
| 112 | + it { should_not include(vaccination_record) } |
| 113 | + end |
| 114 | + |
| 115 | + context "a vaccination record created because patient is already vaccinated" do |
| 116 | + let!(:vaccination_record) do |
| 117 | + create(:vaccination_record, source: :consent_refusal, programme:) |
| 118 | + end |
| 119 | + |
| 120 | + it { should_not include(vaccination_record) } |
| 121 | + end |
86 | 122 | end |
87 | 123 |
|
88 | | - describe "#syncable_to_nhs_immunisations_api?" do |
89 | | - subject { vaccination_record.syncable_to_nhs_immunisations_api? } |
| 124 | + describe "#correct_source_to_nhs_immunisations_api?" do |
| 125 | + subject { vaccination_record.correct_source_for_nhs_immunisations_api? } |
| 126 | + |
| 127 | + before { Flipper.enable(:sync_national_reporting_to_imms_api) } |
90 | 128 |
|
91 | 129 | context "when the vaccination record is eligible to sync" do |
92 | 130 | it { should be true } |
|
104 | 142 | it { should be false } |
105 | 143 | end |
106 | 144 |
|
| 145 | + context "a vaccination record uploaded through national reporting portal" do |
| 146 | + let(:vaccination_record) do |
| 147 | + build( |
| 148 | + :vaccination_record, |
| 149 | + :sourced_from_bulk_upload, |
| 150 | + outcome:, |
| 151 | + programme: |
| 152 | + ) |
| 153 | + end |
| 154 | + |
| 155 | + it { should be true } |
| 156 | + |
| 157 | + context "with the sync_national_reporting_to_imms_api feature flag disabled" do |
| 158 | + before { Flipper.disable(:sync_national_reporting_to_imms_api) } |
| 159 | + |
| 160 | + it { should be false } |
| 161 | + end |
| 162 | + end |
| 163 | + |
| 164 | + context "a vaccination record created because patient is already vaccinated" do |
| 165 | + let(:vaccination_record) do |
| 166 | + build( |
| 167 | + :vaccination_record, |
| 168 | + source: :consent_refusal, |
| 169 | + outcome:, |
| 170 | + programme: |
| 171 | + ) |
| 172 | + end |
| 173 | + |
| 174 | + it { should be false } |
| 175 | + end |
| 176 | + |
107 | 177 | context "a patient without an nhs number" do |
108 | 178 | let(:patient) do |
109 | 179 | create(:patient, nhs_number: nil, school: session.location) |
|
0 commit comments