Skip to content

Commit

Permalink
Fix workspace collection post view not allowing to use the title opti…
Browse files Browse the repository at this point in the history
…on when duplicating a workspace
  • Loading branch information
aarranz committed Nov 24, 2020
1 parent 30c7d04 commit 39861a4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions setup.cfg
25 changes: 24 additions & 1 deletion src/wirecloud/platform/tests/rest_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2013-2017 CoNWeT Lab., Universidad Politécnica de Madrid
# Copyright (c) 2019 Future Internet Consulting and Development Solutions S.L.
# Copyright (c) 2019-2020 Future Internet Consulting and Development Solutions S.L.

# This file is part of Wirecloud.

Expand Down Expand Up @@ -521,6 +521,29 @@ def test_workspace_collection_post_from_workspace(self):
public_preference = response_data['preferences'].get('public', {'value': 'False', 'inherit': False})
self.assertEqual(public_preference['value'], 'false')

def test_workspace_collection_post_from_workspace_custom_name_title(self):

url = reverse('wirecloud.workspace_collection')

# Authenticate
self.client.login(username='user_with_workspaces', password='admin')

# workspace 3 (owner: user_with_workspaces, name: Pending Events)
data = {
'name': 'newname',
'title': 'Custom Title',
'workspace': '3',
}
response = self.client.post(url, json.dumps(data), content_type='application/json; charset=UTF-8', HTTP_ACCEPT='application/json')
self.assertEqual(response.status_code, 201)
self.assertEqual(response['Content-Type'].split(';', 1)[0], 'application/json')
response_data = json.loads(response.content.decode('utf-8'))
self.assertEqual(response_data['owner'], 'user_with_workspaces')
self.assertEqual(response_data['name'], 'newname')
self.assertEqual(response_data['title'], 'Custom Title')
public_preference = response_data['preferences'].get('public', {'value': 'False', 'inherit': False})
self.assertEqual(public_preference['value'], 'false')

def test_workspace_collection_post_from_workspace_allow_renaming(self):

url = reverse('wirecloud.workspace_collection')
Expand Down
2 changes: 1 addition & 1 deletion src/wirecloud/platform/workspace/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def create(self, request):
return build_error_response(request, 403, _('You are not allowed to read from workspace %s') % workspace_id)

try:
workspace = create_workspace(request.user, mashup, allow_renaming=allow_renaming, new_name=workspace_name, dry_run=dry_run)
workspace = create_workspace(request.user, mashup, allow_renaming=allow_renaming, new_name=workspace_name, new_title=workspace_title, dry_run=dry_run)
except ValueError as e:
return build_error_response(request, 422, e)
except MissingDependencies as e:
Expand Down

0 comments on commit 39861a4

Please sign in to comment.