diff --git a/pagure/templates/repo_pull_request.html b/pagure/templates/repo_pull_request.html index 9f6f778..ae882d1 100644 --- a/pagure/templates/repo_pull_request.html +++ b/pagure/templates/repo_pull_request.html @@ -582,7 +582,7 @@
Subscribers - {{subscribers|count}} + {{subscribers|count}}
{% for subscriber in subscribers %} {{ + }}" title="{{ subscriber }}" id="sub-avatar-{{subscriber}}">{{ subscriber |avatar(size=30, css_class="pb-1") | safe }} {% endfor %} @@ -1246,10 +1246,19 @@ $(document).ready(function () { $.post( _url, _data ).done( function(data) { var _btn = $("#subcribe-btn"); + var _countlabel = $("#subscribers-count") + var _count = parseInt(_countlabel.text()) if (_btn.text() == 'Subscribe'){ _btn.text('Unsubscribe'); + _countlabel.text(_count+1) + var _html = '' + + ''; + $('#subscribers_list').prepend(_html); } else { _btn.text('Subscribe'); + _countlabel.text(_count-1); + $('#sub-avatar-'+data.user).remove(); } return false; } diff --git a/tests/__init__.py b/tests/__init__.py index c835b2d..c325303 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -496,6 +496,8 @@ class FakeUser(object): # pylint: disable=too-few-public-methods self.username = username self.name = username self.email = 'foo@bar.com' + self.default_email = 'foo@bar.com' + self.approved_memberships = [ FakeGroup('packager'), FakeGroup('design-team') diff --git a/tests/test_pagure_flask_api_fork.py b/tests/test_pagure_flask_api_fork.py index 0325c03..9b76a2d 100644 --- a/tests/test_pagure_flask_api_fork.py +++ b/tests/test_pagure_flask_api_fork.py @@ -1724,7 +1724,10 @@ class PagureFlaskApiForktests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( data, - {'message': 'You are no longer watching this pull-request'} + {'message': 'You are no longer watching this pull-request', + 'avatar_url': 'https://seccdn.libravatar.org/avatar/94bea27db4b720dc24905a1848dbd9d7a8d2c11594f88a62c9dd73009d7b408c?s=30&d=retro', + 'user': 'bar', + } ) data = {} @@ -1735,7 +1738,10 @@ class PagureFlaskApiForktests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( data, - {'message': 'You are no longer watching this pull-request'} + {'message': 'You are no longer watching this pull-request', + 'avatar_url': 'https://seccdn.libravatar.org/avatar/94bea27db4b720dc24905a1848dbd9d7a8d2c11594f88a62c9dd73009d7b408c?s=30&d=retro', + 'user': 'bar', + } ) # No change @@ -1755,7 +1761,10 @@ class PagureFlaskApiForktests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( data, - {'message': 'You are now watching this pull-request'} + {'message': 'You are now watching this pull-request', + 'avatar_url': 'https://seccdn.libravatar.org/avatar/94bea27db4b720dc24905a1848dbd9d7a8d2c11594f88a62c9dd73009d7b408c?s=30&d=retro', + 'user': 'bar', + } ) # Subscribe - no changes @@ -1767,7 +1776,10 @@ class PagureFlaskApiForktests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( data, - {'message': 'You are now watching this pull-request'} + {'message': 'You are now watching this pull-request', + 'avatar_url': 'https://seccdn.libravatar.org/avatar/94bea27db4b720dc24905a1848dbd9d7a8d2c11594f88a62c9dd73009d7b408c?s=30&d=retro', + 'user': 'bar', + } ) repo = pagure.lib.get_authorized_project(self.session, 'test') @@ -1786,7 +1798,10 @@ class PagureFlaskApiForktests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( data, - {'message': 'You are no longer watching this pull-request'} + {'message': 'You are no longer watching this pull-request', + 'avatar_url': 'https://seccdn.libravatar.org/avatar/94bea27db4b720dc24905a1848dbd9d7a8d2c11594f88a62c9dd73009d7b408c?s=30&d=retro', + 'user': 'bar', + } ) repo = pagure.lib.get_authorized_project(self.session, 'test') @@ -1856,7 +1871,10 @@ class PagureFlaskApiForktests(tests.Modeltests): data = json.loads(output.get_data(as_text=True)) self.assertDictEqual( data, - {'message': 'You are now watching this pull-request'} + {'message': 'You are now watching this pull-request', + 'avatar_url': 'https://seccdn.libravatar.org/avatar/0c7e6a405862e402eb76a70f8a26fc732d07c32931e9fae9ab1582911d2e8a3b?s=30&d=retro', + 'user': 'foo', + } ) # Check subscribtions after