18995: proper fix for group class destroy method. Add a test.
authorWard Vandewege <ward@curii.com>
Fri, 15 Apr 2022 14:55:58 +0000 (10:55 -0400)
committerWard Vandewege <ward@curii.com>
Fri, 15 Apr 2022 15:01:34 +0000 (11:01 -0400)
Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <ward@curii.com>

services/api/app/controllers/arvados/v1/groups_controller.rb
services/api/test/functional/arvados/v1/groups_controller_test.rb

index 8539332f16509a6f00a6e9e27617d16a2ef75e45..3473c7e4e0c361e3c594569f83178e2ea18ebed2 100644 (file)
@@ -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
index fcdce0e600d6572fc69b682cd8b5ef68036d633a..369a10d45eaaf5ea981ff6856aa1b9ef7b40a082 100644 (file)
@@ -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