From ef9566d1886af250e080870ae4e8b96b0ae46b47 Mon Sep 17 00:00:00 2001 From: Roman Le Negrate Date: Wed, 27 Aug 2008 00:23:27 +0200 Subject: [PATCH] add failing test checking that layout MIME type should match response's --- actionpack/test/controller/mime_responds_test.rb | 26 ++++++++++++++++++++ .../layouts/multi_mime_layout_post.html.erb | 1 + .../layouts/multi_mime_layout_post.js.erb | 1 + .../layouts/multi_mime_layout_post.xml.erb | 1 + .../multi_mime_layout_post/_sub_html.html.erb | 1 + .../multi_mime_layout_post/index.html.erb | 1 + .../post_test/multi_mime_layout_post/index.js.erb | 1 + .../post_test/multi_mime_layout_post/index.xml.erb | 1 + 8 files changed, 33 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.html.erb create mode 100644 actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.js.erb create mode 100644 actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.xml.erb create mode 100644 actionpack/test/fixtures/post_test/multi_mime_layout_post/_sub_html.html.erb create mode 100644 actionpack/test/fixtures/post_test/multi_mime_layout_post/index.html.erb create mode 100644 actionpack/test/fixtures/post_test/multi_mime_layout_post/index.js.erb create mode 100644 actionpack/test/fixtures/post_test/multi_mime_layout_post/index.xml.erb diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb index 0d508eb..410aab6 100644 --- a/actionpack/test/controller/mime_responds_test.rb +++ b/actionpack/test/controller/mime_responds_test.rb @@ -509,6 +509,16 @@ class SuperPostController < PostController end end +class MultiMimeLayoutPostController < AbstractPostController + def index + respond_to do |type| + type.html + type.xml + type.js + end + end +end + class MimeControllerLayoutsTest < Test::Unit::TestCase def setup @request = ActionController::TestRequest.new @@ -537,4 +547,20 @@ class MimeControllerLayoutsTest < Test::Unit::TestCase get :index assert_equal '
Super iPhone
', @response.body end + + def test_layout_mime_should_match_responses + @controller = MultiMimeLayoutPostController.new + + @request.accept = "text/html" + get :index + assert_equal 'layout.html.erb > index.html.erb', @response.body + + @request.accept = "text/xml" + get :index + assert_equal 'layout.xml.erb > index.xml.erb', @response.body + + @request.accept = "application/x-javascript" + get :index + assert_equal 'layout.js.erb > index.js.erb (_sub_html.html.erb)', @response.body + end end diff --git a/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.html.erb b/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.html.erb new file mode 100644 index 0000000..932f5cf --- /dev/null +++ b/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.html.erb @@ -0,0 +1 @@ +layout.html.erb > <%= yield %> \ No newline at end of file diff --git a/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.js.erb b/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.js.erb new file mode 100644 index 0000000..bc4995b --- /dev/null +++ b/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.js.erb @@ -0,0 +1 @@ +layout.js.erb > <%= yield %> \ No newline at end of file diff --git a/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.xml.erb b/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.xml.erb new file mode 100644 index 0000000..91ee66d --- /dev/null +++ b/actionpack/test/fixtures/post_test/layouts/multi_mime_layout_post.xml.erb @@ -0,0 +1 @@ +layout.xml.erb > <%= yield %> \ No newline at end of file diff --git a/actionpack/test/fixtures/post_test/multi_mime_layout_post/_sub_html.html.erb b/actionpack/test/fixtures/post_test/multi_mime_layout_post/_sub_html.html.erb new file mode 100644 index 0000000..c25c99a --- /dev/null +++ b/actionpack/test/fixtures/post_test/multi_mime_layout_post/_sub_html.html.erb @@ -0,0 +1 @@ +_sub_html.html.erb \ No newline at end of file diff --git a/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.html.erb b/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.html.erb new file mode 100644 index 0000000..81a0589 --- /dev/null +++ b/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.html.erb @@ -0,0 +1 @@ +index.html.erb \ No newline at end of file diff --git a/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.js.erb b/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.js.erb new file mode 100644 index 0000000..32548cb --- /dev/null +++ b/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.js.erb @@ -0,0 +1 @@ +index.js.erb (<%= render :partial => 'sub_html'%>) \ No newline at end of file diff --git a/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.xml.erb b/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.xml.erb new file mode 100644 index 0000000..45674a2 --- /dev/null +++ b/actionpack/test/fixtures/post_test/multi_mime_layout_post/index.xml.erb @@ -0,0 +1 @@ +index.xml.erb \ No newline at end of file -- 1.5.5.3