diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-29 21:35:30 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-10 17:35:16 -0300 |
commit | 3142bf51ee7afff880b4eb837434dae874b47491 (patch) | |
tree | 2a3aba87e9b0c4d59e46cd9c3c7640d881a16c71 | |
parent | 567cdd1f29850d66e4b895be2eba4a100df51371 (diff) | |
download | rails-3142bf51ee7afff880b4eb837434dae874b47491.tar.gz rails-3142bf51ee7afff880b4eb837434dae874b47491.tar.bz2 rails-3142bf51ee7afff880b4eb837434dae874b47491.zip |
Make sure the tests pass in the case closer to described in #8195
Conflicts:
activerecord/test/models/bulb.rb
activerecord/test/schema/schema.rb
-rw-r--r-- | activerecord/test/cases/base_test.rb | 12 | ||||
-rw-r--r-- | activerecord/test/cases/cache_key_test.rb | 18 | ||||
-rw-r--r-- | activerecord/test/models/bulb.rb | 2 | ||||
-rw-r--r-- | activerecord/test/schema/schema.rb | 1 |
4 files changed, 14 insertions, 19 deletions
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 8644f2f496..e4445698dc 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -23,6 +23,8 @@ require 'models/edge' 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 @@ class BasicsTest < ActiveRecord::TestCase 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) diff --git a/activerecord/test/cases/cache_key_test.rb b/activerecord/test/cases/cache_key_test.rb deleted file mode 100644 index e52bbd3d30..0000000000 --- a/activerecord/test/cases/cache_key_test.rb +++ /dev/null @@ -1,18 +0,0 @@ -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 diff --git a/activerecord/test/models/bulb.rb b/activerecord/test/models/bulb.rb index e4c0278c0d..0109ef4f83 100644 --- a/activerecord/test/models/bulb.rb +++ b/activerecord/test/models/bulb.rb @@ -1,6 +1,6 @@ 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 diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb index 35778d008a..af14bc7bd5 100644 --- a/activerecord/test/schema/schema.rb +++ b/activerecord/test/schema/schema.rb @@ -115,6 +115,7 @@ ActiveRecord::Schema.define do 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| |