SystemStackError when updating fixtures
wakairo opened this issue · 1 comments
wakairo commented
In rails test, the following test code causes an error: SystemStackError: stack level too deep.
node = nodes(:one)
node.update(parent_id: node.id)Node (class of the node) has closure tree as below.
class Node < ApplicationRecord
has_closure_tree
endIt seems that the following conditions are needed to reproduce this error:
- The node object is made from fixtures.
- Updating parent_id of the node to an id of self or descendants.
I have made a repository for this issue. To reproduce this error on this repository, please execute rails test command.
Repository: https://github.com/wakairo/issue-closure_tree-error_on_update
jkraemer commented
To work around this, you could try to either put the node_hierarchies table into fixtures as well, or call Node.rebuild! after fixtures are loaded but before tests are run.