aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_base/etag_test.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-10-03 21:05:51 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-03 21:05:51 -0500
commit018b79dd36d054d87fdc408d38dc9ac7f1b1500d (patch)
treea954ecef58682b2d259432a04ce503f8bb865840 /actionpack/test/controller/new_base/etag_test.rb
parent84e94551f62d3bcbc71f1c6f3fda738342d984e2 (diff)
downloadrails-018b79dd36d054d87fdc408d38dc9ac7f1b1500d.tar.gz
rails-018b79dd36d054d87fdc408d38dc9ac7f1b1500d.tar.bz2
rails-018b79dd36d054d87fdc408d38dc9ac7f1b1500d.zip
File extra test folders into controller, dispatch, or template
Diffstat (limited to 'actionpack/test/controller/new_base/etag_test.rb')
-rw-r--r--actionpack/test/controller/new_base/etag_test.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/actionpack/test/controller/new_base/etag_test.rb b/actionpack/test/controller/new_base/etag_test.rb
new file mode 100644
index 0000000000..d5b7942ab6
--- /dev/null
+++ b/actionpack/test/controller/new_base/etag_test.rb
@@ -0,0 +1,46 @@
+require 'abstract_unit'
+
+module Etags
+ class BasicController < ActionController::Base
+ self.view_paths = [ActionView::FixtureResolver.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 => "etags"
+ end
+ end
+
+ class EtagTest < 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
+
+ private
+
+ def etag_for(text)
+ %("#{Digest::MD5.hexdigest(text)}")
+ end
+ end
+end