allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [1/3] allura git commit: [#8164] add activity stream entries for merge request actions
Date Thu, 28 Sep 2017 14:57:12 GMT
Repository: allura
Updated Branches:
  refs/heads/master 78b89b4de -> 7bca839f0


[#8164] add activity stream entries for merge request actions


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

Branch: refs/heads/master
Commit: 7bca839f0e6f5d12fced78c76aff4bff6c956c72
Parents: 6785ab9
Author: Dave Brondsema <dave@brondsema.net>
Authored: Tue Sep 26 12:22:54 2017 -0400
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Thu Sep 28 10:44:49 2017 -0400

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py | 7 +++++++
 Allura/allura/model/repository.py       | 6 ++++++
 Allura/allura/tasks/repo_tasks.py       | 2 ++
 Allura/allura/tests/model/test_repo.py  | 3 ++-
 Allura/allura/tests/test_tasks.py       | 3 ++-
 5 files changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/7bca839f/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 9518f89..17e3dfb 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -207,6 +207,8 @@ class RepoRootController(BaseController, FeedController):
                 subject='Discussion for Merge Request #:%s: %s' % (
                     mr.request_number, mr.summary))
             session(t).flush()
+            g.director.create_activity(c.user, 'created', mr,
+                                       related_nodes=[c.project], tags=['merge-request'])
             redirect(mr.url())
 
     @without_trailing_slash
@@ -466,6 +468,9 @@ class MergeRequestController(object):
 
         if changes:
             self.req.add_meta_post(changes=changes)
+            g.director.create_activity(c.user, 'updated', self.req,
+                                       related_nodes=[c.project], tags=['merge-request'])
+
         redirect(self.req.url())
 
     @expose()
@@ -475,6 +480,8 @@ class MergeRequestController(object):
         if status and self.req.status != status and \
            (has_access(self.req, 'write') or (self.req.creator == c.user and status == 'rejected')):
             self.req.add_meta_post(changes={'Status': [self.req.status, status]})
+            g.director.create_activity(c.user, 'updated', self.req,
+                                       related_nodes=[c.project], tags=['merge-request'])
             self.req.status = status
         redirect('.')
 

http://git-wip-us.apache.org/repos/asf/allura/blob/7bca839f/Allura/allura/model/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/repository.py b/Allura/allura/model/repository.py
index 4c508b7..0a22230 100644
--- a/Allura/allura/model/repository.py
+++ b/Allura/allura/model/repository.py
@@ -807,6 +807,12 @@ class MergeRequest(VersionedArtifact, ActivityObject):
     def activity_name(self):
         return 'merge request #%s' % self.request_number
 
+    @property
+    def activity_extras(self):
+        d = ActivityObject.activity_extras.fget(self)
+        d.update(summary=self.summary)
+        return d
+
     @LazyProperty
     def creator(self):
         from allura import model as M

http://git-wip-us.apache.org/repos/asf/allura/blob/7bca839f/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index a9a89d7..f84de1a 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -158,6 +158,8 @@ def merge(merge_request_id):
     mr.app.repo.merge(mr)
     mr.add_meta_post(changes={'Status': [mr.status, 'merged']})
     mr.status = 'merged'
+    g.director.create_activity(c.user, 'merged', mr,
+                               related_nodes=[c.project], tags=['merge-request'])
     session(mr).flush(mr)
 
 

http://git-wip-us.apache.org/repos/asf/allura/blob/7bca839f/Allura/allura/tests/model/test_repo.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_repo.py b/Allura/allura/tests/model/test_repo.py
index fc30c43..3761821 100644
--- a/Allura/allura/tests/model/test_repo.py
+++ b/Allura/allura/tests/model/test_repo.py
@@ -691,8 +691,9 @@ class TestMergeRequest(object):
         self.mr = M.MergeRequest(
             app_config=mock.Mock(_id=ObjectId()),
             downstream={'commit_id': '12345'},
+            request_number=1,
         )
-        self.mr.app = mock.Mock(forkable=True)
+        self.mr.app = mock.Mock(forkable=True, url='/mock-app-url/')
         self.mr.app.repo.commit.return_value = mock.Mock(_id='09876')
         self.mr.merge_allowed = mock.Mock(return_value=True)
         self.mr.discussion_thread = mock.Mock()

http://git-wip-us.apache.org/repos/asf/allura/blob/7bca839f/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index abfa021..2f4de42 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -67,7 +67,8 @@ class TestRepoTasks(unittest.TestCase):
     @mock.patch('allura.tasks.repo_tasks.session', autospec=True)
     @mock.patch.object(M, 'MergeRequest', autospec=True)
     def test_merge(self, MR, session):
-        mr = mock.Mock(_id='_id')
+        mr = mock.Mock(_id='_id',
+                       activity_name='merge req', activity_url='/fake/url', activity_extras={},
node_id=None)
         MR.query.get.return_value = mr
         repo_tasks.merge(mr._id)
         mr.app.repo.merge.assert_called_once_with(mr)


Mime
View raw message