allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jetm...@apache.org
Subject [3/3] allura git commit: [#7082] ticket:769 Tests for has_activity_access
Date Mon, 18 May 2015 10:30:18 GMT
[#7082] ticket:769 Tests for has_activity_access


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/dfdbe04e
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/dfdbe04e
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/dfdbe04e

Branch: refs/heads/ib/7082
Commit: dfdbe04e8a88b6c9a199a735838bce248d6e3dc3
Parents: 87f15d8
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon May 18 09:09:00 2015 +0000
Committer: Igor Bondarenko <jetmind2@gmail.com>
Committed: Mon May 18 09:09:00 2015 +0000

----------------------------------------------------------------------
 .../tests/unit/test_ticket_model.py             | 28 ++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/dfdbe04e/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
index aa17c1f..889f342 100644
--- a/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
+++ b/ForgeTracker/forgetracker/tests/unit/test_ticket_model.py
@@ -23,8 +23,13 @@ import mock
 from ming.orm.ormsession import ThreadLocalORMSession
 from ming.orm import session
 from ming import schema
-from nose.tools import raises, assert_equal, assert_in
-
+from nose.tools import (
+    raises,
+    assert_equal,
+    assert_in,
+    assert_true,
+    assert_false,
+)
 from forgetracker.model import Ticket, TicketAttachment
 from forgetracker.tests.unit import TrackerTestWithModel
 from forgetracker.import_support import ResettableStream
@@ -87,6 +92,25 @@ class TestTicketModel(TrackerTestWithModel):
         assert_in('allura_id', t.activity_extras)
         assert_equal(t.activity_extras['summary'], t.summary)
 
+    def test_has_activity_access(self):
+        t = Ticket(summary='ticket', ticket_num=666)
+        assert_true(t.has_activity_access('read', c.user, 'activity'))
+        t.deleted = True
+        assert_false(t.has_activity_access('read', c.user, 'activity'))
+
+    def test_comment_has_activity_access(self):
+        t = Ticket(summary='ticket', ticket_num=666, deleted=True)
+        p = t.discussion_thread.add_post(text='test post')
+        assert_equal(p.status, 'ok')
+        assert_true(p.has_activity_access('read', c.user, 'activity'))
+        p.status = 'spam'
+        assert_false(p.has_activity_access('read', c.user, 'activity'))
+        p.status = 'pending'
+        assert_false(p.has_activity_access('read', c.user, 'activity'))
+        p.status = 'ok'
+        p.deleted = True
+        assert_false(p.has_activity_access('read', c.user, 'activity'))
+
     def test_private_ticket(self):
         from allura.model import ProjectRole
         from allura.model import ACE, DENY_ALL


Mime
View raw message