Skip to content

Commit

Permalink
Show all vaccination deletions in activity log
Browse files Browse the repository at this point in the history
The current behaviour seems to be confusing for users, where we don't
always show vaccination records as having been deleted in the activity
log. This changes that to be consistent and always show the information
in the log, as suggested by our designer.
  • Loading branch information
thomasleese committed Nov 18, 2024
1 parent 58766b0 commit 4324bb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 44 deletions.
6 changes: 1 addition & 5 deletions app/controllers/vaccinations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
47 changes: 8 additions & 39 deletions spec/features/delete_vaccination_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -27,38 +24,13 @@
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

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
Expand All @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 4324bb0

Please sign in to comment.