'Ensure that DBRef items in ListFields are dereferenced.'

def test_list_item_dereference_dref_true_save_doesnt_cause_extra_queries(self):

    class User(Document, ):
        name = StringField()
    class Group(Document, ):
        name = StringField()
        members = ListField(ReferenceField(User, dbref=True))
    User.drop_collection()
    Group.drop_collection()
    for i in range(1, 51):
        User(name=('user    %s' % i)).save()
    Group(name='Test', members=User.objects).save()
    with query_counter() as q:
        self.assertEqual(q, 0)
        group_obj = Group.objects.first()
        self.assertEqual(q, 1)
        group_obj.name = 'new    test'
        group_obj.save()
        self.assertEqual(q, 2)
