Repository navigation
refactor(workshops): move the deletion policy into Workshop#deletable? - #2957
Merged
mroderick merged 2 commits intoSep 28, 2026
Merged
Conversation
mroderick
approved these changes
Sep 28, 2026
mroderick
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed and verified in a worktree of the PR branch:
Workshop#deletable?is the old controller logic moved expression for expression, same check order:invitations.blank? && Time.zone.now.between?(created_at, created_at + DELETION_WINDOW).between?stays inclusive at both ends, so behaviour is unchanged.- Nothing else references the deleted constant or helpers — the controller specs were the only external consumers and are updated to
Workshop::DELETION_WINDOW. - New model specs cover both sides of each condition: just after creation, one minute inside the window, one minute outside, and with an invitation.
- Ran
bundle exec rspec spec/models/workshop_spec.rb spec/controllers/admin/workshops_controller_spec.rb: 106 examples, 0 failures.rubocopon both app files: clean.
Non-blocking nit: DELETION_WINDOW sits between resourcify and the has_many block rather than with the other constants at the top of the model — cosmetic only.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2940
Moves the workshop deletion policy out of
Admin::WorkshopsControllerand into the model:Workshop::DELETION_WINDOW(4 hours) andWorkshop#deletable?, which is true while the workshop is within that window ofcreated_atand has no invitations.#destroynow calls@workshop.deletable?; the controller constant and its two private helpers are gone. The logic is the same two checks, moved as is, so flash messages and redirects are unchanged.Testing
#deletable?: just after creation, one minute before the window ends, one minute after it ends, and with an invitationspec/controllers/admin/workshops_controller_spec.rbdestroy specs pass (the constant reference now points atWorkshop::DELETION_WINDOW)bundle exec rspec spec/models/workshop_spec.rb spec/controllers/admin/workshops_controller_spec.rb: 106 examples, 0 failures; rubocop clean