From cdb5cb06b280b48f5128c7b0db221a08c4d1ee70 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Fri, 13 Jan 2023 15:37:27 -0500 Subject: [PATCH 1/2] Remove == method from drops from testing to_liquid_value Since they could cause tests to pass without to_liquid_value being called on the left side of the equality comparison. --- test/test_helper.rb | 8 -------- 1 file changed, 8 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index 67900df8..49b1cc76 100755 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -131,10 +131,6 @@ class IntegerDrop < Liquid::Drop @value = value.to_i end - def ==(other) - @value == other - end - def to_s @value.to_s end @@ -150,10 +146,6 @@ class BooleanDrop < Liquid::Drop @value = value end - def ==(other) - @value == other - end - def to_liquid_value @value end From 619ed3fcd7e391e4a264372822fc36eecaa62e8d Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Fri, 13 Jan 2023 15:46:12 -0500 Subject: [PATCH 2/2] Add some additional to_liquid_value assertions --- test/integration/variable_test.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/integration/variable_test.rb b/test/integration/variable_test.rb index 0c42413c..c007f1f5 100644 --- a/test/integration/variable_test.rb +++ b/test/integration/variable_test.rb @@ -24,13 +24,17 @@ class VariableTest < Minitest::Test def test_if_tag_calls_to_liquid_value assert_template_result('one', '{% if foo == 1 %}one{% endif %}', { 'foo' => IntegerDrop.new('1') }) + assert_template_result('one', '{% if foo == eqv %}one{% endif %}', { 'foo' => IntegerDrop.new(1), 'eqv' => IntegerDrop.new(1) }) assert_template_result('one', '{% if 0 < foo %}one{% endif %}', { 'foo' => IntegerDrop.new('1') }) assert_template_result('one', '{% if foo > 0 %}one{% endif %}', { 'foo' => IntegerDrop.new('1') }) + assert_template_result('one', '{% if b > a %}one{% endif %}', { 'b' => IntegerDrop.new(1), 'a' => IntegerDrop.new(0) }) assert_template_result('true', '{% if foo == true %}true{% endif %}', { 'foo' => BooleanDrop.new(true) }) assert_template_result('true', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(true) }) assert_template_result('', '{% if foo %}true{% endif %}', { 'foo' => BooleanDrop.new(false) }) assert_template_result('', '{% if foo == true %}True{% endif %}', { 'foo' => BooleanDrop.new(false) }) + + assert_template_result('one', '{% if a contains x %}one{% endif %}', { 'a' => [1], 'x' => IntegerDrop.new(1) }) end def test_unless_tag_calls_to_liquid_value