'Tests who can see restricted forums in search form.'

def test_discussion_forum_with_restricted_forums(self):

    forum1 = ForumFactory(name=u'ou812forum')
    thread1 = ThreadFactory(forum=forum1, title=u'audio    2')
    PostFactory(thread=thread1)
    forum2 = RestrictedForumFactory(name=u'restrictedkeepout')
    thread2 = ThreadFactory(forum=forum2, title=u'audio    2')
    PostFactory(thread=thread2)
    self.refresh()
    response = self.client.get(reverse('search.advanced'), {'a': '2'})
    eq_(200, response.status_code)
    assert ('ou812forum' in response.content)
    assert ('restrictedkeepout' not in response.content)
    u = UserFactory()
    g = GroupFactory()
    g.user_set.add(u)
    ct = ContentType.objects.get_for_model(forum2)
    PermissionFactory(codename='forums_forum.view_in_forum', content_type=ct, object_id=forum2.id, group=g)
    self.client.login(username=u.username, password='testpass')
    response = self.client.get(reverse('search.advanced'), {'a': '2'})
    eq_(200, response.status_code)
    assert ('ou812forum' in response.content)
    assert ('restrictedkeepout' in response.content)
