diff options
author | Yves Senn <yves.senn@gmail.com> | 2014-06-22 22:53:47 +0200 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2014-06-22 22:53:47 +0200 |
commit | b663869940e642b06c903eba2eb2b362585ed194 (patch) | |
tree | 4b56454cc6dd24519c2312cca10332532dfa2e4d /activerecord | |
parent | 7035a205a37057be290d75a65a397e161839c598 (diff) | |
parent | ba692a5bb83ad9cffc050c26234031445e1ac237 (diff) | |
download | rails-b663869940e642b06c903eba2eb2b362585ed194.tar.gz rails-b663869940e642b06c903eba2eb2b362585ed194.tar.bz2 rails-b663869940e642b06c903eba2eb2b362585ed194.zip |
Merge pull request #15865 from sgrif/sg-missing-test
Add missing test cases for `attribute_names` instance method
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/attribute_methods_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 84a7a8ef68..7566af920f 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -842,6 +842,26 @@ class AttributeMethodsTest < ActiveRecord::TestCase assert_not @target.attribute_method?(:title) end + def test_attribute_names_on_new_record + model = @target.new + + assert_equal @target.column_names, model.attribute_names + end + + def test_attribute_names_on_queried_record + model = @target.last! + + assert_equal @target.column_names, model.attribute_names + end + + def test_attribute_names_with_custom_select + model = @target.select('id').last! + + assert_equal ['id'], model.attribute_names + # Sanity check, make sure other columns exist + assert_not_equal ['id'], @target.column_names + end + private def new_topic_like_ar_class(&block) |