mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user