Repository navigation
Fix after-callback transitions on Mongoid 8.1 (QUAL-2685) - #12
Merged
roloand merged 5 commits intoOct 30, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
roloand
commented
Oct 30, 2026
The run-once guard hid duplicate dispatches from the old assertion. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ubuntu-latest is now 26.04, which has no prebuilt Ruby 3.0 or 3.1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
roloand
marked this pull request as ready for review
October 30, 2026 20:55
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.
Summary
Fixes after_save/after_update transition callbacks on Mongoid 8.1 (QUAL-2685), adds real-MongoDB specs, makes the 8.1 CI cells required, bumps to 0.1.3.
Root cause (verified)
Specs were written first and run against real Mongo before any lib change: on both 8.1 combos 6 of 8 failed (after_save on create, after_save on update, run-once, subsequent transition, after_update); 7.4 combos failed only the after_update specs. This confirms the spec's theory: Mongoid 8.1 empties
changes[field]insideafter_save, soprocess_state_transition_from_changesfinds nothing.Extra finding not in the spec:
after_updatetransitions never fired on any Mongoid version (7.4 too) becausedefine_state_attributeonly registered before_save/after_save/validation hooks and never dispatched:after_update. The newafter_updatehook fixes that too.Change
before_savecaptureschanges[field]per instance;after_updateandafter_savereplay the captured change (after_save clears it inensure).spec/mongoid_after_callbacks_spec.rb(real MongoDB, create and update).continue-on-error/experimentalfrom the 8.1 cells.Verification
Full suite, 68 examples, 0 failures on as6.1/as7.0 x mongoid7.4/8.1 (Ruby 3.0.6, mongo:7.0 local).
Decisions made
add_run_once_callbackleft in place (callback DSL refactor is out of scope); consequence: the same from->to transition on one instance fires once per lifecycle, as before.before_create/after_create/before_updateDSL events are still never dispatched; not fixed, follow-up candidate.errors[field] <<(PR QUAL-2625: Modernize CI with Rails and Mongoid matrix #11).🤖 Generated with Claude Code