30 from cubicweb.view import STRICT_DOCTYPE |
30 from cubicweb.view import STRICT_DOCTYPE |
31 from cubicweb.devtools.testlib import CubicWebTC |
31 from cubicweb.devtools.testlib import CubicWebTC |
32 from cubicweb.utils import json_dumps |
32 from cubicweb.utils import json_dumps |
33 from cubicweb.uilib import rql_for_eid |
33 from cubicweb.uilib import rql_for_eid |
34 from cubicweb.web import INTERNAL_FIELD_VALUE, Redirect, RequestError, RemoteCallFailed |
34 from cubicweb.web import INTERNAL_FIELD_VALUE, Redirect, RequestError, RemoteCallFailed |
|
35 import cubicweb.server.session |
|
36 from cubicweb.server.session import Transaction as OldTransaction |
35 from cubicweb.entities.authobjs import CWUser |
37 from cubicweb.entities.authobjs import CWUser |
36 from cubicweb.web.views.autoform import get_pending_inserts, get_pending_deletes |
38 from cubicweb.web.views.autoform import get_pending_inserts, get_pending_deletes |
37 from cubicweb.web.views.basecontrollers import JSonController, xhtmlize, jsonize |
39 from cubicweb.web.views.basecontrollers import JSonController, xhtmlize, jsonize |
38 from cubicweb.web.views.ajaxcontroller import ajaxfunc, AjaxFunction |
40 from cubicweb.web.views.ajaxcontroller import ajaxfunc, AjaxFunction |
39 import cubicweb.transaction as tx |
41 import cubicweb.transaction as tx |
779 self.assertEqual(res, '12') |
781 self.assertEqual(res, '12') |
780 |
782 |
781 |
783 |
782 class UndoControllerTC(CubicWebTC): |
784 class UndoControllerTC(CubicWebTC): |
783 |
785 |
|
786 def setUp(self): |
|
787 class Transaction(OldTransaction): |
|
788 """Force undo feature to be turned on in all case""" |
|
789 undo_actions = property(lambda tx: True, lambda x, y:None) |
|
790 cubicweb.server.session.Transaction = Transaction |
|
791 super(UndoControllerTC, self).setUp() |
|
792 |
|
793 def tearDown(self): |
|
794 super(UndoControllerTC, self).tearDown() |
|
795 cubicweb.server.session.Transaction = OldTransaction |
|
796 |
|
797 |
784 def setup_database(self): |
798 def setup_database(self): |
785 req = self.request() |
799 req = self.request() |
786 self.session.undo_actions = True |
|
787 self.toto = self.create_user(req, 'toto', password='toto', groups=('users',), |
800 self.toto = self.create_user(req, 'toto', password='toto', groups=('users',), |
788 commit=False) |
801 commit=False) |
789 self.txuuid_toto = self.commit() |
802 self.txuuid_toto = self.commit() |
790 self.toto_email = self.session.create_entity('EmailAddress', |
803 self.toto_email = self.session.create_entity('EmailAddress', |
791 address=u'toto@logilab.org', |
804 address=u'toto@logilab.org', |