@@ -54,30 +54,6 @@ def each(&block)
54
54
end
55
55
end
56
56
57
- class TestDeepEnumerable < Liquid ::Drop
58
- include Enumerable
59
-
60
- class Product < Liquid ::Drop
61
- attr_reader :title , :price , :premium
62
-
63
- def initialize ( title :, price :, premium : nil )
64
- @title = { "content" => title , "language" => "en" }
65
- @price = { "value" => price , "unit" => "USD" }
66
- @premium = { "category" => premium } if premium
67
- end
68
- end
69
-
70
- def each ( &block )
71
- [
72
- Product . new ( title : "Pro goggles" , price : 1299 ) ,
73
- Product . new ( title : "Thermal gloves" , price : 1299 ) ,
74
- Product . new ( title : "Alpine jacket" , price : 3999 , premium : 'Basic' ) ,
75
- Product . new ( title : "Mountain boots" , price : 3899 , premium : 'Pro' ) ,
76
- Product . new ( title : "Safety helmet" , price : 1999 )
77
- ] . each ( &block )
78
- end
79
- end
80
-
81
57
class NumberLikeThing < Liquid ::Drop
82
58
def initialize ( amount )
83
59
@amount = amount
@@ -438,15 +414,6 @@ def test_sort_natural_invalid_property
438
414
end
439
415
end
440
416
441
- def test_sort_natural_with_deep_enumerables
442
- template = <<~LIQUID
443
- {{- products | sort_natural: 'title.content' | map: 'title.content' | join: ', ' -}}
444
- LIQUID
445
- expected_output = "Alpine jacket, Mountain boots, Pro goggles, Safety helmet, Thermal gloves"
446
-
447
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
448
- end
449
-
450
417
def test_legacy_sort_hash
451
418
assert_equal ( [ { a : 1 , b : 2 } ] , @filters . sort ( a : 1 , b : 2 ) )
452
419
end
@@ -483,15 +450,6 @@ def test_uniq_invalid_property
483
450
end
484
451
end
485
452
486
- def test_uniq_with_deep_enumerables
487
- template = <<~LIQUID
488
- {{- products | uniq: 'price.value' | map: "title.content" | join: ', ' -}}
489
- LIQUID
490
- expected_output = "Pro goggles, Alpine jacket, Mountain boots, Safety helmet"
491
-
492
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
493
- end
494
-
495
453
def test_compact_empty_array
496
454
assert_equal ( [ ] , @filters . compact ( [ ] , "a" ) )
497
455
end
@@ -508,15 +466,6 @@ def test_compact_invalid_property
508
466
end
509
467
end
510
468
511
- def test_compact_with_deep_enumerables
512
- template = <<~LIQUID
513
- {{- products | compact: 'premium.category' | map: 'title.content' | join: ', ' -}}
514
- LIQUID
515
- expected_output = "Alpine jacket, Mountain boots"
516
-
517
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
518
- end
519
-
520
469
def test_reverse
521
470
assert_equal ( [ 4 , 3 , 2 , 1 ] , @filters . reverse ( [ 1 , 2 , 3 , 4 ] ) )
522
471
end
@@ -626,15 +575,6 @@ def test_sort_works_on_enumerables
626
575
assert_template_result ( "213" , '{{ foo | sort: "bar" | map: "foo" }}' , { "foo" => TestEnumerable . new } )
627
576
end
628
577
629
- def test_sort_with_deep_enumerables
630
- template = <<~LIQUID
631
- {{- products | sort: 'price.value' | map: 'title.content' | join: ', ' -}}
632
- LIQUID
633
- expected_output = "Pro goggles, Thermal gloves, Safety helmet, Mountain boots, Alpine jacket"
634
-
635
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
636
- end
637
-
638
578
def test_first_and_last_call_to_liquid
639
579
assert_template_result ( 'foobar' , '{{ foo | first }}' , { 'foo' => [ ThingWithToLiquid . new ] } )
640
580
assert_template_result ( 'foobar' , '{{ foo | last }}' , { 'foo' => [ ThingWithToLiquid . new ] } )
@@ -951,15 +891,6 @@ def test_reject_with_false_value
951
891
assert_template_result ( expected_output , template , { "array" => array } )
952
892
end
953
893
954
- def test_reject_with_deep_enumerables
955
- template = <<~LIQUID
956
- {{- products | reject: 'title.content', 'Pro goggles' | map: 'price.value' | join: ', ' -}}
957
- LIQUID
958
- expected_output = "1299, 3999, 3899, 1999"
959
-
960
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
961
- end
962
-
963
894
def test_has
964
895
array = [
965
896
{ "handle" => "alpha" , "ok" => true } ,
@@ -1028,16 +959,6 @@ def test_has_with_false_value_when_does_not_have_it
1028
959
assert_template_result ( expected_output , template , { "array" => array } )
1029
960
end
1030
961
1031
- def test_has_with_deep_enumerables
1032
- template = <<~LIQUID
1033
- {{- products | has: 'title.content', 'Pro goggles' -}},
1034
- {{- products | has: 'title.content', 'foo' -}}
1035
- LIQUID
1036
- expected_output = "true,false"
1037
-
1038
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
1039
- end
1040
-
1041
962
def test_find_with_value
1042
963
products = [
1043
964
{ "title" => "Pro goggles" , "price" => 1299 } ,
@@ -1056,16 +977,6 @@ def test_find_with_value
1056
977
assert_template_result ( expected_output , template , { "products" => products } )
1057
978
end
1058
979
1059
- def test_find_with_deep_enumerables
1060
- template = <<~LIQUID
1061
- {%- assign product = products | find: 'title.content', 'Pro goggles' -%}
1062
- {{- product.title.content -}}
1063
- LIQUID
1064
- expected_output = "Pro goggles"
1065
-
1066
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
1067
- end
1068
-
1069
980
def test_find_with_empty_arrays
1070
981
template = <<~LIQUID
1071
982
{%- assign product = products | find: 'title.content', 'Not found' -%}
@@ -1096,16 +1007,6 @@ def test_find_index_with_value
1096
1007
assert_template_result ( expected_output , template , { "products" => products } )
1097
1008
end
1098
1009
1099
- def test_find_index_with_deep_enumerables
1100
- template = <<~LIQUID
1101
- {%- assign index = products | find_index: 'title.content', 'Alpine jacket' -%}
1102
- {{- index -}}
1103
- LIQUID
1104
- expected_output = "2"
1105
-
1106
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
1107
- end
1108
-
1109
1010
def test_find_index_with_empty_arrays
1110
1011
template = <<~LIQUID
1111
1012
{%- assign index = products | find_index: 'title.content', 'Not found' -%}
@@ -1216,15 +1117,6 @@ def test_where_array_of_only_unindexable_values
1216
1117
assert_nil ( @filters . where ( [ nil ] , "ok" ) )
1217
1118
end
1218
1119
1219
- def test_where_with_deep_enumerables
1220
- template = <<~LIQUID
1221
- {{- products | where: 'title.content', 'Pro goggles' | map: 'price.value' -}}
1222
- LIQUID
1223
- expected_output = "1299"
1224
-
1225
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
1226
- end
1227
-
1228
1120
def test_all_filters_never_raise_non_liquid_exception
1229
1121
test_drop = TestDrop . new ( value : "test" )
1230
1122
test_drop . context = Context . new
@@ -1376,15 +1268,6 @@ def test_sum_with_floats_and_indexable_map_values
1376
1268
assert_template_result ( "0" , "{{ input | sum: 'subtotal' }}" , { "input" => input } )
1377
1269
end
1378
1270
1379
- def test_sum_with_deep_enumerables
1380
- template = <<~LIQUID
1381
- {{- products | sum: 'price.value' -}}
1382
- LIQUID
1383
- expected_output = "12495"
1384
-
1385
- assert_template_result ( expected_output , template , { "products" => TestDeepEnumerable . new } )
1386
- end
1387
-
1388
1271
private
1389
1272
1390
1273
def with_timezone ( tz )
0 commit comments