web/test/unittest_views_actions.py
branchstable
changeset 9198 c32a21bf88bb
parent 9197 9905d9efa4a3
child 9808 d121b74e043f
--- a/web/test/unittest_views_actions.py	Mon Jul 29 16:00:40 2013 +0200
+++ b/web/test/unittest_views_actions.py	Mon Jul 29 16:01:18 2013 +0200
@@ -19,6 +19,7 @@
 from logilab.common.testlib import unittest_main
 
 from cubicweb.devtools.testlib import CubicWebTC
+from cubicweb.web.views import actions, uicfg
 
 class ActionsTC(CubicWebTC):
     def test_view_action(self):
@@ -28,6 +29,18 @@
         vaction = [action for action in actions if action.__regid__ == 'view'][0]
         self.assertEqual(vaction.url(), 'http://testing.fr/cubicweb/view?rql=CWUser%20X')
 
+    def test_has_editable_relations(self):
+        """ensure has_editable_relation predicate used by ModifyAction
+        return positive score if there is only some inlined forms
+        """
+        use_email = self.schema['use_email'].rdefs['CWUser', 'EmailAddress']
+        with self.temporary_permissions((use_email, {'add': ('guests',)}),
+                                        ):
+            with self.login('anon'):
+                req = self.request()
+                predicate = actions.has_editable_relation()
+                self.assertEqual(predicate(None, req, rset=req.user.as_rset()),
+                                 1)
 
 if __name__ == '__main__':
     unittest_main()