提交 3142bf51 编写于 作者: R Rafael Mendonça França

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

Conflicts:
	activerecord/test/models/bulb.rb
	activerecord/test/schema/schema.rb
上级 567cdd1f
......@@ -23,6 +23,8 @@
require 'models/joke'
require 'models/bulb'
require 'models/bird'
require 'models/car'
require 'models/bulb'
require 'rexml/document'
require 'active_support/core_ext/exception'
......@@ -1442,6 +1444,16 @@ def test_cache_key_format_for_existing_record_with_updated_at
assert_equal "developers/#{dev.id}-#{dev.updated_at.utc.to_s(:nsec)}", dev.cache_key
end
def test_cache_key_changes_when_child_touched
car = Car.create
Bulb.create(car: car)
key = car.cache_key
car.bulb.touch
car.reload
assert_not_equal key, car.cache_key
end
def test_cache_key_format_for_existing_record_with_nil_updated_at
dev = Developer.first
dev.update_columns(updated_at: nil)
......
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
class Bulb < ActiveRecord::Base
default_scope { where(:name => 'defaulty') }
belongs_to :car
belongs_to :car, :touch => true
attr_reader :scope_after_initialize, :attributes_after_initialize
......
......@@ -115,6 +115,7 @@ def create_table(*args, &block)
t.integer :engines_count
t.integer :wheels_count
t.column :lock_version, :integer, :null => false, :default => 0
t.timestamps
end
create_table :categories, :force => true do |t|
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册