From ba692a5bb83ad9cffc050c26234031445e1ac237 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 22 Jun 2014 14:16:34 -0600 Subject: 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. --- activerecord/test/cases/attribute_methods_test.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'activerecord/test') 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) -- cgit v1.2.3