aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorMatt Jones <al2o3cr@gmail.com>2012-09-13 10:12:11 -0400
committerMatt Jones <al2o3cr@gmail.com>2012-09-13 10:12:11 -0400
commit46873aeded378bc836fb23925e5ab4f252f57b5b (patch)
treea0e03a08a4bacde7e3fa1a444b8b0973d82efa5c /activerecord/test/cases
parent01ef633f753cbc97ecd89b464af33e80fd0ca917 (diff)
downloadrails-46873aeded378bc836fb23925e5ab4f252f57b5b.tar.gz
rails-46873aeded378bc836fb23925e5ab4f252f57b5b.tar.bz2
rails-46873aeded378bc836fb23925e5ab4f252f57b5b.zip
refactor store_accessor
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/store_test.rb14
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