From 1e55357b998f6e289ff6bc43e66417bd4d5bf894 Mon Sep 17 00:00:00 2001
From: Ivan Tyagov <ivan@nexedi.com>
Date: Tue, 30 Oct 2012 14:49:03 +0200
Subject: [PATCH] Add testing for showing not yet indexed threads using a
 relative url passed from REQUEST.

---
 product/ERP5/tests/testERP5Discussion.py | 29 ++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/product/ERP5/tests/testERP5Discussion.py b/product/ERP5/tests/testERP5Discussion.py
index 9bdf44c5b0..cbbc28d774 100644
--- a/product/ERP5/tests/testERP5Discussion.py
+++ b/product/ERP5/tests/testERP5Discussion.py
@@ -106,6 +106,35 @@ class TestERP5Discussion(ERP5TypeTestCase):
     # indexed already
     self.assertSameSet([post], thread.DiscussionThread_getDiscussionPostList())
 
+  def test_03_createDiscussionThread(self):
+    """
+      Create a disucssion thread
+    """
+    portal = self.portal
+
+    # create web sections & set predicates
+    group1 = portal.portal_categories.group.newContent(portal_type='Category',
+                                                       title = 'Group 1')
+    web_site = portal.web_site_module.newContent(portal_type='Web Site')
+    web_section1 = web_site.newContent(portal_type='Web Section')
+    web_section1.setMultimembershipCriterionBaseCategoryList(['group'])
+    web_section1.setMembershipCriterionCategoryList([group1.getRelativeUrl()])
+    self.tic()
+
+    web_section1.WebSection_createNewDiscussionThread('test1-new', 'test1 body')
+    discussion_thread = [x for x in self.portal.discussion_thread_module.objectValues() \
+                          if x.getReference()=='test1-new'][0]
+    # not indexed yet
+    self.assertSameSet([], web_section1.WebSection_getDiscussionThreadList())
+
+    # not indexed but its relative url is passed through REQUEST
+    self.app.REQUEST.set('thread_relative_url', discussion_thread.getRelativeUrl())
+    self.assertSameSet([discussion_thread], web_section1.WebSection_getDiscussionThreadList())
+
+    self.tic()
+    # indexed already
+    self.assertSameSet([discussion_thread], web_section1.WebSection_getDiscussionThreadList())
+
   def test_MultipleForum(self):
     """
       Test multiple forums may exists within same ERP5 Web Site.
-- 
2.30.9