From 0540781539508e09e5db176edfc72031773b0dc7 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 19 Sep 2009 13:04:12 -0500 Subject: Namespace TestControllers inside their test case class --- actionpack/test/controller/render_xml_test.rb | 68 ++++++++++++++------------- 1 file changed, 36 insertions(+), 32 deletions(-) (limited to 'actionpack/test/controller/render_xml_test.rb') diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb index e96e8a4d57..68a52c3e8c 100644 --- a/actionpack/test/controller/render_xml_test.rb +++ b/actionpack/test/controller/render_xml_test.rb @@ -2,37 +2,41 @@ require 'abstract_unit' require 'controller/fake_models' require 'pathname' -class TestController < ActionController::Base - protect_from_forgery +class RenderXmlTest < ActionController::TestCase + class TestController < ActionController::Base + protect_from_forgery - def render_with_location - render :xml => "", :location => "http://example.com", :status => 201 - end + def self.controller_path + 'test' + end - def render_with_object_location - customer = Customer.new("Some guy", 1) - render :xml => "", :location => customer, :status => :created - end + def render_with_location + render :xml => "", :location => "http://example.com", :status => 201 + end - def render_with_to_xml - to_xmlable = Class.new do - def to_xml - "" - end - end.new + def render_with_object_location + customer = Customer.new("Some guy", 1) + render :xml => "", :location => customer, :status => :created + end - render :xml => to_xmlable - end - - def formatted_xml_erb + def render_with_to_xml + to_xmlable = Class.new do + def to_xml + "" + end + end.new + + render :xml => to_xmlable + end + + def formatted_xml_erb + end + + def render_xml_with_custom_content_type + render :xml => "", :content_type => "application/atomsvc+xml" + end end - - def render_xml_with_custom_content_type - render :xml => "", :content_type => "application/atomsvc+xml" - end -end -class RenderTest < ActionController::TestCase tests TestController def setup @@ -42,8 +46,8 @@ class RenderTest < ActionController::TestCase @controller.logger = Logger.new(nil) @request.host = "www.nextangle.com" - end - + end + def test_rendering_with_location_should_set_header get :render_with_location assert_equal "http://example.com", @response.headers["Location"] @@ -53,7 +57,7 @@ class RenderTest < ActionController::TestCase get :render_with_to_xml assert_equal "", @response.body end - + def test_rendering_with_object_location_should_set_header_with_url_for with_routing do |set| set.draw do |map| @@ -65,19 +69,19 @@ class RenderTest < ActionController::TestCase assert_equal "http://www.nextangle.com/customers/1", @response.headers["Location"] end end - + def test_should_render_formatted_xml_erb_template get :formatted_xml_erb, :format => :xml assert_equal 'passed formatted xml erb', @response.body end - + def test_should_render_xml_but_keep_custom_content_type get :render_xml_with_custom_content_type assert_equal "application/atomsvc+xml", @response.content_type end - + def test_should_use_implicit_content_type get :implicit_content_type, :format => 'atom' assert_equal Mime::ATOM, @response.content_type - end + end end -- cgit v1.2.3