Arvados-DCO-1.1-Signed-off-by: Radhika Chippada <radhika@curoverse.com>
[arvados.git] / apps / workbench / test / unit / group_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class GroupTest < ActiveSupport::TestCase
8   test "get contents with names" do
9     use_token :active
10     oi = Group.
11       find(api_fixture('groups')['asubproject']['uuid']).
12       contents()
13     assert_operator(0, :<, oi.count,
14                     "Expected to find some items belonging to :active user")
15     assert_operator(0, :<, oi.items_available,
16                     "Expected contents response to have items_available > 0")
17     oi_uuids = oi.collect { |i| i['uuid'] }
18
19     expect_uuid = api_fixture('specimens')['in_asubproject']['uuid']
20     assert_includes(oi_uuids, expect_uuid,
21                     "Expected '#{expect_uuid}' in asubproject's contents")
22   end
23
24   test "can select specific group columns" do
25     use_token :admin
26     Group.select(["uuid", "name"]).limit(5).each do |user|
27       assert_not_nil user.uuid
28       assert_not_nil user.name
29       assert_nil user.owner_uuid
30     end
31   end
32
33   test "project editable by its admin" do
34     use_token :subproject_admin
35     project = Group.find(api_fixture("groups")["asubproject"]["uuid"])
36     assert(project.editable?, "project not editable by admin")
37   end
38
39   test "project not editable by reader" do
40     use_token :project_viewer
41     project = Group.find(api_fixture("groups")["aproject"]["uuid"])
42     refute(project.editable?, "project editable by reader")
43   end
44 end