Merge remote-tracking branch 'origin/master' into 14645-fuse-operations-reporting
[arvados.git] / services / api / test / integration / groups_test.rb
index 6226ffd16c20cc1b65bf4da97f81c149f9de8eb1..6b1bf795ed7eced1e872809358150c324e234239 100644 (file)
@@ -99,7 +99,8 @@ class GroupsTest < ActionDispatch::IntegrationTest
   test "group contents with include trash collections" do
     get "/arvados/v1/groups/contents", {
       include_trash: "true",
-      filters: [["uuid", "is_a", "arvados#collection"]].to_json
+      filters: [["uuid", "is_a", "arvados#collection"]].to_json,
+      limit: 1000
     }, auth(:active)
     assert_response 200
 
@@ -108,4 +109,49 @@ class GroupsTest < ActionDispatch::IntegrationTest
     assert_includes coll_uuids, collections(:foo_collection_in_aproject).uuid
     assert_includes coll_uuids, collections(:expired_collection).uuid
   end
+
+  test "group contents without trash collections" do
+    get "/arvados/v1/groups/contents", {
+      filters: [["uuid", "is_a", "arvados#collection"]].to_json,
+      limit: 1000
+    }, 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_not_includes coll_uuids, collections(:expired_collection).uuid
+  end
+
+  test "create request with async=true defers permissions update" do
+    Rails.configuration.async_permissions_update_interval = 1 # seconds
+    name = "Random group #{rand(1000)}"
+    assert_equal nil, Group.find_by_name(name)
+    post "/arvados/v1/groups", {
+      group: {
+        name: name
+      },
+      async: true
+    }, auth(:active)
+    assert_response 202
+    g = Group.find_by_name(name)
+    assert_not_nil g
+    get "/arvados/v1/groups", {
+      filters: [["name", "=", name]].to_json,
+      limit: 10
+    }, auth(:active)
+    assert_response 200
+    assert_equal 0, json_response['items_available']
+
+    # Unblock the thread doing the permissions update
+    ActiveRecord::Base.clear_active_connections!
+
+    sleep(3)
+    get "/arvados/v1/groups", {
+      filters: [["name", "=", name]].to_json,
+      limit: 10
+    }, auth(:active)
+    assert_response 200
+    assert_equal 1, json_response['items_available']
+  end
 end