Katello/katello — pull request #1743 by iNecas (2013-03-13 10:28:06+00:00)
Title: Destroy default content view on cascade when deleting environment

Also save the default content_view explicitly. Here is what happened without
this changes:

1. Create environment (default content view and content_view_version was
crated)

2. Delete the environment (`content_view` stayed there because
`:dependent=> :destroy` was missing)

3. When creating an environment with the
same name, the content_view was not created, because another content view with
the same name already existed. However, because the content_view was being
saved as part of saving content_view_version, the exception was not thrown
(and the content_view_version was saved successfully without association to
any content_view)

4. When promoting some time after this incident (that
happened unnoticed), "nil pointer exception" occurred while promoting, because
the default content view was not there.