From 5dc5d156d1f586f41b6341c30f3c2a202f3e037e Mon Sep 17 00:00:00 2001 From: Ward Vandewege Date: Fri, 15 Apr 2022 10:55:58 -0400 Subject: [PATCH] 18995: proper fix for group class destroy method. Add a test. Arvados-DCO-1.1-Signed-off-by: Ward Vandewege --- .../arvados/v1/groups_controller.rb | 3 ++- .../arvados/v1/groups_controller_test.rb | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/services/api/app/controllers/arvados/v1/groups_controller.rb b/services/api/app/controllers/arvados/v1/groups_controller.rb index 8539332f16..3473c7e4e0 100644 --- a/services/api/app/controllers/arvados/v1/groups_controller.rb +++ b/services/api/app/controllers/arvados/v1/groups_controller.rb @@ -103,7 +103,8 @@ class Arvados::V1::GroupsController < ApplicationController def destroy if !TRASHABLE_CLASSES.include?(@object.group_class) - return @object.destroy + @object.destroy + show else super # Calls destroy from TrashableController module end diff --git a/services/api/test/functional/arvados/v1/groups_controller_test.rb b/services/api/test/functional/arvados/v1/groups_controller_test.rb index fcdce0e600..369a10d45e 100644 --- a/services/api/test/functional/arvados/v1/groups_controller_test.rb +++ b/services/api/test/functional/arvados/v1/groups_controller_test.rb @@ -787,6 +787,28 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase end end + # the group class overrides the destroy method. Make sure that the destroyed + # object is returned + [ + [group_class: "project"], + [group_class: "role"], + [group_class: "filter", properties: {"filters":[]}], + ].each do |params| + test "destroy group #{params} returns object" do + authorize_with :active + + group = Group.create!(params).first + + post :destroy, params: { + id: group.uuid, + format: :json, + } + assert_response :success + assert_not_nil json_response + assert_equal group.uuid, json_response["uuid"] + end + end + test 'get shared owned by another user' do authorize_with :user_bar_in_sharing_group -- 2.30.2