@@ -35,6 +35,11 class Setting < ActiveRecord::Base | |||
|
35 | 35 | v |
|
36 | 36 | end |
|
37 | 37 | |
|
38 | def value=(v) | |
|
39 | v = v.to_yaml if @@available_settings[name]['serialized'] && v.is_a?(String) | |
|
40 | write_attribute(:value, v) | |
|
41 | end | |
|
42 | ||
|
38 | 43 | # Returns the value of the setting named name |
|
39 | 44 | def self.[](name) |
|
40 | 45 | v = @cached_settings[name] |
@@ -36,4 +36,10 class SettingTest < Test::Unit::TestCase | |||
|
36 | 36 | # make sure db has been updated (UPDATE) |
|
37 | 37 | assert_equal "My other title", Setting.find_by_name('app_title').value |
|
38 | 38 | end |
|
39 | ||
|
40 | def test_serialized_setting | |
|
41 | Setting.notified_events = ['issue_added', 'issue_updated', 'news_added'] | |
|
42 | assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.notified_events | |
|
43 | assert_equal ['issue_added', 'issue_updated', 'news_added'], Setting.find_by_name('notified_events').value | |
|
44 | end | |
|
39 | 45 | end |
General Comments 0
You need to be logged in to leave comments.
Login now