Merge branch '8784-dir-listings'
[arvados.git] / apps / workbench / test / unit / group_test.rb
index c555c4a62453618442dd12681dde03e408ba395c..7040f972320888cd7ae93e8f382ed41c19ff4faf 100644 (file)
@@ -1,3 +1,7 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: AGPL-3.0
+
 require 'test_helper'
 
 class GroupTest < ActiveSupport::TestCase
@@ -5,25 +9,16 @@ class GroupTest < ActiveSupport::TestCase
     use_token :active
     oi = Group.
       find(api_fixture('groups')['asubproject']['uuid']).
-      contents(include_linked: true)
+      contents()
     assert_operator(0, :<, oi.count,
                     "Expected to find some items belonging to :active user")
     assert_operator(0, :<, oi.items_available,
                     "Expected contents response to have items_available > 0")
-    assert_operator(0, :<, oi.result_links.count,
-                    "Expected to receive name links with contents response")
     oi_uuids = oi.collect { |i| i['uuid'] }
 
     expect_uuid = api_fixture('specimens')['in_asubproject']['uuid']
     assert_includes(oi_uuids, expect_uuid,
                     "Expected '#{expect_uuid}' in asubproject's contents")
-
-    expect_uuid = api_fixture('specimens')['in_aproject_linked_from_asubproject']['uuid']
-    expect_name = api_fixture('links')['specimen_is_in_two_projects']['name']
-    assert_includes(oi_uuids, expect_uuid,
-                    "Expected '#{expect_uuid}' in asubproject's contents")
-    assert_equal(expect_name, oi.name_for(expect_uuid),
-                 "Expected name_for '#{expect_uuid}' to be '#{expect_name}'")
   end
 
   test "can select specific group columns" do
@@ -34,4 +29,16 @@ class GroupTest < ActiveSupport::TestCase
       assert_nil user.owner_uuid
     end
   end
+
+  test "project editable by its admin" do
+    use_token :subproject_admin
+    project = Group.find(api_fixture("groups")["asubproject"]["uuid"])
+    assert(project.editable?, "project not editable by admin")
+  end
+
+  test "project not editable by reader" do
+    use_token :project_viewer
+    project = Group.find(api_fixture("groups")["aproject"]["uuid"])
+    refute(project.editable?, "project editable by reader")
+  end
 end