File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,16 @@ class NamespacedEnvCacheTest < ActiveSupport::TestCase
1717 end
1818 end
1919
20+ test 'read_collection should not break on cached ActiveRecord::Relation objects' do
21+ @cache . write ( 'test_posts_cache' , Post . where ( user : users ( :standard_user ) ) )
22+
23+ data = assert_nothing_raised do
24+ @cache . fetch_collection ( 'test_posts_cache' )
25+ end
26+
27+ assert_not_nil data
28+ end
29+
2030 test 'fetch_collection' do
2131 data = assert_nothing_raised do
2232 @cache . fetch_collection ( 'test_posts_cache' ) do
@@ -30,9 +40,11 @@ class NamespacedEnvCacheTest < ActiveSupport::TestCase
3040 @cache . fetch_collection ( 'test_posts_cache' ) do
3141 Post . where ( user : users ( :standard_user ) )
3242 end
43+
3344 data = assert_nothing_raised do
3445 @cache . fetch_collection ( 'test_posts_cache' )
3546 end
47+
3648 assert_not_nil data
3749 end
3850
@@ -51,6 +63,7 @@ class NamespacedEnvCacheTest < ActiveSupport::TestCase
5163 test 'normalize_collection should correctly prepare collections for caching' do
5264 collection = Post . where ( user : users ( :standard_user ) )
5365 normalized = QPixel ::NamespacedEnvCache . normalize_collection ( collection )
66+
5467 assert_equal Post . name , normalized . shift
5568 assert ( collection . to_a . all? { |post | normalized . include? ( post . id ) } )
5669 end
You can’t perform that action at this time.
0 commit comments