Skip to content

Commit

Permalink
Merge pull request #960 from alphagov/fix-paging-activity-page
Browse files Browse the repository at this point in the history
Fix pagination on activity page
  • Loading branch information
quis committed Oct 3, 2016
2 parents 2eb7360 + 3069858 commit cf01227
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
3 changes: 2 additions & 1 deletion app/main/views/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def view_notifications(service_id, message_type):
'views/notifications.html',
partials=get_notifications(service_id, message_type),
message_type=message_type,
status=request.args.get('status')
status=request.args.get('status'),
page=request.args.get('page', 1)
)


Expand Down
2 changes: 1 addition & 1 deletion app/templates/views/notifications.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h1 class="heading-large">

{{ ajax_block(
partials,
url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status),
url_for('.get_notifications_as_json', service_id=current_service.id, message_type=message_type, status=status, page=page),
'notifications'
) }}

Expand Down
24 changes: 21 additions & 3 deletions tests/app/main/views/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ def test_should_show_updates_for_one_job_as_json(
)
]
)
@pytest.mark.parametrize(
"page_argument, expected_page_argument", [
(1, 1),
(22, 22),
(None, 1)
]
)
def test_can_show_notifications(
app_,
service_one,
Expand All @@ -289,7 +296,9 @@ def test_can_show_notifications(
message_type,
page_title,
status_argument,
expected_api_call
expected_api_call,
page_argument,
expected_page_argument
):
with app_.test_request_context():
with app_.test_client() as client:
Expand All @@ -298,7 +307,8 @@ def test_can_show_notifications(
'main.view_notifications',
service_id=service_one['id'],
message_type=message_type,
status=status_argument))
status=status_argument,
page=page_argument))
assert response.status_code == 200
content = response.get_data(as_text=True)

Expand All @@ -317,9 +327,17 @@ def test_can_show_notifications(
status=status_argument
) == page.findAll("a", {"download": "download"})[0]['href']

assert url_for(
'.get_notifications_as_json',
service_id=service_one['id'],
message_type=message_type,
status=status_argument,
page=expected_page_argument
) == page.find("div", {'data-key': 'notifications'})['data-resource']

mock_get_notifications.assert_called_with(
limit_days=7,
page=1,
page=expected_page_argument,
service_id=service_one['id'],
status=expected_api_call,
template_type=[message_type]
Expand Down

0 comments on commit cf01227

Please sign in to comment.