Merge pull request #2946 from alphagov/use-service-organisation-for-service-agreement

Look at service’s organisation on agreement page
This commit is contained in:
Chris Hill-Scott
2019-05-07 16:10:18 +01:00
committed by GitHub
2 changed files with 13 additions and 5 deletions

View File

@@ -1,6 +1,7 @@
from flask import abort, render_template, request, send_file, url_for from flask import abort, render_template, request, send_file, url_for
from flask_login import current_user, login_required from flask_login import current_user, login_required
from app import current_service
from app.main import main from app.main import main
from app.main.views.sub_navigation_dictionaries import features_nav from app.main.views.sub_navigation_dictionaries import features_nav
from app.s3_client.s3_mou_client import get_mou from app.s3_client.s3_mou_client import get_mou
@@ -20,8 +21,8 @@ def agreement():
@login_required @login_required
def service_agreement(service_id): def service_agreement(service_id):
return render_template( return render_template(
'views/agreement/service-{}.html'.format(current_user.default_organisation.as_jinja_template), 'views/agreement/service-{}.html'.format(current_service.organisation.as_jinja_template),
owner=current_user.default_organisation.name, owner=current_service.organisation.name,
) )

View File

@@ -4,7 +4,11 @@ from io import BytesIO
import pytest import pytest
from flask import url_for from flask import url_for
from tests.conftest import SERVICE_ONE_ID, mock_get_organisation_by_domain from tests.conftest import (
SERVICE_ONE_ID,
mock_get_organisation_by_domain,
mock_get_service_organisation,
)
class _MockS3Object(): class _MockS3Object():
@@ -16,16 +20,18 @@ class _MockS3Object():
return {'Body': BytesIO(self.data)} return {'Body': BytesIO(self.data)}
@pytest.mark.parametrize('endpoint, extra_args, link_selector, expected_back_links', [ @pytest.mark.parametrize('endpoint, extra_args, organisation_mock, link_selector, expected_back_links', [
( (
'main.agreement', 'main.agreement',
{}, {},
mock_get_organisation_by_domain,
'main .column-two-thirds a', 'main .column-two-thirds a',
[] []
), ),
( (
'main.service_agreement', 'main.service_agreement',
{'service_id': SERVICE_ONE_ID}, {'service_id': SERVICE_ONE_ID},
mock_get_service_organisation,
'main .column-five-sixths a', 'main .column-five-sixths a',
[ [
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID) partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID)
@@ -66,10 +72,11 @@ def test_show_agreement_page(
expected_links, expected_links,
endpoint, endpoint,
extra_args, extra_args,
organisation_mock,
link_selector, link_selector,
expected_back_links, expected_back_links,
): ):
mock_get_organisation_by_domain( organisation_mock(
mocker, mocker,
crown=crown, crown=crown,
agreement_signed=agreement_signed, agreement_signed=agreement_signed,