]> source.dussan.org Git - redmine.git/commitdiff
Fixed usage of #attribute_present? in UserPreference (#13008).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 10 Sep 2013 17:39:49 +0000 (17:39 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 10 Sep 2013 17:39:49 +0000 (17:39 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12126 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user_preference.rb
test/unit/user_preference_test.rb

index 37d114ab5b355d228950a0b9f8cd1a170313a564..5fccf0485760d33cb947d10ba2fd74cef48683bb 100644 (file)
@@ -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
index b0092697f9a0460f9772808b57fd32ede8dd2c5c..d932286b9210fa993fe4f58271d2547a2e5404fe 100644 (file)
@@ -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