Sep 4 - Add link relavant issues function

This commit is contained in:
2026-09-04 13:17:33 -04:00
parent b7bc0f0335
commit 50df63115e
7 changed files with 1320 additions and 15 deletions
+72
View File
@@ -167,6 +167,78 @@ def test_issues_list_scopes_a_customer_to_their_own_facilities(
assert 'other customer only' not in body
# ── Issue detail scope gate ──────────────────────────────────────────────────
# issues.view() had two inline scope blocks; they were collapsed into
# _issue_readable_by() so the linked-issues panel could reuse the same rule.
# These pin the behaviour that gate must keep.
def test_issue_view_allows_an_inspector_inside_their_contract(
client, login, make_user, db, make_facility, make_issue, project):
inspector = make_user(role='inspector')
db.session.add(InspectorAssignment(user_id=inspector.id,
project_id=project.id))
db.session.commit()
issue = make_issue(facility=make_facility(project=project))
login(inspector)
assert client.get(f'/issues/{issue.id}').status_code == 200
def test_issue_view_denies_an_inspector_outside_their_contract(
client, login, make_user, db, make_facility, make_issue,
project, other_project):
inspector = make_user(role='inspector')
db.session.add(InspectorAssignment(user_id=inspector.id,
project_id=project.id))
db.session.commit()
issue = make_issue(facility=make_facility(project=other_project),
description='not yours')
login(inspector)
res = client.get(f'/issues/{issue.id}', follow_redirects=True)
assert 'not yours' not in res.get_data(as_text=True)
def test_issue_view_denies_an_inspector_with_no_assignments(
client, login, make_user, make_facility, make_issue, project):
"""Strict scoping: no assignments means no access, not full access."""
issue = make_issue(facility=make_facility(project=project),
description='strictly scoped')
login(make_user(role='inspector'))
res = client.get(f'/issues/{issue.id}', follow_redirects=True)
assert 'strictly scoped' not in res.get_data(as_text=True)
def test_issue_view_denies_a_customer_outside_their_contract(
client, login, make_user, db, make_facility, make_issue,
project, other_project):
customer = make_user(role='customer')
db.session.add(CustomerAssignment(user_id=customer.id,
project_id=project.id))
db.session.commit()
issue = make_issue(facility=make_facility(project=other_project),
description='other customer only')
login(customer)
res = client.get(f'/issues/{issue.id}', follow_redirects=True)
assert 'other customer only' not in res.get_data(as_text=True)
def test_issue_view_allows_a_customer_inside_their_contract(
client, login, make_user, db, make_facility, make_issue, project):
customer = make_user(role='customer')
db.session.add(CustomerAssignment(user_id=customer.id,
project_id=project.id))
db.session.commit()
issue = make_issue(facility=make_facility(project=project),
description='mine to read')
login(customer)
res = client.get(f'/issues/{issue.id}')
assert res.status_code == 200
assert 'mine to read' in res.get_data(as_text=True)
# ── Reports overview ─────────────────────────────────────────────────────────
def test_reports_overview_renders_for_admin(client, login, make_user,