You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by je...@apache.org on 2015/04/20 12:45:45 UTC

[7/7] allura git commit: [#7866] ticket:754 Test can_merge task

[#7866] ticket:754 Test can_merge task


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

Branch: refs/heads/ib/7866
Commit: 49298f0c6feecd61556bddbb5923a0c7174df435
Parents: ee6f0bb
Author: Igor Bondarenko <je...@gmail.com>
Authored: Mon Apr 20 10:11:15 2015 +0000
Committer: Igor Bondarenko <je...@gmail.com>
Committed: Mon Apr 20 10:11:15 2015 +0000

----------------------------------------------------------------------
 Allura/allura/tasks/repo_tasks.py | 2 --
 Allura/allura/tests/test_tasks.py | 9 +++++++++
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/49298f0c/Allura/allura/tasks/repo_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tasks/repo_tasks.py b/Allura/allura/tasks/repo_tasks.py
index 614b4b0..e44ea94 100644
--- a/Allura/allura/tasks/repo_tasks.py
+++ b/Allura/allura/tasks/repo_tasks.py
@@ -169,6 +169,4 @@ def can_merge(merge_request_id):
     from allura import model as M
     mr = M.MergeRequest.query.get(_id=merge_request_id)
     result = mr.app.repo.can_merge(mr)
-    source_hash = mr.downstream.commit_id
-    target_hash = mr.app.repo.commit(mr.target_branch)._id
     mr.set_can_merge_cache(result)

http://git-wip-us.apache.org/repos/asf/allura/blob/49298f0c/Allura/allura/tests/test_tasks.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_tasks.py b/Allura/allura/tests/test_tasks.py
index d822229..4ad311c 100644
--- a/Allura/allura/tests/test_tasks.py
+++ b/Allura/allura/tests/test_tasks.py
@@ -75,6 +75,15 @@ class TestRepoTasks(unittest.TestCase):
         session.assert_called_once_with(mr)
         session.return_value.flush.assert_called_once_with(mr)
 
+    @mock.patch.object(M, 'MergeRequest', autospec=True)
+    def test_can_merge(self, MR):
+        mr = M.MergeRequest(_id='_id')
+        MR.query.get.return_value = mr
+        repo_tasks.can_merge(mr._id)
+        mr.app.repo.can_merge.assert_called_once_with(mr)
+        val = mr.app.repo.can_merge.return_value
+        mr.set_can_merge_cache.assert_called_once_with(val)
+
 
 class TestEventTasks(unittest.TestCase):