Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #15865 from sgrif/sg-missing-test

Add missing test cases for `attribute_names` instance method
  • Loading branch information...
commit b663869940e642b06c903eba2eb2b362585ed194 2 parents 7035a20 + ba692a5
@senny senny authored
Showing with 20 additions and 0 deletions.
  1. +20 −0 activerecord/test/cases/attribute_methods_test.rb
View
20 activerecord/test/cases/attribute_methods_test.rb
@@ -842,6 +842,26 @@ def test_attribute_method_returns_false_if_table_does_not_exist
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)
Please sign in to comment.
Something went wrong with that request. Please try again.