]> source.dussan.org Git - redmine.git/commitdiff
Merged r21725 from trunk to 4.2-stable (#37450, #37476).
authorGo MAEDA <maeda@farend.jp>
Thu, 21 Jul 2022 02:52:22 +0000 (02:52 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 21 Jul 2022 02:52:22 +0000 (02:52 +0000)
git-svn-id: https://svn.redmine.org/redmine/branches/4.2-stable@21730 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/setting.rb
test/unit/lib/redmine/plugin_test.rb

index 1418cf04bb0c26dd869c94978dfba0b55178f0bc..45a12103e4a30a46ad20bd563480aae5b53bd545 100644 (file)
@@ -105,7 +105,7 @@ class Setting < ActiveRecord::Base
     v = read_attribute(:value)
     # Unserialize serialized settings
     if available_settings[name]['serialized'] && v.is_a?(String)
-      v = YAML.safe_load(v, permitted_classes: [ActiveSupport::HashWithIndifferentAccess])
+      v = YAML.safe_load(v, permitted_classes: [Symbol, ActiveSupport::HashWithIndifferentAccess])
       v = force_utf8_strings(v)
     end
     v = v.to_sym if available_settings[name]['format'] == 'symbol' && !v.blank?
index 92898e1819cf299cb6a68df0f739f784fab483c3..8e8cc3cdc71aa4a49fefac54bbd7281106a73ac2 100644 (file)
@@ -191,6 +191,13 @@ class Redmine::PluginTest < ActiveSupport::TestCase
     end
   end
 
+  def test_default_settings
+    @klass.register(:foo_plugin) {settings :default => {'key1' => 'abc', :key2 => 123}}
+    h = Setting.plugin_foo_plugin
+    assert_equal 'abc', h['key1']
+    assert_equal 123, h[:key2]
+  end
+
   def test_settings_warns_about_possible_partial_collision
     @klass.register(:foo_plugin) {settings :partial => 'foo/settings'}
     Rails.logger.expects(:warn)