From 6b594e498c63bbc6549667d89c53de5148a59e21 Mon Sep 17 00:00:00 2001 From: ulferts Date: Tue, 1 Nov 2022 13:03:55 +0100 Subject: [PATCH] bump psych --- Gemfile.lock | 2 +- app/models/custom_actions/actions/serializer.rb | 2 +- app/models/queries/work_packages/filter_serializer.rb | 2 +- config/constants/settings/definition.rb | 2 ++ spec/constants/settings/definition_spec.rb | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index caceb8cce9..45b4c47c89 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -719,7 +719,7 @@ GEM pry-stack_explorer (0.6.1) binding_of_caller (~> 1.0) pry (~> 0.13) - psych (4.0.4) + psych (4.0.6) stringio public_suffix (5.0.0) puffing-billy (3.0.4) diff --git a/app/models/custom_actions/actions/serializer.rb b/app/models/custom_actions/actions/serializer.rb index 8184d7f5f8..2a4e86b2dc 100644 --- a/app/models/custom_actions/actions/serializer.rb +++ b/app/models/custom_actions/actions/serializer.rb @@ -33,7 +33,7 @@ module CustomActions::Actions::Serializer return [] unless value YAML - .safe_load(value, permitted_classes: [Symbol]) + .safe_load(value, permitted_classes: [Symbol, Date]) .map do |key, values| klass = nil diff --git a/app/models/queries/work_packages/filter_serializer.rb b/app/models/queries/work_packages/filter_serializer.rb index cce9ed3677..70b9abaf07 100644 --- a/app/models/queries/work_packages/filter_serializer.rb +++ b/app/models/queries/work_packages/filter_serializer.rb @@ -37,7 +37,7 @@ module Queries::WorkPackages::FilterSerializer yaml = serialized_filter_hash .gsub('!ruby/object:Syck::DefaultKey {}', '"="') - (YAML.load(yaml) || {}).each_with_object([]) do |(field, options), array| + (YAML.load(yaml, permitted_classes: [Symbol, Date]) || {}).each_with_object([]) do |(field, options), array| options = options.with_indifferent_access filter = filter_for(field, no_memoization: true) filter.operator = options['operator'] diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rb index e0bb19bfe9..9db59465e7 100644 --- a/config/constants/settings/definition.rb +++ b/config/constants/settings/definition.rb @@ -89,6 +89,8 @@ module Settings if format == :hash self.value = {} if value.nil? value.deep_merge! other_value.deep_stringify_keys + elsif format == :datetime && !other_value.is_a?(DateTime) + self.value = DateTime.parse(other_value) else self.value = other_value end diff --git a/spec/constants/settings/definition_spec.rb b/spec/constants/settings/definition_spec.rb index 5adb44ead1..098ff0c3af 100644 --- a/spec/constants/settings/definition_spec.rb +++ b/spec/constants/settings/definition_spec.rb @@ -156,11 +156,11 @@ describe Settings::Definition do .to be false end - it 'overriding date configuration from ENV will cast the value' do + it 'overriding datetime configuration from ENV will cast the value' do stub_const('ENV', { 'OPENPROJECT_CONSENT__TIME' => '2222-01-01' }) expect(all.detect { |d| d.name == 'consent_time' }.value) - .to eql Date.parse('2222-01-01') + .to eql DateTime.parse('2222-01-01') end it 'overriding configuration from ENV will set it to non writable' do