6588: Removed manage account button, modified tests and deleted views.
[arvados.git] / apps / workbench / test / unit / group_test.rb
index 1e7d087577964d87d4defd071dd4a898a871eb3f..4a4530ca5694114f465f50ab0dec2250916a90ea 100644 (file)
@@ -1,28 +1,40 @@
 require 'test_helper'
 
 class GroupTest < ActiveSupport::TestCase
-  test "get owned_items with names" do
+  test "get contents with names" do
     use_token :active
     oi = Group.
-      find(api_fixture('groups')['asubfolder']['uuid']).
-      owned_items(include_linked: true)
+      find(api_fixture('groups')['asubproject']['uuid']).
+      contents()
     assert_operator(0, :<, oi.count,
                     "Expected to find some items belonging to :active user")
     assert_operator(0, :<, oi.items_available,
-                    "Expected owned_items response to have items_available > 0")
-    assert_operator(0, :<, oi.result_links.count,
-                    "Expected to receive name links with owned_items response")
+                    "Expected contents response to have items_available > 0")
     oi_uuids = oi.collect { |i| i['uuid'] }
 
-    expect_uuid = api_fixture('specimens')['in_asubfolder']['uuid']
+    expect_uuid = api_fixture('specimens')['in_asubproject']['uuid']
     assert_includes(oi_uuids, expect_uuid,
-                    "Expected '#{expect_uuid}' in asubfolder's owned_items")
+                    "Expected '#{expect_uuid}' in asubproject's contents")
+  end
 
-    expect_uuid = api_fixture('specimens')['in_afolder_linked_from_asubfolder']['uuid']
-    expect_name = api_fixture('links')['specimen_is_in_two_folders']['name']
-    assert_includes(oi_uuids, expect_uuid,
-                    "Expected '#{expect_uuid}' in asubfolder's owned_items")
-    assert_equal(expect_name, oi.name_for(expect_uuid),
-                 "Expected name_for '#{expect_uuid}' to be '#{expect_name}'")
+  test "can select specific group columns" do
+    use_token :admin
+    Group.select(["uuid", "name"]).limit(5).each do |user|
+      assert_not_nil user.uuid
+      assert_not_nil user.name
+      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