aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-12 18:36:55 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-12 18:39:34 -0600
commit150f1c8da286b1b29602c579b5d2b78bc7fce52d (patch)
treeb945a3a900ceab84921e4e3293fbf3869a0a395c /activerecord
parent1cec61fc13a9809b616f1dcc74c1a9ccea9db08c (diff)
downloadrails-150f1c8da286b1b29602c579b5d2b78bc7fce52d.tar.gz
rails-150f1c8da286b1b29602c579b5d2b78bc7fce52d.tar.bz2
rails-150f1c8da286b1b29602c579b5d2b78bc7fce52d.zip
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