diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-28 12:22:24 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-10-28 12:22:24 -0700 |
commit | c82f0d76e4cfc9a80fe9988f5d1ca6f6a5594eed (patch) | |
tree | ef55c28c9ed1238840a2f3af1b166b3ec4ca51e9 /activerecord/test/cases | |
parent | e46a8d89baa5b58f19cd84cf9a57beb4507e7d9c (diff) | |
parent | 10f6f90d9d1bbc9598bffea90752fc6bd76904cd (diff) | |
download | rails-c82f0d76e4cfc9a80fe9988f5d1ca6f6a5594eed.tar.gz rails-c82f0d76e4cfc9a80fe9988f5d1ca6f6a5594eed.tar.bz2 rails-c82f0d76e4cfc9a80fe9988f5d1ca6f6a5594eed.zip |
Merge pull request #8056 from frodsan/fix_issue_missing_attribute
AR::AttributeMethods#[] raises AM::AttributeMissingError for missing attributes
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index c2b58fd7d1..8b82b79219 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -287,6 +287,12 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_equal "Don't change the topic", topic[:title] end + def test_read_attribute_raises_missing_attribute_error_when_not_exists + computer = Computer.select('id').first + assert_raises(ActiveModel::MissingAttributeError) { computer[:developer] } + assert_raises(ActiveModel::MissingAttributeError) { computer[:extendedWarranty] } + end + def test_read_attribute_when_false topic = topics(:first) topic.approved = false |