Rails 2.3.3.1

Update to latest Rails.
A little bit of jiggery-pokery is involved, since they
neglected to re-include vendored Rack in this release.
This commit is contained in:
Jacques Distler 2009-08-04 10:16:03 -05:00
parent 329fafafce
commit 664552ac02
257 changed files with 4346 additions and 1682 deletions

View file

@ -1,3 +1,4 @@
require 'logger'
require 'abstract_unit'
class CacheKeyTest < ActiveSupport::TestCase
@ -20,22 +21,34 @@ class CacheStoreSettingTest < ActiveSupport::TestCase
end
def test_mem_cache_fragment_cache_store
MemCache.expects(:new).with(%w[localhost], {})
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost"
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
assert_equal %w(localhost), store.addresses
end
def test_mem_cache_fragment_cache_store_with_given_mem_cache
mem_cache = MemCache.new
MemCache.expects(:new).never
store = ActiveSupport::Cache.lookup_store :mem_cache_store, mem_cache
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
end
def test_mem_cache_fragment_cache_store_with_given_mem_cache_like_object
MemCache.expects(:new).never
store = ActiveSupport::Cache.lookup_store :mem_cache_store, stub("memcache", :get => true)
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
end
def test_mem_cache_fragment_cache_store_with_multiple_servers
MemCache.expects(:new).with(%w[localhost 192.168.1.1], {})
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", '192.168.1.1'
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
assert_equal %w(localhost 192.168.1.1), store.addresses
end
def test_mem_cache_fragment_cache_store_with_options
MemCache.expects(:new).with(%w[localhost 192.168.1.1], { :namespace => "foo" })
store = ActiveSupport::Cache.lookup_store :mem_cache_store, "localhost", '192.168.1.1', :namespace => 'foo'
assert_kind_of(ActiveSupport::Cache::MemCacheStore, store)
assert_equal %w(localhost 192.168.1.1), store.addresses
assert_equal 'foo', store.instance_variable_get('@data').instance_variable_get('@namespace')
end
def test_object_assigned_fragment_cache_store
@ -161,6 +174,8 @@ uses_memcached 'memcached backed store' do
@cache = ActiveSupport::Cache.lookup_store(:mem_cache_store)
@data = @cache.instance_variable_get(:@data)
@cache.clear
@cache.silence!
@cache.logger = Logger.new("/dev/null")
end
include CacheStoreBehavior
@ -173,6 +188,15 @@ uses_memcached 'memcached backed store' do
end
end
def test_stored_objects_should_not_be_frozen
@cache.with_local_cache do
@cache.write('foo', 'bar')
end
@cache.with_local_cache do
assert !@cache.read('foo').frozen?
end
end
def test_write_should_return_true_on_success
@cache.with_local_cache do
result = @cache.write('foo', 'bar')
@ -256,6 +280,15 @@ uses_memcached 'memcached backed store' do
end
end
def test_multi_get
@cache.with_local_cache do
@cache.write('foo', 1)
@cache.write('goo', 2)
result = @cache.read_multi('foo', 'goo')
assert_equal({'foo' => 1, 'goo' => 2}, result)
end
end
def test_middleware
app = lambda { |env|
result = @cache.write('foo', 'bar')
@ -265,6 +298,22 @@ uses_memcached 'memcached backed store' do
app = @cache.middleware.new(app)
app.call({})
end
def test_expires_in
result = @cache.write('foo', 'bar', :expires_in => 1)
assert_equal 'bar', @cache.read('foo')
sleep 2
assert_equal nil, @cache.read('foo')
end
def test_expires_in_with_invalid_value
@cache.write('baz', 'bat')
assert_raise(RuntimeError) do
@cache.write('foo', 'bar', :expires_in => 'Mon Jun 29 13:10:40 -0700 2150')
end
assert_equal 'bat', @cache.read('baz')
assert_equal nil, @cache.read('foo')
end
end
class CompressedMemCacheStore < ActiveSupport::TestCase