From ffdd20351e52a85e7412ef92e6e4840389eac7b9 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 5 Sep 2016 14:01:28 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20bug=20where=20every=20service=20was=20?= =?UTF-8?q?=E2=80=98in=E2=80=99=20trial=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The message on the service settings page was being shown for every service, whether or not they were in trial mode. It also tests for both cases. --- app/templates/views/service-settings.html | 26 +++++++------- tests/app/main/views/test_service_settings.py | 36 +++++++++++++++++++ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 053e950f5..5163650fa 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -39,22 +39,24 @@ {% endcall %} -
+ {% if current_service.restricted %} +
-

Your service is in trial mode

+

Your service is in trial mode

-
    -
  • you can only send messages to yourself
  • -
  • you can add people to your team, then you can send messages to them too
  • -
  • you can only send 50 messages per day
  • -
+
    +
  • you can only send messages to yourself
  • +
  • you can add people to your team, then you can send messages to them too
  • +
  • you can only send 50 messages per day
  • +
-

- To remove these restrictions - request to go live. -

+

+ To remove these restrictions + request to go live. +

-
+
+ {% endif %} {% if current_user.has_permissions([], admin_override=True) %} diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index 08080b599..0f75d86c6 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -93,6 +93,24 @@ def test_should_redirect_after_change_service_name(app_, assert mock_get_services.called +def test_show_restricted_service( + app_, + service_one, + mock_login, + mock_get_user, + active_user_with_permissions, + mock_has_permissions, + mock_get_service, + mock_get_organisation, +): + with app_.test_request_context(), app_.test_client() as client: + client.login(active_user_with_permissions) + response = client.get(url_for('main.service_settings', service_id=service_one['id'])) + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.find('h1').text == 'Settings' + assert page.find_all('h2')[1].text == 'Your service is in trial mode' + + def test_switch_service_to_live( app_, service_one, @@ -120,6 +138,24 @@ def test_switch_service_to_live( ) +def test_show_live_service( + app_, + service_one, + mock_login, + mock_get_user, + active_user_with_permissions, + mock_get_live_service, + mock_has_permissions, + mock_get_organisation, +): + with app_.test_request_context(), app_.test_client() as client: + client.login(active_user_with_permissions) + response = client.get(url_for('main.service_settings', service_id=service_one['id'])) + page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') + assert page.find('h1').text.strip() == 'Settings' + assert 'Your service is in trial mode' not in page.text + + def test_switch_service_to_restricted( app_, service_one,