# Unit test problem -- BetterNestedSet?

**URL:** <https://www.ruby-forum.com/t/unit-test-problem-betternestedset/89123>\
**Category:** Rails\
**Created:** [March 17, 2007, 2:29pm UTC](https://www.ruby-forum.com/t/unit-test-problem-betternestedset/89123 "2007-03-17T14:29:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![al-evans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/54ee81/32.png) [@al-evans](https://www.ruby-forum.com/u/al-evans)\
**Post date:** [March 17, 2007, 2:29pm UTC](https://www.ruby-forum.com/t/unit-test-problem-betternestedset/89123/1 "2007-03-17T14:29:36Z")

</div>

After adding

validates\_uniqueness\_of :login\_name

to a User model that acts\_as\_nested\_set using BetterNestedSet, my unit  
tests started failing.

On investigation, I found that valid? wasn’t true for the records in  
question after they were created.

Running the exact same sequence of tests by hand in the console –  
creating records, then calling move\_to\_child\_of on them – works fine.  
If I comment out the validation, the tests run fine.

Does anybody know what’s happening here?

Thanks!

–Al Evans
