From 150f1c8da286b1b29602c579b5d2b78bc7fce52d Mon Sep 17 00:00:00 2001 From: Sean Griffin <sean@thoughtbot.com> Date: Thu, 12 Jun 2014 18:36:55 -0600 Subject: Add a test to ensure we don't get a performance regression on #hash --- activerecord/test/cases/base_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index dc8f25b0e7..541f74f21e 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1597,4 +1597,11 @@ class BasicsTest < ActiveRecord::TestCase assert_equal after_handler, new_handler assert_equal orig_handler, klass.connection_handler end + + # Note: This is a performance optimization for Array#uniq and Hash#[] with + # AR::Base objects. If the future has made this irrelevant, feel free to + # delete this. + test "records without an id have unique hashes" do + assert_not_equal Post.new.hash, Post.new.hash + end end -- cgit v1.2.3