aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorEvan Light <evan@tripledogdare.net>2011-07-13 22:17:38 -0400
committerEvan Light <evan@tripledogdare.net>2011-07-14 14:04:02 -0400
commitf13dea8a3463b753a69c22fc27648160c013fc3b (patch)
tree0e7ec6af48a35a34a829ffdc9fe872d7139cca71 /activerecord/lib/active_record
parent003c6516dcffcd846d1f257a16062cea657cbd33 (diff)
downloadrails-f13dea8a3463b753a69c22fc27648160c013fc3b.tar.gz
rails-f13dea8a3463b753a69c22fc27648160c013fc3b.tar.bz2
rails-f13dea8a3463b753a69c22fc27648160c013fc3b.zip
Fix and unit test for https://github.com/rails/rails/issues/2059
Cache key was incorrectly using timezone-dependent record#updated_at when it should be using a timezone-independent value to generate the cache key Minor refactoring to cache_key timezone test Closes #2059 Adds a test to validate the format of the cache_key for nil and present updated_at values Correctly handles updated_at == nil
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/base.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index eb4a16ecf5..deff1c65ef 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1638,7 +1638,8 @@ MSG
when new_record?
"#{self.class.model_name.cache_key}/new"
when timestamp = self[:updated_at]
- "#{self.class.model_name.cache_key}/#{id}-#{timestamp.to_s(:number)}"
+ timestamp = timestamp.utc.to_s(:number)
+ "#{self.class.model_name.cache_key}/#{id}-#{timestamp}"
else
"#{self.class.model_name.cache_key}/#{id}"
end