Skip to content

Fix/paranoia soft delete#6854

Merged
compwron merged 3 commits intorubyforgood:mainfrom
alanparmenter:fix/paranoia-soft-delete
Apr 15, 2026
Merged

Fix/paranoia soft delete#6854
compwron merged 3 commits intorubyforgood:mainfrom
alanparmenter:fix/paranoia-soft-delete

Conversation

@alanparmenter
Copy link
Copy Markdown
Contributor

What github issue is this PR for, if any?

Resolves #6837

What changed, and why?

acts_as_paranoid added toContactTopicAnswer to enable soft deletion. deleted_at column introduced via migration to support this.

How is this tested? (please write rspec and jest tests!) 💖💪

A new test in contact_topic_answer_spec.rb verifies that a ContactTopicAnswer object can be soft-deleted and restored after destruction.

Delete and undelete steps in the UI show that deletion previously removed content permanently, and after the changes the content is restored on undelete.

Screenshots please :)

Before and after screenshot videos from a browser window.

Before.Screen.Recording.2026-04-14.at.14.12.05.mov
After.Screen.Recording.2026-04-14.at.14.38.45.mov

Feelings gif (optional)

Squirrel munching with manageable paranoia)

Add `acts_as_paranoid` to `ContactTopicAnswer` and add `deleted_at` column via migration to support soft deletion.
Introduce test that contact topic answers are soft-deleted and restored properly
@github-actions github-actions Bot added ruby Pull requests that update Ruby code Tests! 🎉💖👏 labels Apr 14, 2026
@compwron
Copy link
Copy Markdown
Collaborator

Please fix failing spec


  1) /contact_topic_answers POST /create returns the record as json
     Failure/Error:
       expect(response_json.keys)
         .to contain_exactly(:id, :contact_topic_id, :value, :case_contact_id, :created_at, :updated_at, :selected)

       expected collection contained:  [:case_contact_id, :contact_topic_id, :created_at, :id, :selected, :updated_at, :value]
       actual collection contained:    [:case_contact_id, :contact_topic_id, :created_at, :deleted_at, :id, :selected, :updated_at, :value]
       the extra elements were:        [:deleted_at]
     # ./spec/requests/contact_topic_answers_spec.rb:38:in 'block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:133:in 'block (2 levels) in <top (required)>'
     # ./spec/rails_helper.rb:118:in 'block (3 levels) in <top (required)>'
     # ./spec/rails_helper.rb:117:in 'block (2 levels) in <top (required)>'
     # ./spec/support/prosopite.rb:56:in 'block (2 levels) in <top (required)>'

compwron
compwron previously approved these changes Apr 15, 2026
@compwron compwron merged commit 21e937a into rubyforgood:main Apr 15, 2026
11 checks passed
@alanparmenter alanparmenter deleted the fix/paranoia-soft-delete branch April 15, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code Tests! 🎉💖👏

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: contact topic answers are permanently deleted when a case contact is soft-deleted

2 participants