8282 } . to raise_error ( ArgumentError , /not a national reporting team/ )
8383 end
8484
85+ it "raises an error when the team has no national reporting cut off date" do
86+ given_a_national_reporting_team_exists_without_a_cut_off_date
87+ expect {
88+ run_command_with_workgroup ( @national_reporting_team . workgroup )
89+ } . to raise_error (
90+ ArgumentError ,
91+ /does not have a national reporting cut off date set/
92+ )
93+ end
94+
8595 it "does not delete records that have been sent to the Imms API" do
8696 given_a_national_reporting_team_exists
8797 and_the_national_reporting_team_has_immunisation_imports_with_vaccination_records
141151 and_no_vaccination_records_are_deleted
142152 and_no_patients_are_deleted
143153 end
154+
155+ it "skips national_reporting teams that have no cut off date set" do
156+ given_a_national_reporting_team_exists_without_a_cut_off_date
157+ and_the_national_reporting_team_has_immunisation_imports_with_vaccination_records
158+
159+ when_i_run_the_command_for_all_teams
160+
161+ then_the_output_indicates_no_teams_found
162+ and_no_immunisation_imports_are_deleted
163+ and_no_vaccination_records_are_deleted
164+ and_no_patients_are_deleted
165+ end
144166 end
145167
146168 private
@@ -160,6 +182,18 @@ def given_a_national_reporting_team_exists
160182 alias_method :and_a_national_reporting_team_exists ,
161183 :given_a_national_reporting_team_exists
162184
185+ def given_a_national_reporting_team_exists_without_a_cut_off_date
186+ @national_reporting_team =
187+ create (
188+ :team ,
189+ :national_reporting ,
190+ national_reporting_cut_off_date : nil ,
191+ programmes : [ Programme . hpv , Programme . flu ] ,
192+ organisation : national_reporting_organisation ,
193+ workgroup : "national-reporting-team"
194+ )
195+ end
196+
163197 def and_the_feature_flag_is_enabled
164198 Flipper . enable ( :sync_national_reporting_to_imms_api )
165199 end
0 commit comments