X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/840b855ff0317e66f4176ae0f23e9785f72267b4..85c625c40ad873d0efac33f8a63c1ee256185e36:/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 cfdf8f9244..270b96203b 100644 --- a/apps/workbench/test/unit/arvados_resource_list_test.rb +++ b/apps/workbench/test/unit/arvados_resource_list_test.rb @@ -1,3 +1,7 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' class ResourceListTest < ActiveSupport::TestCase @@ -99,4 +103,20 @@ class ResourceListTest < ActiveSupport::TestCase 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