From ea6e326b9ca65e7772866e6c47c5050a70313609 Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Wed, 28 Oct 2020 13:37:17 -0400 Subject: [PATCH] Fix FrozenError for blank case tag with multiple expression when tag (#1340) --- lib/liquid/tags/case.rb | 7 +++++-- test/integration/tags/standard_tag_test.rb | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/liquid/tags/case.rb b/lib/liquid/tags/case.rb index 879fcb7..9aeb797 100644 --- a/lib/liquid/tags/case.rb +++ b/lib/liquid/tags/case.rb @@ -22,8 +22,11 @@ module Liquid body = new_body body = @blocks.last.attachment while parse_body(body, tokens) @blocks.each do |condition| - condition.attachment.remove_blank_strings if blank? - condition.attachment.freeze + body = condition.attachment + unless body.frozen? + body.remove_blank_strings if blank? + body.freeze + end end end diff --git a/test/integration/tags/standard_tag_test.rb b/test/integration/tags/standard_tag_test.rb index 08b2aa0..ea7dca1 100644 --- a/test/integration/tags/standard_tag_test.rb +++ b/test/integration/tags/standard_tag_test.rb @@ -213,6 +213,11 @@ class StandardTagTest < Minitest::Test assert_template_result('', code, 'condition' => 'something else') end + def test_case_when_comma_and_blank_body + code = '{% case condition %}{% when 1, 2 %} {% assign r = "result" %} {% endcase %}{{ r }}' + assert_template_result('result', code, 'condition' => 2) + end + def test_assign assert_template_result('variable', '{% assign a = "variable"%}{{a}}') end