|
@@ -1,34 +1,34 @@
|
|
from django.core.urlresolvers import reverse
|
|
from django.core.urlresolvers import reverse
|
|
|
|
|
|
from misago.acl.testutils import override_acl
|
|
from misago.acl.testutils import override_acl
|
|
-from misago.admin.testutils import AdminTestCase
|
|
|
|
|
|
+from misago.users.testutils import AuthenticatedUserTestCase
|
|
|
|
|
|
from misago.forums.lists import get_forums_list
|
|
from misago.forums.lists import get_forums_list
|
|
from misago.forums.models import Forum
|
|
from misago.forums.models import Forum
|
|
|
|
|
|
|
|
|
|
-class ForumViewsTests(AdminTestCase):
|
|
|
|
|
|
+class ForumViewsTests(AuthenticatedUserTestCase):
|
|
def test_index(self):
|
|
def test_index(self):
|
|
"""index contains forums list"""
|
|
"""index contains forums list"""
|
|
response = self.client.get(reverse('misago:index'))
|
|
response = self.client.get(reverse('misago:index'))
|
|
|
|
|
|
- for node in get_forums_list(self.test_admin):
|
|
|
|
|
|
+ for node in get_forums_list(self.user):
|
|
self.assertIn(node.name, response.content)
|
|
self.assertIn(node.name, response.content)
|
|
if node.level > 1:
|
|
if node.level > 1:
|
|
self.assertIn(node.get_absolute_url(), response.content)
|
|
self.assertIn(node.get_absolute_url(), response.content)
|
|
|
|
|
|
def test_index_no_perms(self):
|
|
def test_index_no_perms(self):
|
|
"""index contains no visible forums"""
|
|
"""index contains no visible forums"""
|
|
- override_acl(self.test_admin, {'visible_forums': []})
|
|
|
|
|
|
+ override_acl(self.user, {'visible_forums': []})
|
|
response = self.client.get(reverse('misago:index'))
|
|
response = self.client.get(reverse('misago:index'))
|
|
|
|
|
|
- for node in get_forums_list(self.test_admin):
|
|
|
|
|
|
+ for node in get_forums_list(self.user):
|
|
self.assertNotIn(node.name, response.content)
|
|
self.assertNotIn(node.name, response.content)
|
|
if node.level > 1:
|
|
if node.level > 1:
|
|
self.assertNotIn(node.get_absolute_url(), response.content)
|
|
self.assertNotIn(node.get_absolute_url(), response.content)
|
|
|
|
|
|
|
|
|
|
-class CategoryViewsTests(AdminTestCase):
|
|
|
|
|
|
+class CategoryViewsTests(AuthenticatedUserTestCase):
|
|
def setUp(self):
|
|
def setUp(self):
|
|
super(CategoryViewsTests, self).setUp()
|
|
super(CategoryViewsTests, self).setUp()
|
|
categories_qs = Forum.objects.all_forums().filter(role='category')
|
|
categories_qs = Forum.objects.all_forums().filter(role='category')
|
|
@@ -41,14 +41,14 @@ class CategoryViewsTests(AdminTestCase):
|
|
|
|
|
|
def test_cant_see_category(self):
|
|
def test_cant_see_category(self):
|
|
"""can't see category"""
|
|
"""can't see category"""
|
|
- override_acl(self.test_admin, {'visible_forums': []})
|
|
|
|
|
|
+ override_acl(self.user, {'visible_forums': []})
|
|
|
|
|
|
response = self.client.get(self.category.get_absolute_url())
|
|
response = self.client.get(self.category.get_absolute_url())
|
|
self.assertEqual(response.status_code, 404)
|
|
self.assertEqual(response.status_code, 404)
|
|
|
|
|
|
def test_cant_browse_category(self):
|
|
def test_cant_browse_category(self):
|
|
"""can't see category"""
|
|
"""can't see category"""
|
|
- override_acl(self.test_admin, {
|
|
|
|
|
|
+ override_acl(self.user, {
|
|
'visible_forums': [self.category.parent_id, self.category.pk],
|
|
'visible_forums': [self.category.parent_id, self.category.pk],
|
|
'forums': {
|
|
'forums': {
|
|
self.category.parent_id: {'can_see': 1, 'can_browse': 1},
|
|
self.category.parent_id: {'can_see': 1, 'can_browse': 1},
|
|
@@ -61,7 +61,7 @@ class CategoryViewsTests(AdminTestCase):
|
|
|
|
|
|
def test_can_browse_category(self):
|
|
def test_can_browse_category(self):
|
|
"""can see category contents"""
|
|
"""can see category contents"""
|
|
- override_acl(self.test_admin, {
|
|
|
|
|
|
+ override_acl(self.user, {
|
|
'visible_forums': [self.category.parent_id, self.category.pk],
|
|
'visible_forums': [self.category.parent_id, self.category.pk],
|
|
'forums': {
|
|
'forums': {
|
|
self.category.parent_id: {'can_see': 1, 'can_browse': 1},
|
|
self.category.parent_id: {'can_see': 1, 'can_browse': 1},
|
|
@@ -73,14 +73,14 @@ class CategoryViewsTests(AdminTestCase):
|
|
self.assertEqual(response.status_code, 200)
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
|
|
-class RedirectViewsTests(AdminTestCase):
|
|
|
|
|
|
+class RedirectViewsTests(AuthenticatedUserTestCase):
|
|
def setUp(self):
|
|
def setUp(self):
|
|
super(RedirectViewsTests, self).setUp()
|
|
super(RedirectViewsTests, self).setUp()
|
|
redirects_qs = Forum.objects.all_forums().filter(role='redirect')
|
|
redirects_qs = Forum.objects.all_forums().filter(role='redirect')
|
|
self.redirect = redirects_qs[:1][0]
|
|
self.redirect = redirects_qs[:1][0]
|
|
|
|
|
|
def allow_redirect_follow(self):
|
|
def allow_redirect_follow(self):
|
|
- override_acl(self.test_admin, {
|
|
|
|
|
|
+ override_acl(self.user, {
|
|
'visible_forums': [self.redirect.parent_id, self.redirect.pk],
|
|
'visible_forums': [self.redirect.parent_id, self.redirect.pk],
|
|
'forums': {
|
|
'forums': {
|
|
self.redirect.parent_id: {'can_see': 1, 'can_browse': 1},
|
|
self.redirect.parent_id: {'can_see': 1, 'can_browse': 1},
|
|
@@ -90,7 +90,7 @@ class RedirectViewsTests(AdminTestCase):
|
|
|
|
|
|
def test_cant_see_redirect(self):
|
|
def test_cant_see_redirect(self):
|
|
"""can't see redirect"""
|
|
"""can't see redirect"""
|
|
- override_acl(self.test_admin, {'visible_forums': []})
|
|
|
|
|
|
+ override_acl(self.user, {'visible_forums': []})
|
|
|
|
|
|
response = self.client.get(self.redirect.get_absolute_url())
|
|
response = self.client.get(self.redirect.get_absolute_url())
|
|
self.assertEqual(response.status_code, 404)
|
|
self.assertEqual(response.status_code, 404)
|