aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/test/cases/cache_key_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/cache_key_test.rb b/activerecord/test/cases/cache_key_test.rb
new file mode 100644
index 0000000000..e52bbd3d30
--- /dev/null
+++ b/activerecord/test/cases/cache_key_test.rb
@@ -0,0 +1,18 @@
+require "cases/helper"
+require "models/invoice"
+require "models/line_item"
+
+class CacheKeyTest < ActiveRecord::TestCase
+ def setup
+ @invoice = Invoice.create
+ LineItem.create(invoice: @invoice)
+ @invoice.reload
+ end
+
+ def test_cache_key_changes_when_child_touched
+ key = @invoice.cache_key
+ @invoice.line_items[0].touch
+ @invoice.reload
+ assert_not_equal key, @invoice.cache_key
+ end
+end