##// END OF EJS Templates
Merged r12126 from trunk (#13008)....
Jean-Philippe Lang -
r11897:ddc016d81d64
parent child
Show More
@@ -33,7 +33,7 class UserPreference < ActiveRecord::Base
33 33 end
34 34
35 35 def [](attr_name)
36 if attribute_present? attr_name
36 if has_attribute? attr_name
37 37 super
38 38 else
39 39 others ? others[attr_name] : nil
@@ -41,7 +41,7 class UserPreference < ActiveRecord::Base
41 41 end
42 42
43 43 def []=(attr_name, value)
44 if attribute_present? attr_name
44 if has_attribute? attr_name
45 45 super
46 46 else
47 47 h = (read_attribute(:others) || {}).dup
@@ -55,6 +55,11 class UserPreferenceTest < ActiveSupport::TestCase
55 55 assert_kind_of Hash, up.others
56 56 end
57 57
58 def test_others_should_be_blank_after_initialization
59 pref = User.new.pref
60 assert_equal({}, pref.others)
61 end
62
58 63 def test_reading_value_from_nil_others_hash
59 64 up = UserPreference.new(:user => User.new)
60 65 up.others = nil
General Comments 0
You need to be logged in to leave comments. Login now