3021: Reset API fixtures before running the first test case.
[arvados.git] / apps / workbench / test / unit / group_test.rb
1 require 'test_helper'
2
3 class GroupTest < ActiveSupport::TestCase
4   test "get contents with names" do
5     use_token :active
6     oi = Group.
7       find(api_fixture('groups')['asubproject']['uuid']).
8       contents()
9     assert_operator(0, :<, oi.count,
10                     "Expected to find some items belonging to :active user")
11     assert_operator(0, :<, oi.items_available,
12                     "Expected contents response to have items_available > 0")
13     oi_uuids = oi.collect { |i| i['uuid'] }
14
15     expect_uuid = api_fixture('specimens')['in_asubproject']['uuid']
16     assert_includes(oi_uuids, expect_uuid,
17                     "Expected '#{expect_uuid}' in asubproject's contents")
18   end
19
20   test "can select specific group columns" do
21     use_token :admin
22     Group.select(["uuid", "name"]).limit(5).each do |user|
23       assert_not_nil user.uuid
24       assert_not_nil user.name
25       assert_nil user.owner_uuid
26     end
27   end
28
29   test "project editable by its admin" do
30     use_token :subproject_admin
31     project = Group.find(api_fixture("groups")["asubproject"]["uuid"])
32     assert(project.editable?, "project not editable by admin")
33   end
34
35   test "project not editable by reader" do
36     use_token :project_viewer
37     project = Group.find(api_fixture("groups")["aproject"]["uuid"])
38     refute(project.editable?, "project editable by reader")
39   end
40 end