是否可以打开页面缓存进行功能测试?以下内容不起作用:
class ArticlesControllerTest < ActionController::TestCase
def setup
ActionController::Base.public_class_method :page_cache_path
ActionController::Base.perform_caching = true
end
end
提前致谢
Deb
我当前的解决方法是启用perform_caching
然后重新加载控制器:
class ProjectsCachingTest < ActionController::IntegrationTest
def setup
# force the controller to be reloaded when caching is enabled
ActionController::Base.perform_caching = true
load "projects_controller.rb"
end
def teardown
# undo the actions above
ActionController::Base.perform_caching = false
load "projects_controller.rb"
end
end
在最新版本的 Rails 2 中,您遇到的问题与类方法有关caches_action
and caches_page
。他们都创建了一个 around 过滤器来进行缓存,但仅当perform_caching
已启用。
所以,修改perform_caching
在运行时不会重新创建预期的过滤器周围。上面的示例是强制重新评估控制器的一种方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)