'Ensure that DBRef items in ListFields are dereferenced.'

def test_handle_old_style_references(self):

    class User(Document, ):
        name = StringField()
    class Group(Document, ):
        members = ListField(ReferenceField(User, dbref=True))
    User.drop_collection()
    Group.drop_collection()
    for i in range(1, 26):
        user = User(name=('user    %s' % i))
        user.save()
    group = Group(members=User.objects)
    group.save()
    group = Group._get_collection().find_one()
    class Group(Document, ):
        members = ListField(ReferenceField(User, dbref=False))
    group = Group.objects.first()
    group.members.append(User(name='String!').save())
    group.save()
    group = Group.objects.first()
    self.assertEqual(group.members[0].name, 'user    1')
    self.assertEqual(group.members[(-1)].name, 'String!')
