diff --git a/app/models/setting.rb b/app/models/setting.rb index d4c82191..5341cc95 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -35,6 +35,11 @@ class Setting < ActiveRecord::Base v end + def value=(v) + v = v.to_yaml if @@available_settings[name]['serialized'] && v.is_a?(String) + write_attribute(:value, v) + end + # Returns the value of the setting named name def self.[](name) v = @cached_settings[name] diff --git a/test/unit/setting_test.rb b/test/unit/setting_test.rb index 44240ef4..34d07c19 100644 --- a/test/unit/setting_test.rb +++ b/test/unit/setting_test.rb @@ -36,4 +36,10 @@ class SettingTest < Test::Unit::TestCase # make sure db has been updated (UPDATE) assert_equal "My other title", Setting.find_by_name('app_title').value end + + def test_serialized_setting + Setting.notified_events = ['issue_added', 'issue_updated', 'news_added'] + assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.notified_events + assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.find_by_name('notified_events').value + end end