From 43e1ca89dc06792d7b4c1642ec02f6a716708da1 Mon Sep 17 00:00:00 2001 From: Mir Bhatia Date: Thu, 4 Jun 2026 13:18:48 +0200 Subject: [PATCH] Add blank string handling for CustomValue::DateStrategy Other strategies like BoolStrategy and LinkStrategy have a similar parse_value override to handle blank strings. This will equate '' to nil for the filter and thus fix the bug (OP-19456) --- app/models/custom_value/date_strategy.rb | 4 ++++ .../models/custom_value/date_strategy_spec.rb | 23 +++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/app/models/custom_value/date_strategy.rb b/app/models/custom_value/date_strategy.rb index 523aab51d84..084fe3b8bcf 100644 --- a/app/models/custom_value/date_strategy.rb +++ b/app/models/custom_value/date_strategy.rb @@ -31,6 +31,10 @@ class CustomValue::DateStrategy < CustomValue::FormatStrategy include Redmine::I18n + def parse_value(val) + val.presence + end + def typed_value return if value.blank? diff --git a/spec/models/custom_value/date_strategy_spec.rb b/spec/models/custom_value/date_strategy_spec.rb index 7f94776d728..98c7dbe04d1 100644 --- a/spec/models/custom_value/date_strategy_spec.rb +++ b/spec/models/custom_value/date_strategy_spec.rb @@ -133,4 +133,27 @@ RSpec.describe CustomValue::DateStrategy do end end end + + describe "#parse_value" do + subject { instance.parse_value(val) } + let(:value) { nil } # unused by parse_value but required by the double + + context "when value is a valid date string" do + let(:val) { "2025-07-03" } + + it { is_expected.to eq "2025-07-03" } + end + + context "when value is an empty string" do + let(:val) { "" } + + it { is_expected.to be_nil } + end + + context "when value is nil" do + let(:val) { nil } + + it { is_expected.to be_nil } + end + end end