diff options
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/store_test.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb index 2741f223da..dc47d40f41 100644 --- a/activerecord/test/cases/store_test.rb +++ b/activerecord/test/cases/store_test.rb @@ -29,6 +29,12 @@ class StoreTest < ActiveRecord::TestCase assert_equal 'graeters', @john.reload.settings[:icecream] end + test "overriding a read accessor" do + @john.settings[:phone_number] = '1234567890' + + assert_equal '(123) 456-7890', @john.phone_number + end + test "updating the store will mark it as changed" do @john.color = 'red' assert @john.settings_changed? @@ -54,6 +60,12 @@ class StoreTest < ActiveRecord::TestCase assert_equal false, @john.remember_login end + test "overriding a write accessor" do + @john.phone_number = '(123) 456-7890' + + assert_equal '1234567890', @john.settings[:phone_number] + end + test "preserve store attributes data in HashWithIndifferentAccess format without any conversion" do @john.json_data = HashWithIndifferentAccess.new(:height => 'tall', 'weight' => 'heavy') @john.height = 'low' @@ -124,7 +136,7 @@ class StoreTest < ActiveRecord::TestCase end test "all stored attributes are returned" do - assert_equal [:color, :homepage, :favorite_food], Admin::User.stored_attributes[:settings] + assert_equal [:color, :homepage, :favorite_food, :phone_number], Admin::User.stored_attributes[:settings] end test "stores_attributes are class level settings" do |