Page for adding a new service

This page is exactly the same as the page for adding your first service, save
the heading text.

So all this commit does is:
- set up two routes (`/add-service`, `/add-service/first`) for each of the two
  journeys and change the existing journeys to use the `/add-service/first`
  route
- add logic to show different heading text depending on the journey
- add a link to the new (`/add-service`) route in the service chooser dropdown
This commit is contained in:
Chris Hill-Scott
2016-01-18 10:47:53 +00:00
parent 893378ef9f
commit 81d4230b61
8 changed files with 78 additions and 31 deletions

View File

@@ -1,3 +1,4 @@
from flask import url_for
from app.main.dao import verify_codes_dao, services_dao
from tests.app.main import create_test_user
@@ -8,8 +9,8 @@ def test_get_should_render_add_service_template(notifications_admin, notificatio
user = create_test_user('active')
client.login(user)
verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='sms')
client.post('/two-factor', data={'sms_code': '12345'})
response = client.get('/add-service')
client.post(url_for('.two_factor'), data={'sms_code': '12345'})
response = client.get(url_for('.add_service', first='first'))
assert response.status_code == 200
assert 'Set up notifications for your service' in response.get_data(as_text=True)
@@ -20,10 +21,13 @@ def test_should_add_service_and_redirect_to_next_page(notifications_admin, notif
user = create_test_user('active')
client.login(user)
verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='sms')
client.post('/two-factor', data={'sms_code': '12345'})
response = client.post('/add-service', data={'service_name': 'testing the post'})
client.post(url_for('.two_factor'), data={'sms_code': '12345'})
response = client.post(
url_for('.add_service', first='first'),
data={'service_name': 'testing the post'}
)
assert response.status_code == 302
assert response.location == 'http://localhost/services/123/dashboard'
assert response.location == url_for('.dashboard', service_id=123, _external=True)
saved_service = services_dao.find_service_by_service_name('testing the post')
assert saved_service is not None
@@ -36,7 +40,19 @@ def test_should_return_form_errors_when_service_name_is_empty(notifications_admi
user = create_test_user('active')
client.login(user)
verify_codes_dao.add_code(user_id=user.id, code='12345', code_type='sms')
client.post('/two-factor', data={'sms_code': '12345'})
response = client.post('/add-service', data={})
client.post(url_for('.two_factor'), data={'sms_code': '12345'})
response = client.post(url_for('.add_service', first='first'), data={})
assert response.status_code == 200
assert 'Service name can not be empty' in response.get_data(as_text=True)
def test_should_show_page_for_adding_another_service(notifications_admin,
notifications_admin_db,
notify_db_session):
with notifications_admin.test_request_context():
with notifications_admin.test_client() as client:
user = create_test_user('active')
client.login(user)
response = client.get(url_for('.add_service'))
assert response.status_code == 200
assert 'Add a new service' in response.get_data(as_text=True)

View File

@@ -32,7 +32,7 @@ def test_should_redirect_to_add_service_when_code_are_correct(notifications_admi
data={'sms_code': '12345',
'email_code': '23456'})
assert response.status_code == 302
assert response.location == url_for('main.add_service', _external=True)
assert response.location == url_for('main.add_service', first='first', _external=True)
def test_should_activate_user_after_verify(notifications_admin, notifications_admin_db, notify_db_session):