diff options
author | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-11 10:57:59 -0700 |
---|---|---|
committer | Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com> | 2009-05-11 10:57:59 -0700 |
commit | a2f3684cecb361db2bf5f7ec0b6de0603868ffd5 (patch) | |
tree | 792ded3b8c16eb4c47b512712be13171dab0d7e3 /actionpack/test/new_base | |
parent | 030dfe3f831aacd60bbfa525dfac4cd5921b6530 (diff) | |
download | rails-a2f3684cecb361db2bf5f7ec0b6de0603868ffd5.tar.gz rails-a2f3684cecb361db2bf5f7ec0b6de0603868ffd5.tar.bz2 rails-a2f3684cecb361db2bf5f7ec0b6de0603868ffd5.zip |
Ported fresh_when into a ConditionalGet module
Diffstat (limited to 'actionpack/test/new_base')
-rw-r--r-- | actionpack/test/new_base/etag_test.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/actionpack/test/new_base/etag_test.rb b/actionpack/test/new_base/etag_test.rb new file mode 100644 index 0000000000..7af5febfb3 --- /dev/null +++ b/actionpack/test/new_base/etag_test.rb @@ -0,0 +1,47 @@ +require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper") + +module Etags + + class BasicController < ActionController::Base + + self.view_paths = [ActionView::Template::FixturePath.new( + "etags/basic/base.html.erb" => "Hello from without_layout.html.erb", + "layouts/etags.html.erb" => "teh <%= yield %> tagz" + )] + + def without_layout + render :action => "base" + end + + def with_layout + render :action => "base", :layout => "etag" + end + + end + + class TestBasic < SimpleRouteCase + describe "Rendering without any special etag options returns an etag that is an MD5 hash of its text" + + test "an action without a layout" do + get "/etags/basic/without_layout" + body = "Hello from without_layout.html.erb" + assert_body body + assert_header "Etag", etag_for(body) + assert_status 200 + end + + test "an action with a layout" do + get "/etags/basic/with_layout" + body = "teh Hello from without_layout.html.erb tagz" + assert_body body + assert_header "Etag", etag_for(body) + assert_status 200 + end + + def etag_for(text) + %("#{Digest::MD5.hexdigest(text)}") + end + end + + +end
\ No newline at end of file |