Edit workspace #160300728
This commit is contained in:
dandds
2018-09-17 15:45:35 -04:00
committed by GitHub
11 changed files with 202 additions and 9 deletions

View File

@@ -63,16 +63,16 @@ def test_workspaces_get_ensures_user_is_in_workspace(workspace, workspace_owner)
Workspaces.get(outside_user, workspace.id)
def test_get_for_update_allows_owner(workspace, workspace_owner):
Workspaces.get_for_update(workspace_owner, workspace.id)
def test_get_for_update_projects_allows_owner(workspace, workspace_owner):
Workspaces.get_for_update_projects(workspace_owner, workspace.id)
def test_get_for_update_blocks_developer(workspace):
def test_get_for_update_projects_blocks_developer(workspace):
developer = UserFactory.create()
WorkspaceUsers.add(developer, workspace.id, "developer")
with pytest.raises(UnauthorizedError):
Workspaces.get_for_update(developer, workspace.id)
Workspaces.get_for_update_projects(developer, workspace.id)
def test_can_create_workspace_user(workspace, workspace_owner):
@@ -234,3 +234,19 @@ def test_for_user_returns_all_workspaces_for_ccpo(workspace, workspace_owner):
sams_workspaces = Workspaces.for_user(sam)
assert len(sams_workspaces) == 2
def test_get_for_update_information():
workspace_owner = UserFactory.create()
workspace = Workspaces.create(RequestFactory.create(creator=workspace_owner))
owner_ws = Workspaces.get_for_update_information(workspace_owner, workspace.id)
assert workspace == owner_ws
admin = UserFactory.create()
Workspaces.add_member(workspace, admin, "admin")
admin_ws = Workspaces.get_for_update_information(admin, workspace.id)
assert workspace == admin_ws
ccpo = UserFactory.from_atat_role("ccpo")
with pytest.raises(UnauthorizedError):
Workspaces.get_for_update_information(ccpo, workspace.id)

View File

@@ -1,3 +1,5 @@
from flask import url_for
from tests.factories import UserFactory, WorkspaceFactory
from atst.domain.workspaces import Workspaces
from atst.models.workspace_user import WorkspaceUser
@@ -51,3 +53,17 @@ def test_user_without_permission_has_no_add_member_link(client, user_session):
'href="/workspaces/{}/members/new"'.format(workspace.id).encode()
not in response.data
)
def test_update_workspace_name(client, user_session):
user = UserFactory.create()
workspace = WorkspaceFactory.create()
Workspaces._create_workspace_role(user, workspace, "admin")
user_session(user)
response = client.post(
url_for("workspaces.edit_workspace", workspace_id=workspace.id),
data={"name": "a cool new name"},
follow_redirects=True,
)
assert response.status_code == 200
assert workspace.name == "a cool new name"