Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SystemStackError when updating fixtures #424

Open
wakairo opened this issue Sep 28, 2023 · 1 comment
Open

SystemStackError when updating fixtures #424

wakairo opened this issue Sep 28, 2023 · 1 comment

Comments

@wakairo
Copy link

wakairo commented Sep 28, 2023

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
end

It 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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants