diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-22 14:16:34 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-22 14:52:50 -0600 |
commit | ba692a5bb83ad9cffc050c26234031445e1ac237 (patch) | |
tree | 65911ccb8e049721e053dd9823a97f958bd779b5 | |
parent | 22da898becb1e6d64ec6ed7894b2d58c217a0a71 (diff) | |
download | rails-ba692a5bb83ad9cffc050c26234031445e1ac237.tar.gz rails-ba692a5bb83ad9cffc050c26234031445e1ac237.tar.bz2 rails-ba692a5bb83ad9cffc050c26234031445e1ac237.zip |
Add missing test cases for `attribute_names` instance method
There is a class method with the same name that is tested, but not the
instance method.
-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) |