Merge branch 'master' into 2756-eventbus-in-workbench
[arvados.git] / apps / workbench / test / unit / group_test.rb
index 0821e1fa6a084b34f25229d2cdd5e42ae4b82274..4a7144f99ae098feeaed448d3d099222e2662048 100644 (file)
@@ -1,7 +1,28 @@
 require 'test_helper'
 
-class ProjectTest < ActiveSupport::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
+class GroupTest < ActiveSupport::TestCase
+  test "get contents with names" do
+    use_token :active
+    oi = Group.
+      find(api_fixture('groups')['asubfolder']['uuid']).
+      contents(include_linked: true)
+    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_asubfolder']['uuid']
+    assert_includes(oi_uuids, expect_uuid,
+                    "Expected '#{expect_uuid}' in asubfolder's contents")
+
+    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 contents")
+    assert_equal(expect_name, oi.name_for(expect_uuid),
+                 "Expected name_for '#{expect_uuid}' to be '#{expect_name}'")
+  end
 end