Merged r10438 from trunk.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.1-stable@10524 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
fe61739108
commit
daea57a37c
|
@ -44,7 +44,7 @@ class UserPreference < ActiveRecord::Base
|
||||||
if attribute_present? attr_name
|
if attribute_present? attr_name
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
h = read_attribute(:others).dup || {}
|
h = (read_attribute(:others) || {}).dup
|
||||||
h.update(attr_name => value)
|
h.update(attr_name => value)
|
||||||
write_attribute(:others, h)
|
write_attribute(:others, h)
|
||||||
value
|
value
|
||||||
|
|
|
@ -54,4 +54,19 @@ class UserPreferenceTest < ActiveSupport::TestCase
|
||||||
assert up.save
|
assert up.save
|
||||||
assert_kind_of Hash, up.others
|
assert_kind_of Hash, up.others
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_reading_value_from_nil_others_hash
|
||||||
|
up = UserPreference.new(:user => User.new)
|
||||||
|
up.others = nil
|
||||||
|
assert_nil up.others
|
||||||
|
assert_nil up[:foo]
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_writing_value_to_nil_others_hash
|
||||||
|
up = UserPreference.new(:user => User.new)
|
||||||
|
up.others = nil
|
||||||
|
assert_nil up.others
|
||||||
|
up[:foo] = 'bar'
|
||||||
|
assert_equal 'bar', up[:foo]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue