diff options
author | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-02-25 12:38:09 +0200 |
---|---|---|
committer | bogdanvlviv <bogdanvlviv@gmail.com> | 2017-02-25 12:38:09 +0200 |
commit | ac623b8511d064419a1ae32d36d1c95c28aba01c (patch) | |
tree | c8b813a781c835599e1101c308b21ed92db6c037 /activerecord/test | |
parent | dd3adc5a0419b97d67e34d9677427f1681b2ca29 (diff) | |
download | rails-ac623b8511d064419a1ae32d36d1c95c28aba01c.tar.gz rails-ac623b8511d064419a1ae32d36d1c95c28aba01c.tar.bz2 rails-ac623b8511d064419a1ae32d36d1c95c28aba01c.zip |
Add test for method `#attributes`
ActiveRecord::AttributeMethods#attributes
Extracted from https://github.com/rails/rails/pull/28159
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 979a59f566..8efbc41da9 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 |