diff --git a/app/controllers/vaccinations_controller.rb b/app/controllers/vaccinations_controller.rb index 0a0ce47a7..581c71902 100644 --- a/app/controllers/vaccinations_controller.rb +++ b/app/controllers/vaccinations_controller.rb @@ -109,11 +109,7 @@ def confirm_destroy def destroy authorize @vaccination_record - if @vaccination_record.session.today? - @vaccination_record.destroy! - else - @vaccination_record.discard! - end + @vaccination_record.discard! redirect_to session_patient_path(id: @patient.id), flash: { diff --git a/spec/features/delete_vaccination_record_spec.rb b/spec/features/delete_vaccination_record_spec.rb index 44c639176..e194a2892 100644 --- a/spec/features/delete_vaccination_record_spec.rb +++ b/spec/features/delete_vaccination_record_spec.rb @@ -3,12 +3,9 @@ describe "Delete vaccination record" do before { Flipper.enable(:release_1b) } - after do - Flipper.disable(:release_1b) - travel_back - end + after { Flipper.disable(:release_1b) } - scenario "User deletes a vaccination record same day as session" do + scenario "User deletes a vaccination record" do given_an_hpv_programme_is_underway and_an_administered_vaccination_record_exists @@ -27,30 +24,6 @@ and_i_see_a_successful_message and_they_can_be_vaccinated - when_i_click_on_the_log - then_i_see_no_vaccinations - end - - scenario "User deletes a vaccination record different session date" do - given_an_hpv_programme_is_underway - and_an_administered_vaccination_record_exists - and_its_the_day_after_the_session - - when_i_go_to_a_patient_that_is_vaccinated - and_i_click_on_delete_vaccination_record - then_i_see_the_delete_vaccination_page - - when_i_dont_delete_the_vaccination_record - then_i_see_the_patient - and_they_are_already_vaccinated - and_i_click_on_delete_vaccination_record - then_i_see_the_delete_vaccination_page - - when_i_delete_the_vaccination_record - then_i_see_the_patient - and_i_see_a_successful_message - and_they_can_be_vaccinated - when_i_click_on_the_log then_i_see_the_delete_vaccination end @@ -58,7 +31,6 @@ scenario "User deletes a vaccination record on a closed session date" do given_an_hpv_programme_is_underway and_an_administered_vaccination_record_exists - and_its_the_day_after_the_session and_the_session_has_closed when_i_go_to_a_patient_that_is_vaccinated @@ -70,7 +42,12 @@ def given_an_hpv_programme_is_underway @programme = create(:programme, :hpv, organisations: [@organisation]) @session = - create(:session, organisation: @organisation, programme: @programme) + create( + :session, + date: Date.yesterday, + organisation: @organisation, + programme: @programme + ) @patient = create( @@ -99,10 +76,6 @@ def and_an_administered_vaccination_record_exists ) end - def and_its_the_day_after_the_session - travel 1.day - end - def and_the_session_has_closed @session.close! end @@ -153,10 +126,6 @@ def when_i_click_on_the_log click_on "Activity log" end - def then_i_see_no_vaccinations - expect(page).not_to have_content("Vaccinated") - end - def then_i_see_the_delete_vaccination expect(page).to have_content("Vaccinated with Gardasil 9") expect(page).to have_content("HPV vaccination record deleted")