Ejemplo n.º 1
0
    def test_merge_request_edit(self):
        r = self.app.post('/p/test2/code/do_request_merge',
            params={
                'source_branch': 'zz',
                'target_branch': 'master',
                'summary': 'summary',
                'description': 'description'}).follow()
        assert '<a href="edit" title="Edit"><b data-icon="p" class="ico ico-pencil" title="Edit"></b></a>' in r
        r = self.app.get('/p/test/src-git/merge-requests/1/edit')
        assert 'value="summary"' in r
        assert 'name="description">description</textarea>' in r
        assert '<option selected value="zz">zz</option>' in r

        r = self.app.post('/p/test/src-git/merge-requests/1/do_request_merge_edit',
            params={
                'source_branch': 'zz',
                'target_branch': 'master',
                'summary': 'changed summary',
                'description': 'changed description'},
                extra_environ=dict(username='******'), status=302).follow()
        assert 'Login' in r

        r = self.app.post('/p/test/src-git/merge-requests/1/do_request_merge_edit',
            params={
                'source_branch': 'master',
                'target_branch': 'master',
                'summary': 'changed summary',
                'description': 'changed description'}).follow()

        assert '[5c4724]' not in r
        assert '<p>changed description</p' in r
        assert 'Merge Request #1: changed summary (open)' in r
        changes = r.html.findAll('div', attrs={'class': 'markdown_content'})[-1]
        dd_assert_equal(unicode(changes), """
<div class="markdown_content"><ul>
<li>
<p><strong>Summary</strong>: summary --&gt; changed summary</p>
</li>
<li>
<p><strong>Source branch</strong>: zz --&gt; master</p>
</li>
<li>
<p><strong>Description</strong>:</p>
</li>
</ul>
<p>Diff:</p>
<div class="codehilite"><pre><span class="gd">--- old</span>
<span class="gi">+++ new</span>
<span class="gu">@@ -1 +1 @@</span>
<span class="gd">-description</span>
<span class="gi">+changed description</span>
</pre></div>
</div>
""".strip())

        r = self.app.get('/p/test/src-git/merge-requests')
        assert '<a href="1/">changed summary</a>' in r
Ejemplo n.º 2
0
    def test_merge_request_edit(self):
        r = self.app.post('/p/test2/code/do_request_merge',
                          params={
                              'source_branch': 'zz',
                              'target_branch': 'master',
                              'summary': 'summary',
                              'description': 'description',
                          }).follow()
        assert '<a class="icon" href="edit" title="Edit"><i class="fa fa-edit"></i>&nbsp;Edit</a>' in r
        r = self.app.get('/p/test/src-git/merge-requests/1/edit')
        assert 'value="summary"' in r
        assert '<option selected value="zz">zz</option>' in r
        md_edit = r.html.find('div', {'class': 'markdown_edit'})
        assert md_edit is not None, 'MarkdownEdit widget not found'

        r = self.app.post(
            '/p/test/src-git/merge-requests/1/do_request_merge_edit',
            params={
                'source_branch': 'zz',
                'target_branch': 'master',
                'summary': 'changed summary',
                'description': 'changed description'
            },
            extra_environ=dict(username='******'),
            status=302,
        ).follow()
        assert 'Login' in r

        r = self.app.post(
            '/p/test/src-git/merge-requests/1/do_request_merge_edit',
            params={
                'source_branch': 'master',
                'target_branch': 'master',
                'summary': 'changed summary',
                'description': 'changed description',
            }).follow()

        assert '[5c4724]' not in r
        assert '<p>changed description</p' in r
        assert 'Merge Request #1: changed summary (open)' in r
        changes = r.html.findAll('div', attrs={'class':
                                               'markdown_content'})[-1]
        dd_assert_equal(
            unicode(changes), """
<div class="markdown_content"><ul>
<li>
<p><strong>Summary</strong>: summary --&gt; changed summary</p>
</li>
<li>
<p><strong>Source branch</strong>: zz --&gt; master</p>
</li>
<li>
<p><strong>Description</strong>:</p>
</li>
</ul>
<p>Diff:</p>
<div class="codehilite"><pre><span></span><span class="gd">--- old</span>
<span class="gi">+++ new</span>
<span class="gu">@@ -1 +1 @@</span>
<span class="gd">-description</span>
<span class="gi">+changed description</span>
</pre></div>
</div>
""".strip())

        r = self.app.get('/p/test/src-git/merge-requests').follow()
        assert '<a href="1/">changed summary</a>' in r