diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2011-10-13 16:23:48 -0500 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2011-10-13 16:24:22 -0500 |
commit | 85b64f98d100d37b3a232c315daa10fad37dccdc (patch) | |
tree | e1f4b621240502e7cb9b5530495840c2e8315c52 /activerecord/test/cases | |
parent | 8f11d53506ea7ef2fd4cd28581f5eedd9be9e570 (diff) | |
download | rails-85b64f98d100d37b3a232c315daa10fad37dccdc.tar.gz rails-85b64f98d100d37b3a232c315daa10fad37dccdc.tar.bz2 rails-85b64f98d100d37b3a232c315daa10fad37dccdc.zip |
Added ActiveRecord::Base.store for declaring simple single-column key/value stores [DHH]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/store_test.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb new file mode 100644 index 0000000000..3d056d93b6 --- /dev/null +++ b/activerecord/test/cases/store_test.rb @@ -0,0 +1,29 @@ +require 'cases/helper' +require 'models/admin' +require 'models/admin/user' + +class StoreTest < ActiveRecord::TestCase + setup do + @john = Admin::User.create(name: 'John Doe', color: 'black') + end + + test "reading store attributes through accessors" do + assert_equal 'black', @john.color + assert_nil @john.homepage + end + + test "writing store attributes through accessors" do + @john.color = 'red' + @john.homepage = '37signals.com' + + assert_equal 'red', @john.color + assert_equal '37signals.com', @john.homepage + end + + test "accessing attributes not exposed by accessors" do + @john.settings[:icecream] = 'graeters' + @john.save + + assert 'graeters', @john.reload.settings[:icecream] + end +end |