Skip to content
This repository
Browse code

Make sure the tests pass in the case closer to described in #8195

Conflicts:
	activerecord/test/models/bulb.rb
	activerecord/test/schema/schema.rb
  • Loading branch information...
commit 3142bf51ee7afff880b4eb837434dae874b47491 1 parent 567cdd1
Rafael Mendonça França authored
12  activerecord/test/cases/base_test.rb
@@ -23,6 +23,8 @@
23 23
 require 'models/joke'
24 24
 require 'models/bulb'
25 25
 require 'models/bird'
  26
+require 'models/car'
  27
+require 'models/bulb'
26 28
 require 'rexml/document'
27 29
 require 'active_support/core_ext/exception'
28 30
 
@@ -1442,6 +1444,16 @@ def test_cache_key_format_for_existing_record_with_updated_at
1442 1444
     assert_equal "developers/#{dev.id}-#{dev.updated_at.utc.to_s(:nsec)}", dev.cache_key
1443 1445
   end
1444 1446
 
  1447
+  def test_cache_key_changes_when_child_touched
  1448
+    car = Car.create
  1449
+    Bulb.create(car: car)
  1450
+
  1451
+    key = car.cache_key
  1452
+    car.bulb.touch
  1453
+    car.reload
  1454
+    assert_not_equal key, car.cache_key
  1455
+  end
  1456
+
1445 1457
   def test_cache_key_format_for_existing_record_with_nil_updated_at
1446 1458
     dev = Developer.first
1447 1459
     dev.update_columns(updated_at: nil)
18  activerecord/test/cases/cache_key_test.rb
... ...
@@ -1,18 +0,0 @@
1  
-require "cases/helper"
2  
-require "models/invoice"
3  
-require "models/line_item"
4  
-
5  
-class CacheKeyTest < ActiveRecord::TestCase
6  
-  def setup
7  
-    @invoice = Invoice.create
8  
-    LineItem.create(invoice: @invoice)
9  
-    @invoice.reload
10  
-  end
11  
-
12  
-  def test_cache_key_changes_when_child_touched
13  
-    key = @invoice.cache_key
14  
-    @invoice.line_items[0].touch
15  
-    @invoice.reload
16  
-    assert_not_equal key, @invoice.cache_key
17  
-  end
18  
-end
2  activerecord/test/models/bulb.rb
... ...
@@ -1,6 +1,6 @@
1 1
 class Bulb < ActiveRecord::Base
2 2
   default_scope { where(:name => 'defaulty') }
3  
-  belongs_to :car
  3
+  belongs_to :car, :touch => true
4 4
 
5 5
   attr_reader :scope_after_initialize, :attributes_after_initialize
6 6
 
1  activerecord/test/schema/schema.rb
@@ -115,6 +115,7 @@ def create_table(*args, &block)
115 115
     t.integer :engines_count
116 116
     t.integer :wheels_count
117 117
     t.column :lock_version, :integer, :null => false, :default => 0
  118
+    t.timestamps
118 119
   end
119 120
 
120 121
   create_table :categories, :force => true do |t|

0 notes on commit 3142bf5

Please sign in to comment.
Something went wrong with that request. Please try again.