You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2018/07/30 21:55:38 UTC

allura git commit: [#8220] Personal Dashboard - Create Tests for Merge Requests Section

Repository: allura
Updated Branches:
  refs/heads/master 43c241b96 -> 1267d9c51


[#8220] Personal Dashboard - Create Tests for Merge Requests Section


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

Branch: refs/heads/master
Commit: 1267d9c51c5b1883f57c6dcbb92573ee3ee341ac
Parents: 43c241b
Author: deshanigtk <de...@cse.mrt.ac.lk>
Authored: Fri Jul 27 18:28:58 2018 +0530
Committer: deshanigtk <de...@cse.mrt.ac.lk>
Committed: Sat Jul 28 23:31:46 2018 +0530

----------------------------------------------------------------------
 .../templates/sections/merge_requests.html      | 56 +++++++++++---------
 .../tests/functional/test_personal_dashboard.py | 49 ++++++++++++++++-
 2 files changed, 78 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/1267d9c5/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
----------------------------------------------------------------------
diff --git a/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html b/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
index 368e1df..7808d1b 100644
--- a/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
+++ b/Allura/allura/ext/personal_dashboard/templates/sections/merge_requests.html
@@ -29,32 +29,36 @@
 {% block section_class %}merge_requests{% endblock %}
 
 {% block content %}
-    <table>
-        <thead>
-        <tr>
-            <th>#</th>
-            <th>Status</th>
-            <th>Summary</th>
-            <th>Repository</th>
-            <th>Created</th>
-            <th>Updated</th>
-        </tr>
-        </thead>
-        <tbody>
-        {% for req in requests %}
+    {% if requests %}
+        <table>
+            <thead>
             <tr>
-                <td><a href="{{ req.url() }}">{{ req.request_number }}</a></td>
-                <td><a href="{{ req.url() }}">{{ req.status }}</a></td>
-                <td><a href="{{ req.url() }}">{{ req.summary }}</a></td>
-                <td>{% if req.downstream_repo %}
-                    <a href="{{ req.downstream_url }}">{{ req.downstream_url }}</a>
-                {% else %}
-                    <i>(deleted)</i>
-                {% endif %}</td>
-                <td>{{ lib.abbr_date(req.created) }}</td>
-                <td>{{ lib.abbr_date(req.mod_date) }}</td>
+                <th>#</th>
+                <th>Status</th>
+                <th>Summary</th>
+                <th>Repository</th>
+                <th>Created</th>
+                <th>Updated</th>
             </tr>
-        {% endfor %}
-        </tbody>
-    </table>
+            </thead>
+            <tbody>
+            {% for req in requests %}
+                <tr>
+                    <td><a href="{{ req.url() }}">{{ req.request_number }}</a></td>
+                    <td><a href="{{ req.url() }}">{{ req.status }}</a></td>
+                    <td><a href="{{ req.url() }}">{{ req.summary }}</a></td>
+                    <td>{% if req.downstream_repo %}
+                        <a href="{{ req.downstream_url }}">{{ req.downstream_url }}</a>
+                    {% else %}
+                        <i>(deleted)</i>
+                    {% endif %}</td>
+                    <td>{{ lib.abbr_date(req.created) }}</td>
+                    <td>{{ lib.abbr_date(req.mod_date) }}</td>
+                </tr>
+            {% endfor %}
+            </tbody>
+        </table>
+    {% else %}
+        <li class="empty">No merge requests to display.</li>
+    {% endif %}
 {% endblock %}

http://git-wip-us.apache.org/repos/asf/allura/blob/1267d9c5/Allura/allura/tests/functional/test_personal_dashboard.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_personal_dashboard.py b/Allura/allura/tests/functional/test_personal_dashboard.py
index 3a3e8fa..5e397fc 100644
--- a/Allura/allura/tests/functional/test_personal_dashboard.py
+++ b/Allura/allura/tests/functional/test_personal_dashboard.py
@@ -15,15 +15,21 @@
 #       specific language governing permissions and limitations
 #       under the License.
 
+import pkg_resources
 import mock
 import tg
+
+from ming.orm import ThreadLocalORMSession, ThreadLocalODMSession
 from nose.tools import assert_equal, assert_in, assert_not_in
+from pylons import tmpl_context as c
 
 from allura import model as M
+from allura.lib import helpers as h
 from allura.lib.widgets.user_profile import SectionsUtil
 from allura.tests import TestController
 from allura.tests import decorators as td
-
+from alluratest.controller import setup_global_objects, setup_unit_test
+from forgegit.tests import with_git
 from forgetracker.tests.functional.test_root import TrackerTestController
 
 
@@ -76,3 +82,44 @@ class TestTicketsSection(TrackerTestController):
         response = self.app.get('/dashboard')
         ticket_rows = response.html.find('tbody')
         assert_in('foo', str(ticket_rows))
+
+
+class TestMergeRequestsSection(TestController):
+
+    def setUp(self):
+        super(TestMergeRequestsSection, self).setUp()
+        setup_unit_test()
+        self.setup_with_tools()
+        mr= self.merge_request
+        ThreadLocalODMSession.flush_all()
+
+    @with_git
+    def setup_with_tools(self):
+        setup_global_objects()
+        h.set_context('test', 'src-git', neighborhood='Projects')
+        repo_dir = pkg_resources.resource_filename(
+            'forgegit', 'tests/data')
+        c.app.repo.fs_path = repo_dir
+        c.app.repo.name = 'testgit.git'
+        self.repo = c.app.repo
+        self.repo.refresh()
+        ThreadLocalORMSession.flush_all()
+        ThreadLocalORMSession.close_all()
+
+    @property
+    def merge_request(self):
+        user = M.User.by_username('test-admin')
+        project = M.Project.query.get(shortname='test')
+        cid = '5c47243c8e424136fd5cdd18cd94d34c66d1955c'
+        return M.MergeRequest(
+            downstream={'commit_id': cid, 'project_id': project._id},
+            source_branch='zz',
+            target_branch='master',
+            creator_id=user._id,
+            request_number=1,
+            summary='test request')
+
+    def test_merge_requests_section(self):
+        r = self.app.get('/dashboard')
+        merge_req_rows = r.html.find('tbody')
+        assert_in('test request', str(merge_req_rows))