diff --git a/app/templates/views/templates/_template.html b/app/templates/views/templates/_template.html
index 195ad2c08..fca57b9fa 100644
--- a/app/templates/views/templates/_template.html
+++ b/app/templates/views/templates/_template.html
@@ -16,15 +16,21 @@
{% endif %}
-
+ {% if template._template.archived %}
+
+ This template was deleted
{{ template._template.updated_at|format_date_normal }}
+
+ {% else %}
+
+ {% endif %}
diff --git a/tests/__init__.py b/tests/__init__.py
index 22ed52e5b..79dfd64f1 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -68,14 +68,17 @@ def template_json(service_id,
type_="sms",
content="template content",
subject=None,
- version=1):
+ version=1,
+ archived=False):
template = {
'id': id_,
'name': name,
'template_type': type_,
'content': content,
'service': service_id,
- 'version': version
+ 'version': version,
+ 'updated_at': datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S.%f'),
+ 'archived': archived
}
if subject is not None:
template['subject'] = subject
diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py
index 952ed1d49..009b7f08f 100644
--- a/tests/app/main/views/test_templates.py
+++ b/tests/app/main/views/test_templates.py
@@ -9,15 +9,17 @@ from tests import validate_route_permission
from app.main.views.templates import get_last_use_message, get_human_readable_delta
-def test_should_show_page_for_one_templates(app_,
- api_user_active,
- mock_login,
- mock_get_service,
- mock_get_service_template,
- mock_get_user,
- mock_get_user_by_email,
- mock_has_permissions,
- fake_uuid):
+def test_should_show_page_for_one_template(
+ app_,
+ api_user_active,
+ mock_login,
+ mock_get_service,
+ mock_get_service_template,
+ mock_get_user,
+ mock_get_user_by_email,
+ mock_has_permissions,
+ fake_uuid
+):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
@@ -291,6 +293,39 @@ def test_should_redirect_when_deleting_a_template(app_,
service_id, template_id)
+@freeze_time('2016-01-01T15:00')
+def test_should_show_page_for_a_deleted_template(
+ app_,
+ api_user_active,
+ mock_login,
+ mock_get_service,
+ mock_get_deleted_template,
+ mock_get_user,
+ mock_get_user_by_email,
+ mock_has_permissions,
+ fake_uuid
+):
+ with app_.test_request_context(), app_.test_client() as client:
+ client.login(api_user_active)
+ service_id = fake_uuid
+ template_id = fake_uuid
+ response = client.get(url_for(
+ '.view_template',
+ service_id=service_id,
+ template_id=template_id
+ ))
+
+ assert response.status_code == 200
+
+ content = response.get_data(as_text=True)
+ assert url_for("main.edit_service_template", service_id=fake_uuid, template_id=fake_uuid) not in content
+ assert url_for("main.send_from_api", service_id=fake_uuid, template_id=fake_uuid) not in content
+ assert url_for("main.send_test", service_id=fake_uuid, template_id=fake_uuid) not in content
+ assert "This template was deleted