diff options
| author | Thibault Delavallée <tde@openerp.com> | 2013-05-22 13:42:36 +0200 |
|---|---|---|
| committer | Thibault Delavallée <tde@openerp.com> | 2013-05-22 13:42:36 +0200 |
| commit | cd278d83abd291209d7c3f18ee8eb9ab43a4158a (patch) | |
| tree | 8d866ce7e1d365667e0a4fe9e85b10f15d36ea3d /addons/portal/tests | |
| parent | c1cb8bf7653d98153c43e0ee35eb3558438e0b78 (diff) | |
| parent | d4d6e882668cfdc7c4634a0e30a047d0c83c75a7 (diff) | |
[MERGE] Sync with trunk
bzr revid: tde@openerp.com-20130522103305-yi5ql1chdx9qxxlx
bzr revid: tde@openerp.com-20130522114236-qi2s3i2dl2lemdvh
Diffstat (limited to 'addons/portal/tests')
| -rw-r--r-- | addons/portal/tests/test_portal.py | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/addons/portal/tests/test_portal.py b/addons/portal/tests/test_portal.py index 8021a0e371c..e2b66e65af6 100644 --- a/addons/portal/tests/test_portal.py +++ b/addons/portal/tests/test_portal.py @@ -40,7 +40,9 @@ class test_portal(TestMailBase): self.partner_chell_id = self.user_chell.partner_id.id # Create a PigsPortal group - self.group_port_id = self.mail_group.create(cr, uid, {'name': 'PigsPortal', 'public': 'groups', 'group_public_id': self.group_portal_id}) + self.group_port_id = self.mail_group.create(cr, uid, + {'name': 'PigsPortal', 'public': 'groups', 'group_public_id': self.group_portal_id}, + {'mail_create_nolog': True}) # Set an email address for the user running the tests, used as Sender for outgoing mails self.res_users.write(cr, uid, uid, {'email': 'test@localhost'}) @@ -197,3 +199,27 @@ class test_portal(TestMailBase): self.assertEqual(action.get('id'), port_act_id, 'URL redirection: action without parameters should redirect to client action Inbox') + def test_30_message_read(self): + cr, uid, group_port_id = self.cr, self.uid, self.group_port_id + + # Data: custom subtypes + mt_group_public_id = self.mail_message_subtype.create(cr, uid, {'name': 'group_public', 'description': 'Group changed'}) + self.ir_model_data.create(cr, uid, {'name': 'mt_group_public', 'model': 'mail.message.subtype', 'module': 'mail', 'res_id': mt_group_public_id}) + # Data: post messages with various subtypes + msg1_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body1', type='comment', subtype='mail.mt_comment') + msg2_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body2', type='comment', subtype='mail.mt_group_public') + msg3_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body3', type='comment', subtype='mail.mt_comment') + msg4_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body4', type='comment') + msg5_id = self.mail_group.message_post(cr, uid, group_port_id, body='Body5', type='notification') + + # Do: Chell search messages: should not see internal notes (comment without subtype) + msg_ids = self.mail_message.search(cr, self.user_chell_id, [('model', '=', 'mail.group'), ('res_id', '=', group_port_id)]) + self.assertEqual(set(msg_ids), set([msg1_id, msg2_id, msg3_id, msg5_id]), + 'mail_message: portal user has access to messages he should not read') + + # Do: Chell read messages she can read + self.mail_message.read(cr, self.user_chell_id, msg_ids, ['body', 'type', 'subtype_id']) + + # Do: Chell read a message she should not be able to read + with self.assertRaises(except_orm): + self.mail_message.read(cr, self.user_chell_id, [msg4_id], ['body', 'type', 'subtype_id']) |
