diff options
Diffstat (limited to 'activesupport/test/caching_test.rb')
-rw-r--r-- | activesupport/test/caching_test.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index 51d04d9388..928af256f4 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -146,6 +146,22 @@ class FileStoreTest < ActiveSupport::TestCase end include CacheStoreBehavior + + def test_expires_in + time = Time.local(2008, 4, 24) + Time.stubs(:now).returns(time) + File.stubs(:mtime).returns(time) + + @cache.write('foo', 'bar') + cache_read = lambda { @cache.read('foo', :expires_in => 1.minute) } + assert_equal 'bar', cache_read.call + + Time.stubs(:now).returns(time + 30.seconds) + assert_equal 'bar', cache_read.call + + Time.stubs(:now).returns(time + 2.minutes) + assert_nil cache_read.call + end end class MemoryStoreTest < ActiveSupport::TestCase @@ -160,6 +176,12 @@ class MemoryStoreTest < ActiveSupport::TestCase assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') } assert_equal 'bar', @cache.read('foo') end + + def test_original_store_objects_should_not_be_immutable + bar = 'bar' + @cache.write('foo', bar) + assert_nothing_raised { bar.gsub!(/.*/, 'baz') } + end end uses_memcached 'memcached backed store' do |