diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2017-04-18 17:28:19 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-18 17:28:19 -0400 |
commit | a2ab5ffae97e3523e2d6a8f22222af4df001212f (patch) | |
tree | 77e61d80aa6f93cf823182356028ee231db6aa0b /activerecord/test | |
parent | 48c5139ae31328532e22b1726a67cfa40dbd680d (diff) | |
parent | ac623b8511d064419a1ae32d36d1c95c28aba01c (diff) | |
download | rails-a2ab5ffae97e3523e2d6a8f22222af4df001212f.tar.gz rails-a2ab5ffae97e3523e2d6a8f22222af4df001212f.tar.bz2 rails-a2ab5ffae97e3523e2d6a8f22222af4df001212f.zip |
Merge pull request #28161 from bogdanvlviv/add_test_attributes
Add test for method `#attributes`
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/base_test.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index ee1be09358..15c253890b 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -703,6 +703,17 @@ class BasicsTest < ActiveRecord::TestCase assert_nil topic.bonus_time end + def test_attributes + category = Category.new(name: "Ruby") + + expected_attributes = category.attribute_names.map do |attribute_name| + [attribute_name, category.public_send(attribute_name)] + end.to_h + + assert_instance_of Hash, category.attributes + assert_equal expected_attributes, category.attributes + end + def test_boolean b_nil = Boolean.create("value" => nil) nil_id = b_nil.id |