9587: add support for include_trash in groups_controller -> contents method
authorradhika <radhika@curoverse.com>
Thu, 18 May 2017 01:47:52 +0000 (21:47 -0400)
committerradhika <radhika@curoverse.com>
Thu, 18 May 2017 19:45:57 +0000 (15:45 -0400)
services/api/app/controllers/arvados/v1/groups_controller.rb
services/api/test/integration/groups_test.rb

index 3bf91c38e4d6533e6d30889a1c1ea7c829c8c492..fc6489901a967a2dc667fc106e8f2178110420a8 100644 (file)
@@ -136,8 +136,13 @@ class Arvados::V1::GroupsController < ApplicationController
         end
       end.compact
 
-      @objects = klass.readable_by(*@read_users).
-        order(request_order).where(where_conds)
+      if klass == Collection and params[:include_trash]
+        @objects = klass.unscoped.readable_by(*@read_users).
+          order(request_order).where(where_conds)
+      else
+        @objects = klass.readable_by(*@read_users).
+          order(request_order).where(where_conds)
+      end
       klass_limit = limit_all - all_objects.count
       @limit = klass_limit
       apply_where_limit_order_params klass
index 2afece9563c092a1ad221883ba601e9334de3aa0..c26f6be4cafe165f3cf4b680759cd9b6a41337ad 100644 (file)
@@ -91,4 +91,17 @@ class GroupsTest < ActionDispatch::IntegrationTest
     }, auth(:active)
     assert_response 422
   end
+
+  test "group contents with include trash collections" do
+    get "/arvados/v1/groups/contents", {
+      include_trash: "true",
+      filters: [["uuid", "is_a", "arvados#collection"]].to_json
+    }, auth(:active)
+    assert_response 200
+
+    coll_uuids = []
+    json_response['items'].each { |c| coll_uuids << c['uuid'] }
+    assert_includes coll_uuids, collections(:foo_collection_in_aproject).uuid
+    assert_includes coll_uuids, collections(:expired_collection).uuid
+  end
 end