X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/69e9a3e41a8d381adc095718a73a8a99a7943a5a..568f53d1517bd43e4e4285cb19336ebbcca75389:/services/api/test/functional/arvados/v1/collections_controller_test.rb?ds=sidebyside diff --git a/services/api/test/functional/arvados/v1/collections_controller_test.rb b/services/api/test/functional/arvados/v1/collections_controller_test.rb index 70f35f3dd2..4cf8778e6a 100644 --- a/services/api/test/functional/arvados/v1/collections_controller_test.rb +++ b/services/api/test/functional/arvados/v1/collections_controller_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' class Arvados::V1::CollectionsControllerTest < ActionController::TestCase @@ -1086,4 +1090,44 @@ EOS assert_nil json_response['delete_at'] assert_match /^same name for trashed and persisted collections \(\d{4}-\d\d-\d\d.*?Z\)$/, json_response['name'] end + + test 'cannot show collection in trashed subproject' do + authorize_with :active + get :show, { + id: collections(:collection_in_trashed_subproject).uuid, + format: :json + } + assert_response 404 + end + + test 'can show collection in untrashed subproject' do + authorize_with :active + Group.find_by_uuid(groups(:trashed_project).uuid).update! is_trashed: false + get :show, { + id: collections(:collection_in_trashed_subproject).uuid, + format: :json, + } + assert_response :success + end + + test 'cannot index collection in trashed subproject' do + authorize_with :active + get :index + assert_response :success + item_uuids = json_response['items'].map do |item| + item['uuid'] + end + assert_not_includes(item_uuids, collections(:collection_in_trashed_subproject).uuid) + end + + test 'can index collection in untrashed subproject' do + authorize_with :active + Group.find_by_uuid(groups(:trashed_project).uuid).update! is_trashed: false + get :index + assert_response :success + item_uuids = json_response['items'].map do |item| + item['uuid'] + end + assert_includes(item_uuids, collections(:collection_in_trashed_subproject).uuid) + end end