incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [2/12] git commit: [#4339] ticket:247 fix links in feed for moved ticket
Date Sun, 20 Jan 2013 20:18:29 GMT
[#4339] ticket:247 fix links in feed for moved ticket


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

Branch: refs/heads/master
Commit: 17a903c054da46e9f9d8dcb1a818dd8c120a74b3
Parents: 1609437
Author: Igor Bondarenko <jetmind2@gmail.com>
Authored: Mon Dec 24 12:51:53 2012 +0000
Committer: Cory Johns <johnsca@geek.net>
Committed: Fri Jan 18 21:53:18 2013 +0000

----------------------------------------------------------------------
 ForgeTracker/forgetracker/model/ticket.py          |   15 ++--
 .../forgetracker/tests/functional/test_root.py     |   62 +++++++++++++++
 2 files changed, 71 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/17a903c0/ForgeTracker/forgetracker/model/ticket.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 9a608ce..0fe4119 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -587,17 +587,20 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
         self.discussion_thread.app_config_id = app_config._id
         session(self.discussion_thread.discussion).flush(self.discussion_thread.discussion)
         session(self.discussion_thread).flush(self.discussion_thread)
+        # need this to reset app_config RelationProperty on ticket to a new one
+        session(self.discussion_thread.discussion).expunge(self.discussion_thread.discussion)
+        session(self.discussion_thread).expunge(self.discussion_thread)
+        session(self).expunge(self)
+        ticket = Ticket.query.find(dict(
+            app_config_id=app_config._id, ticket_num=self.ticket_num)).first()
 
         message = 'Ticket moved from %s' % prior_url
         if messages:
             message += '\n\nCan\'t be converted:\n\n'
         message += '\n'.join(messages)
-        self.discussion_thread.add_post(text=message)
-
-        # need this to reset app_config RelationProperty on ticket to a new one
-        session(self).expunge(self)
-        return Ticket.query.find(dict(
-            app_config_id=app_config._id, ticket_num=self.ticket_num)).first()
+        with h.push_context(ticket.project_id, app_config_id=app_config._id):
+            ticket.discussion_thread.add_post(text=message)
+        return ticket
 
     def __json__(self):
         return dict(super(Ticket,self).__json__(),

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/17a903c0/ForgeTracker/forgetracker/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index 33c09a9..d2dbfe6 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -1075,6 +1075,68 @@ class TestFunctionalController(TrackerTestController):
         assert_equal(r.request.path, '/p/test2/bugs2/1/')
         summary = r.html.findAll('h2', {'class': 'dark title'})[0].contents[0].strip()
         assert_equal(summary, '#1 test')
+        ac_id = tracker.config._id
+        ticket = tm.Ticket.query.find({
+            'app_config_id': ac_id,
+            'ticket_num': 1}).first()
+        assert ticket is not None, "Can't find moved ticket"
+        assert_equal(ticket.discussion_thread.app_config_id, ac_id)
+        assert_equal(ticket.discussion_thread.discussion.app_config_id, ac_id)
+        post = ticket.discussion_thread.last_post
+        assert_equal(post.text, 'Ticket moved from /p/test/bugs/1/')
+
+    @td.with_tool('test2', 'Tickets', 'bugs2')
+    def test_move_ticket_feed(self):
+        self.new_ticket(summary='test')
+        p = M.Project.query.get(shortname='test2')
+        ac_id = p.app_instance('bugs2').config._id
+        r = self.app.post('/p/test/bugs/1/move/',
+                params={'tracker': str(ac_id)}).follow()
+
+        ticket = tm.Ticket.query.find({
+            'app_config_id': ac_id,
+            'ticket_num': 1}).first()
+        post = ticket.discussion_thread.last_post
+        ticket_link = '/p/test2/bugs2/1/?limit=50#' + post.slug
+        msg = 'Ticket moved from /p/test/bugs/1/'
+        assert_equal(post.text, msg)
+        # auto comment content and link to it should be in a ticket's feed
+        r = self.app.get('/p/test2/bugs2/1/feed')
+        assert msg in r, r
+        assert ticket_link in r, r
+        # auto comment content and link to it should be in a tracker's feed
+        r = self.app.get('/p/test2/bugs2/1/feed')
+        assert msg in r, r
+        assert ticket_link in r, r
+
+        # post comment and make sure that it appears on the feeds
+        r = self.app.get('/p/test2/bugs2/1/')
+        for f in r.html.findAll('form'):
+            if f.get('action', '').endswith('/post'):
+                break
+        post_content = 'ticket discussion post content'
+        params = dict()
+        inputs = f.findAll('input')
+        for field in inputs:
+            if field.has_key('name'):
+                params[field['name']] = field.has_key('value') and field['value'] or ''
+        params[f.find('textarea')['name']] = post_content
+        r = self.app.post(f['action'].encode('utf-8'), params=params,
+                          headers={'Referer': '/p/test2/bugs2/1/'.encode("utf-8")})
+        r = self.app.get('/p/test2/bugs2/1/', dict(page=1))
+        assert_true(post_content in r)
+        comments_cnt = len(r.html.findAll(attrs={'class': 'discussion-post'}))
+        assert_equal(comments_cnt, 2)  # moved auto comment + new comment
+        post = ticket.discussion_thread.last_post
+        # content and link to the ticket should be in a tracker's feed
+        ticket_link = '/p/test2/bugs2/1/?limit=50#' + post.slug
+        r = self.app.get('/p/test2/bugs2/feed')
+        assert post_content in r, r
+        assert ticket_link in r, r
+        # content and link to the ticket should be in a ticket's feed
+        r = self.app.get('/p/test2/bugs2/1/feed')
+        assert post_content in r, r
+        assert ticket_link in r, r
 
     def test_move_ticket_bad_data(self):
         self.new_ticket(summary='test')


Mime
View raw message