aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-06-13 10:11:54 +0930
committerMatthew Draper <matthew@trebex.net>2014-06-13 10:11:54 +0930
commitb4b3228566708ae67c2339e592e7698fcc2a398c (patch)
tree01da221c150b9ca61ee940951990fc57c8c69251 /activerecord
parent7eb110f104209208e4c76306775cc3bc6e9f129f (diff)
parent150f1c8da286b1b29602c579b5d2b78bc7fce52d (diff)
downloadrails-b4b3228566708ae67c2339e592e7698fcc2a398c.tar.gz
rails-b4b3228566708ae67c2339e592e7698fcc2a398c.tar.bz2
rails-b4b3228566708ae67c2339e592e7698fcc2a398c.zip
Merge pull request #15678 from sgrif/sg-test-hash
Add a test to ensure we don't get a performance regression on #hash
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/base_test.rb7
1 files changed, 7 insertions, 0 deletions
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