diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-09-10 17:40:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-09-10 17:40:34 +0000 |
commit | ddc016d81d64895336c4589abea3525174772b75 (patch) | |
tree | c31e267927a1ecbd6b91167bd0771f51a82f92c4 | |
parent | e7c82e393442c775270754bb39c68857d8761613 (diff) | |
download | redmine-ddc016d81d64895336c4589abea3525174772b75.tar.gz redmine-ddc016d81d64895336c4589abea3525174772b75.zip |
Merged r12126 from trunk (#13008).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@12127 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/models/user_preference.rb | 4 | ||||
-rw-r--r-- | test/unit/user_preference_test.rb | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index cbeaec687..c4ec4e5ac 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -33,7 +33,7 @@ class UserPreference < ActiveRecord::Base end def [](attr_name) - if attribute_present? attr_name + if has_attribute? attr_name super else others ? others[attr_name] : nil @@ -41,7 +41,7 @@ class UserPreference < ActiveRecord::Base end def []=(attr_name, value) - if attribute_present? attr_name + if has_attribute? attr_name super else h = (read_attribute(:others) || {}).dup diff --git a/test/unit/user_preference_test.rb b/test/unit/user_preference_test.rb index b0092697f..d932286b9 100644 --- a/test/unit/user_preference_test.rb +++ b/test/unit/user_preference_test.rb @@ -55,6 +55,11 @@ class UserPreferenceTest < ActiveSupport::TestCase assert_kind_of Hash, up.others 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 up = UserPreference.new(:user => User.new) up.others = nil |