提交 4abe29d8 编写于 作者: K Kasper Timm Hansen

Replace expectation with state check.

The tests would still pass if the cache call in the rendered templates were removed.
上级 7f60bedd
......@@ -352,6 +352,8 @@ def test_view_cache_dependencies_are_listed_in_declaration_order
end
class CollectionCacheController < ActionController::Base
attr_accessor :partial_rendered_times
def index
@customers = [Customer.new('david', params[:id] || 1)]
end
......@@ -377,14 +379,15 @@ def setup
super
@controller = CollectionCacheController.new
@controller.perform_caching = true
@controller.cache_store = ActiveSupport::Cache::MemoryStore.new
@controller.partial_rendered_times = 0
end
def test_collection_fetches_cached_views
get :index
assert_equal 1, @controller.partial_rendered_times
ActionView::PartialRenderer.expects(:collection_with_template).never
get :index
assert_equal 1, @controller.partial_rendered_times
end
def test_preserves_order_when_reading_from_cache_plus_rendering
......@@ -402,8 +405,9 @@ def test_explicit_render_call_with_options
def test_caching_works_with_beginning_comment
get :index_with_comment
assert_equal 1, @controller.partial_rendered_times
ActionView::PartialRenderer.expects(:collection_with_template).never
get :index_with_comment
assert_equal 1, @controller.partial_rendered_times
end
end
<%# I'm a comment %>
<% cache customer do %>
<% controller.partial_rendered_times += 1 %>
<%= customer.name %>, <%= customer.id %>
<% end %>
\ No newline at end of file
<% cache customer do %>
<% controller.partial_rendered_times += 1 %>
<%= customer.name %>, <%= customer.id %>
<% end %>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册