mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-05 14:38:24 -04:00
Fixed bug for subject not updating when changed on the edit template page.
This commit is contained in:
@@ -80,8 +80,12 @@ def edit_service_template(service_id, template_id):
|
|||||||
|
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
service_api_client.update_service_template(
|
service_api_client.update_service_template(
|
||||||
template_id, form.name.data, template['template_type'],
|
template_id,
|
||||||
form.template_content.data, service_id
|
form.name.data,
|
||||||
|
template['template_type'],
|
||||||
|
form.template_content.data,
|
||||||
|
service_id,
|
||||||
|
form.subject.data if getattr(form, 'subject', None) else None
|
||||||
)
|
)
|
||||||
return redirect(url_for(
|
return redirect(url_for(
|
||||||
'.choose_template',
|
'.choose_template',
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ def test_should_redirect_when_saving_a_template(app_,
|
|||||||
'id': template_id,
|
'id': template_id,
|
||||||
'name': name,
|
'name': name,
|
||||||
'template_content': content,
|
'template_content': content,
|
||||||
'type': 'sms',
|
'template_type': 'sms',
|
||||||
'service': service_id
|
'service': service_id
|
||||||
}
|
}
|
||||||
response = client.post(url_for(
|
response = client.post(url_for(
|
||||||
@@ -64,7 +64,47 @@ def test_should_redirect_when_saving_a_template(app_,
|
|||||||
assert response.location == url_for(
|
assert response.location == url_for(
|
||||||
'.choose_template', service_id=service_id, template_type='sms', _external=True)
|
'.choose_template', service_id=service_id, template_type='sms', _external=True)
|
||||||
mock_update_service_template.assert_called_with(
|
mock_update_service_template.assert_called_with(
|
||||||
template_id, name, 'sms', content, service_id)
|
template_id, name, 'sms', content, service_id, None)
|
||||||
|
|
||||||
|
|
||||||
|
def test_should_redirect_when_saving_a_template_email(app_,
|
||||||
|
api_user_active,
|
||||||
|
mock_login,
|
||||||
|
mock_get_service_email_template,
|
||||||
|
mock_update_service_template,
|
||||||
|
mock_get_user,
|
||||||
|
mock_get_service,
|
||||||
|
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)
|
||||||
|
service_id = fake_uuid
|
||||||
|
template_id = fake_uuid
|
||||||
|
name = "new name"
|
||||||
|
content = "template content"
|
||||||
|
subject = "subject"
|
||||||
|
data = {
|
||||||
|
'id': template_id,
|
||||||
|
'name': name,
|
||||||
|
'template_content': content,
|
||||||
|
'template_type': 'email',
|
||||||
|
'service': service_id,
|
||||||
|
'subject': subject
|
||||||
|
}
|
||||||
|
response = client.post(url_for(
|
||||||
|
'.edit_service_template',
|
||||||
|
service_id=service_id,
|
||||||
|
template_id=template_id), data=data)
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert response.location == url_for(
|
||||||
|
'.choose_template',
|
||||||
|
service_id=service_id,
|
||||||
|
template_type='email',
|
||||||
|
_external=True)
|
||||||
|
mock_update_service_template.assert_called_with(
|
||||||
|
template_id, name, 'email', content, service_id, subject)
|
||||||
|
|
||||||
|
|
||||||
def test_should_show_delete_template_page(app_,
|
def test_should_show_delete_template_page(app_,
|
||||||
|
|||||||
@@ -205,9 +205,9 @@ def mock_create_service_template(mocker, fake_uuid):
|
|||||||
|
|
||||||
@pytest.fixture(scope='function')
|
@pytest.fixture(scope='function')
|
||||||
def mock_update_service_template(mocker):
|
def mock_update_service_template(mocker):
|
||||||
def _update(id_, name, type_, content, service):
|
def _update(id_, name, type_, content, service, subject=None):
|
||||||
template = template_json(
|
template = template_json(
|
||||||
service, id_, name, type_, content)
|
service, id_, name, type_, content, subject)
|
||||||
return {'data': template}
|
return {'data': template}
|
||||||
|
|
||||||
return mocker.patch(
|
return mocker.patch(
|
||||||
|
|||||||
Reference in New Issue
Block a user