'#24147 - Managers refer to the correct version of a
historical model'

def test_manager_refer_correct_model_version(self):

    project_state = ProjectState()
    project_state.add_model(ModelState(app_label='migrations', name='Tag', fields=[('id', models.AutoField(primary_key=True)), ('hidden', models.BooleanField())], managers=[('food_mgr', FoodManager('a', 'b')), ('food_qs', FoodQuerySet.as_manager())]))
    old_model = project_state.apps.get_model('migrations', 'tag')
    new_state = project_state.clone()
    operation = RemoveField('tag', 'hidden')
    operation.state_forwards('migrations', new_state)
    new_model = new_state.apps.get_model('migrations', 'tag')
    self.assertIsNot(old_model, new_model)
    self.assertIs(old_model, old_model.food_mgr.model)
    self.assertIs(old_model, old_model.food_qs.model)
    self.assertIs(new_model, new_model.food_mgr.model)
    self.assertIs(new_model, new_model.food_qs.model)
    self.assertIsNot(old_model.food_mgr, new_model.food_mgr)
    self.assertIsNot(old_model.food_qs, new_model.food_qs)
    self.assertIsNot(old_model.food_mgr.model, new_model.food_mgr.model)
    self.assertIsNot(old_model.food_qs.model, new_model.food_qs.model)
