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)
This commit is contained in:
Mir Bhatia
2026-06-04 13:18:48 +02:00
parent 2f63022e8f
commit 43e1ca89dc
2 changed files with 27 additions and 0 deletions
+4
View File
@@ -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?
@@ -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