Skip to content

fix(models): halt destroy callbacks for datebooks, doctors and admin users - #1131

Open
raulriera wants to merge 1 commit into
masterfrom
fix/inert-destroy-guards
Open

fix(models): halt destroy callbacks for datebooks, doctors and admin users#1131
raulriera wants to merge 1 commit into
masterfrom
fix/inert-destroy-guards

Conversation

@raulriera

Copy link
Copy Markdown
Member

Summary

  • before_destroy guards on Datebook, Doctor and User returned false, which no longer halts the callback chain (Rails 5+), so datebooks/doctors with appointments and admin users were silently destroyable
  • Guards now use errors.add(:base, ...) + throw :abort
  • Reinstated the commented-out regression test for destroying a datebook with appointments
  • Doctors empty-state test setup now clears appointments before destroy_all so it still empties the practice

Test plan

  • Red tests reproduce all three broken guards
  • Green after fix
  • Full suite passes (526 runs, 0 failures)

…users

Rails 5+ ignores a false return from before_destroy; these guards were
inert, so datebooks and doctors with appointments and admin users could
be destroyed. Use errors.add + throw :abort, reinstate the commented
regression test, and clear appointments in the doctors empty-state test
setup so its destroy_all still empties the practice.
@github-actions github-actions Bot added the fix A bug has been resolved label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant