diff --git a/templates/navigation/global_navigation.html b/templates/navigation/global_navigation.html index 4b259e2b..09396483 100644 --- a/templates/navigation/global_navigation.html +++ b/templates/navigation/global_navigation.html @@ -21,6 +21,9 @@ {"label":"New Request", "href":url_for("requests.requests_form_new", screen=1), "icon": "plus", "active": g.matchesPath('/requests/new')}, ] ) }} - {{ SidenavItem("Workspaces", href="/workspaces", icon="cloud", active=g.matchesPath('/workspaces')) }} + + {% if g.current_user.workspace_roles %} + {{ SidenavItem("Workspaces", href="/workspaces", icon="cloud", active=g.matchesPath('/workspaces')) }} + {% endif %} diff --git a/tests/routes/test_home.py b/tests/routes/test_home.py new file mode 100644 index 00000000..1e0c1712 --- /dev/null +++ b/tests/routes/test_home.py @@ -0,0 +1,19 @@ +from tests.factories import UserFactory, WorkspaceFactory +from atst.domain.workspaces import Workspaces + + +def test_user_with_workspaces_has_workspaces_nav(client, user_session): + user = UserFactory.create() + workspace = WorkspaceFactory.create() + Workspaces._create_workspace_role(user, workspace, "default") + + user_session(user) + response = client.get("/home") + assert b'href="/workspaces"' in response.data + + +def test_user_without_workspaces_has_no_workspaces_nav(client, user_session): + user = UserFactory.create() + user_session(user) + response = client.get("/home") + assert b'href="/workspaces"' not in response.data