Fixed usage of #attribute_present? in UserPreference (#13008).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12126 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
15ab64488a
commit
06efcaddfa
|
@ -33,7 +33,7 @@ class UserPreference < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](attr_name)
|
def [](attr_name)
|
||||||
if attribute_present? attr_name
|
if has_attribute? attr_name
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
others ? others[attr_name] : nil
|
others ? others[attr_name] : nil
|
||||||
|
@ -41,7 +41,7 @@ class UserPreference < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def []=(attr_name, value)
|
def []=(attr_name, value)
|
||||||
if attribute_present? attr_name
|
if has_attribute? attr_name
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
h = (read_attribute(:others) || {}).dup
|
h = (read_attribute(:others) || {}).dup
|
||||||
|
|
|
@ -55,6 +55,11 @@ class UserPreferenceTest < ActiveSupport::TestCase
|
||||||
assert_kind_of Hash, up.others
|
assert_kind_of Hash, up.others
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_others_should_be_blank_after_initialization
|
||||||
|
pref = User.new.pref
|
||||||
|
assert_equal({}, pref.others)
|
||||||
|
end
|
||||||
|
|
||||||
def test_reading_value_from_nil_others_hash
|
def test_reading_value_from_nil_others_hash
|
||||||
up = UserPreference.new(:user => User.new)
|
up = UserPreference.new(:user => User.new)
|
||||||
up.others = nil
|
up.others = nil
|
||||||
|
|
Loading…
Reference in New Issue