Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Fix deserialization issue with Settings

Christophe Bliarda068798bb5bc
diff --git a/config/constants/settings/definition.rb b/config/constants/settings/definition.rb
index 83d20e05e6c..1403dc1f78d 100644
--- a/config/constants/settings/definition.rb
+++ b/config/constants/settings/definition.rb
@@ -1100,12 +1100,11 @@ module Settings
end
def override_value(other_value)
- coerced_value = coerce(other_value)
- if valid_for?(coerced_value)
- self.value = coerced_value
+ self.value = coerce(other_value)
+ if valid_for?(value)
self.writable = false
else
- raise ArgumentError, "Value for #{name} must be one of #{allowed.join(', ')} but is #{coerced_value}"
+ raise ArgumentError, "Value for #{name} must be one of #{allowed.join(', ')} but is #{value}"
end
end
diff --git a/spec/constants/settings/definition_spec.rb b/spec/constants/settings/definition_spec.rb
index aaba8e0332e..cbd5fc8c7b1 100644
--- a/spec/constants/settings/definition_spec.rb
+++ b/spec/constants/settings/definition_spec.rb
@@ -79,13 +79,16 @@ RSpec.describe Settings::Definition, :settings_reset do
stub_const('ENV',
{
'OPENPROJECT_EDITION' => 'bim',
- 'OPENPROJECT_DEFAULT__LANGUAGE' => 'de'
+ 'OPENPROJECT_DEFAULT__LANGUAGE' => 'de',
+ 'OPENPROJECT_RAILS__CACHE__STORE' => 'memcache'
})
reset(:edition)
reset(:default_language)
+ reset(:rails_cache_store)
- expect(all[:edition].value).to eql 'bim'
- expect(all[:default_language].value).to eql 'de'
+ expect(all[:edition].value).to eq 'bim'
+ expect(all[:default_language].value).to eq 'de'
+ expect(all[:rails_cache_store].value).to eq :memcache
end
it 'allows overriding configuration from ENV with OPENPROJECT_ prefix with single underscore case' do