Upgraded Rails and RSpec
[monkeycharger.git] / vendor / rails / actionpack / test / controller / fragment_store_setting_test.rb
blob3df6fd0be2a8e4267767df0ac1e70e4ed630bce9
1 require File.dirname(__FILE__) + '/../abstract_unit'
3 MemCache = Struct.new(:MemCache, :address) unless Object.const_defined?(:MemCache)
5 class FragmentCacheStoreSettingTest < Test::Unit::TestCase
6   def teardown
7     ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::MemoryStore.new
8   end
9   
10   def test_file_fragment_cache_store
11     ActionController::Base.fragment_cache_store = :file_store, "/path/to/cache/directory"
12     assert_kind_of(
13       ActionController::Caching::Fragments::FileStore,
14       ActionController::Base.fragment_cache_store
15     )
16     assert_equal "/path/to/cache/directory", ActionController::Base.fragment_cache_store.cache_path
17   end
18   
19   def test_drb_fragment_cache_store
20     ActionController::Base.fragment_cache_store = :drb_store, "druby://localhost:9192"
21     assert_kind_of(
22       ActionController::Caching::Fragments::DRbStore,
23       ActionController::Base.fragment_cache_store
24     )
25     assert_equal "druby://localhost:9192", ActionController::Base.fragment_cache_store.address
26   end
28   if defined? CGI::Session::MemCacheStore
29     def test_mem_cache_fragment_cache_store
30       ActionController::Base.fragment_cache_store = :mem_cache_store, "localhost"
31       assert_kind_of(
32         ActionController::Caching::Fragments::MemCacheStore,
33         ActionController::Base.fragment_cache_store
34       )
35       assert_equal %w(localhost), ActionController::Base.fragment_cache_store.addresses
36     end
37   end
39   def test_object_assigned_fragment_cache_store
40     ActionController::Base.fragment_cache_store = ActionController::Caching::Fragments::FileStore.new("/path/to/cache/directory")
41     assert_kind_of(
42       ActionController::Caching::Fragments::FileStore,
43       ActionController::Base.fragment_cache_store
44     )
45     assert_equal "/path/to/cache/directory", ActionController::Base.fragment_cache_store.cache_path
46   end
47 end