Index: test/fragment_cache_test.rb =================================================================== --- test/fragment_cache_test.rb (revision 890) +++ test/fragment_cache_test.rb (working copy) @@ -20,6 +20,10 @@ def index render :text => "doop!" end + + def edit + render :text => "rawk" + end def trees_are_swell? true @@ -103,6 +107,7 @@ include FragmentCacheSpecSetup page_content = "give me my bongos" index_content = "doop!" + edit_content = "rawk" setup do @controller = BarController.new @@ -186,4 +191,35 @@ get :page @response.body.should == page_content end + + #check for edginess + if FooController.respond_to?(:action_cache_path) + specify "should not break cache_path overrides" do + BarController.caches_action :page, :cache_path => 'http://test.host/some/custom/path' + cache_expects(:set).with('test.host/some/custom/path', page_content, ActsAsCached.config[:ttl]) + get :page + end + + specify "should not break cache_path block overrides" do + BarController.caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]}/edit" : "http://test.host/edit" } + cache_expects(:set).with('test.host/edit', edit_content, ActsAsCached.config[:ttl]) + get :edit + + get :index + cache_expects(:set).with('test.host/5/edit', edit_content, ActsAsCached.config[:ttl]) + get :edit, :id => 5 + end + + specify "should play nice with custom ttls and cache_path overrides" do + BarController.caches_action :page => { :ttl => 5.days }, :cache_path => 'http://test.host/my/custom/path' + cache_expects(:set).with('test.host/my/custom/path', page_content, 5.days) + get :page + end + + specify "should play nice with custom ttls and cache_path block overrides" do + BarController.caches_action :edit, :cache_path => Proc.new { |c| c.params[:id] ? "http://test.host/#{c.params[:id]}/edit" : "http://test.host/edit" } + cache_expects(:set).with('test.host/5/edit', edit_content, ActsAsCached.config[:ttl]) + get :edit, :id => 5 + end + end end Index: lib/acts_as_cached/fragment_cache.rb =================================================================== --- lib/acts_as_cached/fragment_cache.rb (revision 890) +++ lib/acts_as_cached/fragment_cache.rb (working copy) @@ -35,9 +35,8 @@ ::ActionController::Caching::Actions::ActionCacheFilter.class_eval do # convert all actions into a hash keyed by action named, with a value of a ttl hash (to match other cache APIs) def initialize(*actions, &block) - # no extract_options in 1.2.x - @options = actions.extract_options! if actions.respond_to? :extract_options! - @actions = actions.inject({}) do |hsh, action| + @options = actions.respond_to?(:extract_options!) ? actions.extract_options! : {} + @actions = actions.inject(@options.except(:cache_path)) do |hsh, action| action.is_a?(Hash) ? hsh.merge(action) : hsh.merge(action => { :ttl => nil }) end end @@ -67,7 +66,7 @@ else set_content_type!(action_cache_path) end - controller.send(:render_text, cache) + controller.send(:render_for_text, cache) false else # 1.2.x compatibility