diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-18 23:54:37 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-06-18 23:54:37 -0300 |
commit | 69f19b292ad4b228f2bc5f89732a8ef3b704fab6 (patch) | |
tree | 6ef5368dd403dfb0d293dc8b8885f7d6d0c92a60 /activerecord/test/cases | |
parent | df2104e06784a4b98d8f30cb3ea4eee69304e768 (diff) | |
parent | 8593964d9741704ff030e3bdf61e0ed64526ecec (diff) | |
download | rails-69f19b292ad4b228f2bc5f89732a8ef3b704fab6.tar.gz rails-69f19b292ad4b228f2bc5f89732a8ef3b704fab6.tar.bz2 rails-69f19b292ad4b228f2bc5f89732a8ef3b704fab6.zip |
Merge pull request #5412 from tilsammans/stored_attributes
Added `stored_attributes` hash which contains the attributes stored using
ActiveRecord::Store. This allows you to retrieve the list of attributes
you've defined.
class User < ActiveRecord::Base
store :settings, accessors: [:color, :homepage]
end
User.stored_attributes[:settings] # [:color, :homepage]
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/store_test.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/test/cases/store_test.rb b/activerecord/test/cases/store_test.rb index 79476ed2a4..e401dd4b12 100644 --- a/activerecord/test/cases/store_test.rb +++ b/activerecord/test/cases/store_test.rb @@ -13,7 +13,7 @@ class StoreTest < ActiveRecord::TestCase assert_equal 'black', @john.color assert_nil @john.homepage end - + test "writing store attributes through accessors" do @john.color = 'red' @john.homepage = '37signals.com' @@ -111,4 +111,8 @@ class StoreTest < ActiveRecord::TestCase @john.is_a_good_guy = false assert_equal false, @john.is_a_good_guy end + + test "stored attributes are returned" do + assert_equal [:color, :homepage], Admin::User.stored_attributes[:settings] + end end |