'Test whether a new record is unapproved by default'

def testRecordApprovedBy(self):

    db = current.db
    auth = current.auth
    s3db = current.s3db
    settings = current.deployment_settings
    try:
        settings.auth.record_approval = True
        auth.s3_impersonate('admin@example.com')
        otable = s3db.org_organisation
        otable.approved_by.default = None
        org = Storage(name='Test    Approval    Organisation')
        org_id = otable.insert(**org)
        self.assertTrue((org_id > 0))
        org.update(id=org_id)
        s3db.update_super(otable, org)
        row = db((otable.id == org_id)).select(limitby=(0, 1)).first()
        self.assertNotEqual(row, None)
        self.assertEqual(row.approved_by, None)
    finally:
        db.rollback()
        settings.auth.record_approval = False
        auth.s3_impersonate(None)
