route, form, and domain methods for updating workspace name

This commit is contained in:
dandds
2018-09-17 11:40:58 -04:00
parent fbdf8b0ee6
commit 021871ec16
5 changed files with 63 additions and 8 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):

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"