-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
This just started appearing on HEAD from some of the commits in the last 2-3 days. I have an object being created and destroyed in the same spec, along with its relationship.
ruby require 'spec_helper' module Test_2779 class Invitation include Mongoid::Document include Mongoid::Timestamps belongs_to :user before_destroy :destroy_user def destroy_user self.user.destroy if self.user end end class User include Mongoid::Document include Mongoid::Timestamps has_many :invitations end end describe Mongoid do it "2779" do invitation = Test_2779::Invitation.create! user = Test_2779::User.create! user.invitations << invitation invitation.destroy end end
Failure/Error: invitation.destroy RuntimeError: can't modify frozen Hash # ./lib/mongoid/attributes.rb:139:in `[]=' # ./lib/mongoid/attributes.rb:139:in `block in write_attribute' # ./lib/mongoid/threaded/lifecycle.rb:26:in `_assigning' # ./lib/mongoid/attributes.rb:130:in `write_attribute' # ./lib/mongoid/persistence.rb:123:in `touch' # ./lib/mongoid/relations/proxy.rb:143:in `method_missing' # (eval):4:in `block in touch_user_after_create_or_destroy' # ./lib/mongoid/relations/accessors.rb:175:in `without_autobuild' # (eval):2:in `touch_user_after_create_or_destroy' # ./lib/mongoid/callbacks.rb:128:in `run_callbacks' # ./lib/mongoid/persistence.rb:34:in `destroy' # ./spec/dblock/2779_spec.rb:29:in `block (2 levels) in <top (required)>'