You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a has_many relation defined with dependent: :destroy like so:
class HostNode
include Mongoid::Document
include Mongoid::Timestamps
has_many :containers, dependent: :destroy
On the other side of the relation, there's a default_scope defined:
class Container
include Mongoid::Document
include Mongoid::Timestamps
field :deleted_at, type: Time
field :container_type, type: String, default: 'container'
default_scope -> { where(deleted_at: nil, container_type: 'container') }
Now within specs when I delete a HostNode model all the Containers are deleted, even those that do NOT match the default_scope. If I do the same operation WITHOUT mongoid-rspec loaded only the containers matching the default_scope gets deleted as expected.
This is somewhat un-expected in my opinion. Why does it behave differently when mongoid-rspec is loaded and is there any way to control this? Tried to look from the code but failed miserably. :D
The text was updated successfully, but these errors were encountered:
I have a
has_many
relation defined withdependent: :destroy
like so:On the other side of the relation, there's a
default_scope
defined:Now within specs when I delete a
HostNode
model all theContainers
are deleted, even those that do NOT match the default_scope. If I do the same operation WITHOUTmongoid-rspec
loaded only the containers matching thedefault_scope
gets deleted as expected.This is somewhat un-expected in my opinion. Why does it behave differently when
mongoid-rspec
is loaded and is there any way to control this? Tried to look from the code but failed miserably. :DThe text was updated successfully, but these errors were encountered: