X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/df9e166a5ffc4aa79658bec1a5d552a3b413f0d8..42c20b25e1325124b88e3b9b285544dc41122b56:/apps/workbench/test/unit/arvados_resource_list_test.rb diff --git a/apps/workbench/test/unit/arvados_resource_list_test.rb b/apps/workbench/test/unit/arvados_resource_list_test.rb index a3bfbc19f4..270b96203b 100644 --- a/apps/workbench/test/unit/arvados_resource_list_test.rb +++ b/apps/workbench/test/unit/arvados_resource_list_test.rb @@ -1,7 +1,13 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' class ResourceListTest < ActiveSupport::TestCase + reset_api_fixtures :after_each_test, false + test 'links_for on a resource list that does not return links' do use_token :active results = Specimen.all @@ -91,4 +97,26 @@ class ResourceListTest < ActiveSupport::TestCase assert_empty c.results end + test 'count=none' do + use_token :active + c = Collection.with_count('none') + assert_nil c.items_available + refute_empty c.results + end + + test 'cache results across each(&block) calls' do + use_token :admin + c = Collection.where(owner_uuid: 'zzzzz-j7d0g-0201collections').with_count('none') + c.each do |x| + x.description = 'foo' + end + found = 0 + c.each do |x| + found += 1 + # We should get the same objects we modified in the loop above + # -- not new objects built from another set of API responses. + assert_equal 'foo', x.description + end + assert_equal 201, found + end end