Upgrade to Rails 2.2.0
As a side benefit, fix an (non-user-visible) bug in display_s5(). Also fixed a bug where removing orphaned pages did not expire cached summary pages.
This commit is contained in:
parent
39348c65c2
commit
7600aef48b
827 changed files with 123652 additions and 11027 deletions
101
vendor/rails/activesupport/test/caching_test.rb
vendored
101
vendor/rails/activesupport/test/caching_test.rb
vendored
|
@ -70,3 +70,104 @@ uses_mocha 'high-level cache store tests' do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Tests the base functionality that should be identical across all cache stores.
|
||||
module CacheStoreBehavior
|
||||
def test_should_read_and_write_strings
|
||||
@cache.write('foo', 'bar')
|
||||
assert_equal 'bar', @cache.read('foo')
|
||||
end
|
||||
|
||||
def test_should_read_and_write_hash
|
||||
@cache.write('foo', {:a => "b"})
|
||||
assert_equal({:a => "b"}, @cache.read('foo'))
|
||||
end
|
||||
|
||||
def test_should_read_and_write_nil
|
||||
@cache.write('foo', nil)
|
||||
assert_equal nil, @cache.read('foo')
|
||||
end
|
||||
|
||||
def test_fetch_without_cache_miss
|
||||
@cache.write('foo', 'bar')
|
||||
assert_equal 'bar', @cache.fetch('foo') { 'baz' }
|
||||
end
|
||||
|
||||
def test_fetch_with_cache_miss
|
||||
assert_equal 'baz', @cache.fetch('foo') { 'baz' }
|
||||
end
|
||||
|
||||
def test_fetch_with_forced_cache_miss
|
||||
@cache.fetch('foo', :force => true) { 'bar' }
|
||||
end
|
||||
|
||||
def test_increment
|
||||
@cache.write('foo', 1, :raw => true)
|
||||
assert_equal 1, @cache.read('foo', :raw => true).to_i
|
||||
assert_equal 2, @cache.increment('foo')
|
||||
assert_equal 2, @cache.read('foo', :raw => true).to_i
|
||||
assert_equal 3, @cache.increment('foo')
|
||||
assert_equal 3, @cache.read('foo', :raw => true).to_i
|
||||
end
|
||||
|
||||
def test_decrement
|
||||
@cache.write('foo', 3, :raw => true)
|
||||
assert_equal 3, @cache.read('foo', :raw => true).to_i
|
||||
assert_equal 2, @cache.decrement('foo')
|
||||
assert_equal 2, @cache.read('foo', :raw => true).to_i
|
||||
assert_equal 1, @cache.decrement('foo')
|
||||
assert_equal 1, @cache.read('foo', :raw => true).to_i
|
||||
end
|
||||
end
|
||||
|
||||
class FileStoreTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:file_store, Dir.pwd)
|
||||
end
|
||||
|
||||
def teardown
|
||||
File.delete("foo.cache")
|
||||
end
|
||||
|
||||
include CacheStoreBehavior
|
||||
end
|
||||
|
||||
class MemoryStoreTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:memory_store)
|
||||
end
|
||||
|
||||
include CacheStoreBehavior
|
||||
|
||||
def test_store_objects_should_be_immutable
|
||||
@cache.write('foo', 'bar')
|
||||
assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
|
||||
assert_equal 'bar', @cache.read('foo')
|
||||
end
|
||||
end
|
||||
|
||||
uses_memcached 'memcached backed store' do
|
||||
class MemCacheStoreTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:mem_cache_store)
|
||||
@cache.clear
|
||||
end
|
||||
|
||||
include CacheStoreBehavior
|
||||
|
||||
def test_store_objects_should_be_immutable
|
||||
@cache.write('foo', 'bar')
|
||||
@cache.read('foo').gsub!(/.*/, 'baz')
|
||||
assert_equal 'bar', @cache.read('foo')
|
||||
end
|
||||
end
|
||||
|
||||
class CompressedMemCacheStore < Test::Unit::TestCase
|
||||
def setup
|
||||
@cache = ActiveSupport::Cache.lookup_store(:compressed_mem_cache_store)
|
||||
@cache.clear
|
||||
end
|
||||
|
||||
include CacheStoreBehavior
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue