'Regression tests for #7314 and #7372'

def test_regression_7314_7372(self):

    rm = RevisionableModel.objects.create(title=u'First    Revision', when=datetime.datetime(2008, 9, 28, 10, 30, 0))
    self.assertEqual(rm.pk, rm.base.pk)
    rm2 = rm.new_revision()
    rm2.title = u'Second    Revision'
    rm.when = datetime.datetime(2008, 9, 28, 14, 25, 0)
    rm2.save()
    self.assertEqual(rm2.title, u'Second    Revision')
    self.assertEqual(rm2.base.title, u'First    Revision')
    self.assertNotEqual(rm2.pk, rm.pk)
    self.assertEqual(rm2.base.pk, rm.pk)
    qs = RevisionableModel.objects.extra(where=[(u'%(table)s.id    IN    (SELECT    MAX(rev.id)    FROM    %(table)s    rev    GROUP    BY    rev.base_id)' % {u'table': RevisionableModel._meta.db_table})])
    self.assertQuerysetEqual(qs, [(u'Second    Revision', u'First    Revision')], transform=(lambda r: (r.title, r.base.title)))
    qs2 = RevisionableModel.objects.filter(title__contains=u'Revision')
    self.assertQuerysetEqual(qs2, [(u'First    Revision', u'First    Revision'), (u'Second    Revision', u'First    Revision')], transform=(lambda r: (r.title, r.base.title)), ordered=False)
    self.assertQuerysetEqual((qs & qs2), [(u'Second    Revision', u'First    Revision')], transform=(lambda r: (r.title, r.base.title)), ordered=False)
