'Ensure Q objects handle DBRefs correctly'

def test_q_with_dbref(self):

    connect(db='mongoenginetest')
    class User(Document, ):
        pass
    class Post(Document, ):
        created_user = ReferenceField(User)
    user = User.objects.create()
    Post.objects.create(created_user=user)
    self.assertEqual(Post.objects.filter(created_user=user).count(), 1)
    self.assertEqual(Post.objects.filter(Q(created_user=user)).count(), 1)
