diff --git a/actionpack/test/controller/render_js_test.rb b/actionpack/test/controller/render_js_test.rb
index bc850de733e4827bd667c57b04af9b9d177547d7..491c98a0fdd57821309c2c4b3775208db000bf6b 100644
--- a/actionpack/test/controller/render_js_test.rb
+++ b/actionpack/test/controller/render_js_test.rb
@@ -2,23 +2,27 @@
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
+class RenderJSTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- def render_vanilla_js_hello
- render :js => "alert('hello')"
- end
-
- def greeting
- # let's just rely on the template
+ def self.controller_path
+ 'test'
+ end
+
+ def render_vanilla_js_hello
+ render :js => "alert('hello')"
+ end
+
+ def greeting
+ # let's just rely on the template
+ end
+
+ def show_partial
+ render :partial => 'partial'
+ end
end
-
- def show_partial
- render :partial => 'partial'
- end
-end
-class RenderTest < ActionController::TestCase
tests TestController
def test_render_vanilla_js
@@ -26,14 +30,14 @@ def test_render_vanilla_js
assert_equal "alert('hello')", @response.body
assert_equal "text/javascript", @response.content_type
end
-
+
def test_render_with_default_from_accept_header
xhr :get, :greeting
assert_equal "$(\"body\").visualEffect(\"highlight\");", @response.body
end
-
+
def test_should_render_js_partial
xhr :get, :show_partial, :format => 'js'
assert_equal 'partial js', @response.body
end
-end
\ No newline at end of file
+end
diff --git a/actionpack/test/controller/render_json_test.rb b/actionpack/test/controller/render_json_test.rb
index 233b2dfd894d571dc22d51414094d59cddda91f6..3938fc70615b39d30a97d2432b72a75520739108 100644
--- a/actionpack/test/controller/render_json_test.rb
+++ b/actionpack/test/controller/render_json_test.rb
@@ -2,35 +2,39 @@
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
-
- def render_json_nil
- render :json => nil
- end
+class RenderJsonTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- def render_json_hello_world
- render :json => ActiveSupport::JSON.encode(:hello => 'world')
- end
+ def self.controller_path
+ 'test'
+ end
- def render_json_hello_world_with_callback
- render :json => ActiveSupport::JSON.encode(:hello => 'world'), :callback => 'alert'
- end
+ def render_json_nil
+ render :json => nil
+ end
- def render_json_with_custom_content_type
- render :json => ActiveSupport::JSON.encode(:hello => 'world'), :content_type => 'text/javascript'
- end
+ def render_json_hello_world
+ render :json => ActiveSupport::JSON.encode(:hello => 'world')
+ end
- def render_symbol_json
- render :json => ActiveSupport::JSON.encode(:hello => 'world')
- end
+ def render_json_hello_world_with_callback
+ render :json => ActiveSupport::JSON.encode(:hello => 'world'), :callback => 'alert'
+ end
- def render_json_with_render_to_string
- render :json => {:hello => render_to_string(:partial => 'partial')}
- end
-end
+ def render_json_with_custom_content_type
+ render :json => ActiveSupport::JSON.encode(:hello => 'world'), :content_type => 'text/javascript'
+ end
+
+ def render_symbol_json
+ render :json => ActiveSupport::JSON.encode(:hello => 'world')
+ end
+
+ def render_json_with_render_to_string
+ render :json => {:hello => render_to_string(:partial => 'partial')}
+ end
+ end
-class RenderTest < ActionController::TestCase
tests TestController
def setup
@@ -40,8 +44,8 @@ def setup
@controller.logger = Logger.new(nil)
@request.host = "www.nextangle.com"
- end
-
+ end
+
def test_render_json_nil
get :render_json_nil
assert_equal 'null', @response.body
@@ -76,5 +80,5 @@ def test_render_json_with_render_to_string
get :render_json_with_render_to_string
assert_equal '{"hello":"partial html"}', @response.body
assert_equal 'application/json', @response.content_type
- end
-end
\ No newline at end of file
+ end
+end
diff --git a/actionpack/test/controller/render_other_test.rb b/actionpack/test/controller/render_other_test.rb
index 05645e47fa2931fbcb6ee2d19c2058061102931d..51c3c55545d126b76084f03c0dea279b694fbb63 100644
--- a/actionpack/test/controller/render_other_test.rb
+++ b/actionpack/test/controller/render_other_test.rb
@@ -2,139 +2,144 @@
require 'controller/fake_models'
require 'pathname'
-class TestController < ActionController::Base
- protect_from_forgery
- layout :determine_layout
+class RenderOtherTest < ActionController::TestCase
+ class TestController < ActionController::Base
+ protect_from_forgery
- module RenderTestHelper
- def rjs_helper_method_from_module
- page.visual_effect :highlight
+ def self.controller_path
+ 'test'
end
- end
- helper RenderTestHelper
- helper do
- def rjs_helper_method(value)
- page.visual_effect :highlight, value
+ layout :determine_layout
+
+ module RenderTestHelper
+ def rjs_helper_method_from_module
+ page.visual_effect :highlight
+ end
end
- end
- def enum_rjs_test
- render :update do |page|
- page.select('.product').each do |value|
- page.rjs_helper_method_from_module
- page.rjs_helper_method(value)
- page.sortable(value, :url => { :action => "order" })
- page.draggable(value)
+ helper RenderTestHelper
+ helper do
+ def rjs_helper_method(value)
+ page.visual_effect :highlight, value
end
end
- end
-
- def render_explicit_html_template
- end
-
- def render_custom_code_rjs
- render :update, :status => 404 do |page|
- page.replace :foo, :partial => 'partial'
+
+ def enum_rjs_test
+ render :update do |page|
+ page.select('.product').each do |value|
+ page.rjs_helper_method_from_module
+ page.rjs_helper_method(value)
+ page.sortable(value, :url => { :action => "order" })
+ page.draggable(value)
+ end
+ end
end
- end
-
- def render_implicit_html_template
- end
-
- def render_js_with_explicit_template
- @project_id = 4
- render :template => 'test/delete_with_js'
- end
- def render_js_with_explicit_action_template
- @project_id = 4
- render :action => 'delete_with_js'
- end
-
- def delete_with_js
- @project_id = 4
- end
-
- def update_page
- render :update do |page|
- page.replace_html 'balance', '$37,000,000.00'
- page.visual_effect :highlight, 'balance'
+ def render_explicit_html_template
+ end
+
+ def render_custom_code_rjs
+ render :update, :status => 404 do |page|
+ page.replace :foo, :partial => 'partial'
+ end
end
- end
- def update_page_with_instance_variables
- @money = '$37,000,000.00'
- @div_id = 'balance'
- render :update do |page|
- page.replace_html @div_id, @money
- page.visual_effect :highlight, @div_id
+ def render_implicit_html_template
end
- end
- def update_page_with_view_method
- render :update do |page|
- page.replace_html 'person', pluralize(2, 'person')
+ def render_js_with_explicit_template
+ @project_id = 4
+ render :template => 'test/delete_with_js'
end
- end
-
- def partial_as_rjs
- render :update do |page|
- page.replace :foo, :partial => 'partial'
+
+ def render_js_with_explicit_action_template
+ @project_id = 4
+ render :action => 'delete_with_js'
end
- end
- def respond_to_partial_as_rjs
- respond_to do |format|
- format.js do
- render :update do |page|
- page.replace :foo, :partial => 'partial'
- end
+ def delete_with_js
+ @project_id = 4
+ end
+
+ def update_page
+ render :update do |page|
+ page.replace_html 'balance', '$37,000,000.00'
+ page.visual_effect :highlight, 'balance'
end
end
- end
-
- def render_alternate_default
- # For this test, the method "default_render" is overridden:
- @alternate_default_render = lambda do
+
+ def update_page_with_instance_variables
+ @money = '$37,000,000.00'
+ @div_id = 'balance'
+ render :update do |page|
+ page.replace_html @div_id, @money
+ page.visual_effect :highlight, @div_id
+ end
+ end
+
+ def update_page_with_view_method
+ render :update do |page|
+ page.replace_html 'person', pluralize(2, 'person')
+ end
+ end
+
+ def partial_as_rjs
render :update do |page|
page.replace :foo, :partial => 'partial'
end
end
- end
-
-private
- def default_render
- if @alternate_default_render
- @alternate_default_render.call
- else
- super
+
+ def respond_to_partial_as_rjs
+ respond_to do |format|
+ format.js do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
end
- end
- def determine_layout
- case action_name
- when "hello_world", "layout_test", "rendering_without_layout",
- "rendering_nothing_on_layout", "render_text_hello_world",
- "render_text_hello_world_with_layout",
- "hello_world_with_layout_false",
- "partial_only", "partial_only_with_layout",
- "accessing_params_in_template",
- "accessing_params_in_template_with_layout",
- "render_with_explicit_template",
- "render_with_explicit_string_template",
- "update_page", "update_page_with_instance_variables"
-
- "layouts/standard"
- when "action_talk_to_layout", "layout_overriding_layout"
- "layouts/talk_from_action"
- when "render_implicit_html_template_from_xhr_request"
- (request.xhr? ? 'layouts/xhr' : 'layouts/standard')
- end
- end
-end
+ def render_alternate_default
+ # For this test, the method "default_render" is overridden:
+ @alternate_default_render = lambda do
+ render :update do |page|
+ page.replace :foo, :partial => 'partial'
+ end
+ end
+ end
+
+ private
+ def default_render
+ if @alternate_default_render
+ @alternate_default_render.call
+ else
+ super
+ end
+ end
+
+ def determine_layout
+ case action_name
+ when "hello_world", "layout_test", "rendering_without_layout",
+ "rendering_nothing_on_layout", "render_text_hello_world",
+ "render_text_hello_world_with_layout",
+ "hello_world_with_layout_false",
+ "partial_only", "partial_only_with_layout",
+ "accessing_params_in_template",
+ "accessing_params_in_template_with_layout",
+ "render_with_explicit_template",
+ "render_with_explicit_string_template",
+ "update_page", "update_page_with_instance_variables"
+
+ "layouts/standard"
+ when "action_talk_to_layout", "layout_overriding_layout"
+ "layouts/talk_from_action"
+ when "render_implicit_html_template_from_xhr_request"
+ (request.xhr? ? 'layouts/xhr' : 'layouts/standard')
+ end
+ end
+ end
-class RenderTest < ActionController::TestCase
tests TestController
def setup
@@ -144,8 +149,8 @@ def setup
@controller.logger = Logger.new(nil)
@request.host = "www.nextangle.com"
- end
-
+ end
+
def test_enum_rjs_test
ActiveSupport::SecureRandom.stubs(:base64).returns("asdf")
get :enum_rjs_test
@@ -153,13 +158,13 @@ def test_enum_rjs_test
$$(".product").each(function(value, index) {
new Effect.Highlight(element,{});
new Effect.Highlight(value,{});
- Sortable.create(value, {onUpdate:function(){new Ajax.Request('/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
+ Sortable.create(value, {onUpdate:function(){new Ajax.Request('/render_other_test/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
new Draggable(value, {});
});
}.gsub(/^ /, '').strip
assert_equal body, @response.body
end
-
+
def test_explicitly_rendering_an_html_template_with_implicit_html_template_renders_should_be_possible_from_an_rjs_template
[:js, "js"].each do |format|
assert_nothing_raised do
@@ -167,14 +172,14 @@ def test_explicitly_rendering_an_html_template_with_implicit_html_template_rende
assert_equal %(document.write("Hello world\\n");), @response.body
end
end
- end
-
+ end
+
def test_render_custom_code_rjs
get :render_custom_code_rjs
assert_response 404
assert_equal %(Element.replace("foo", "partial html");), @response.body
end
-
+
def test_render_in_an_rjs_template_should_pick_html_templates_when_available
[:js, "js"].each do |format|
assert_nothing_raised do
@@ -183,7 +188,7 @@ def test_render_in_an_rjs_template_should_pick_html_templates_when_available
end
end
end
-
+
def test_render_rjs_template_explicitly
get :render_js_with_explicit_template
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
@@ -193,12 +198,12 @@ def test_rendering_rjs_action_explicitly
get :render_js_with_explicit_action_template
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
-
+
def test_render_rjs_with_default
get :delete_with_js
assert_equal %!Element.remove("person");\nnew Effect.Highlight(\"project-4\",{});!, @response.body
end
-
+
def test_update_page
get :update_page
assert_template nil
@@ -219,8 +224,8 @@ def test_update_page_with_view_method
assert_template nil
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
assert_match /2 people/, @response.body
- end
-
+ end
+
def test_should_render_html_formatted_partial_with_rjs
xhr :get, :partial_as_rjs
assert_equal %(Element.replace("foo", "partial html");), @response.body
@@ -230,9 +235,9 @@ def test_should_render_html_formatted_partial_with_rjs_and_js_format
xhr :get, :respond_to_partial_as_rjs
assert_equal %(Element.replace("foo", "partial html");), @response.body
end
-
+
def test_should_render_with_alternate_default_render
xhr :get, :render_alternate_default
assert_equal %(Element.replace("foo", "partial html");), @response.body
- end
-end
\ No newline at end of file
+ end
+end
diff --git a/actionpack/test/controller/render_xml_test.rb b/actionpack/test/controller/render_xml_test.rb
index e96e8a4d576afeabee61f8922ed009b75376622f..68a52c3e8cd9b9e5c3418190bb2886acbba9620a 100644
--- a/actionpack/test/controller/render_xml_test.rb
+++ b/actionpack/test/controller/render_xml_test.rb
@@ -2,37 +2,41 @@
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 @@ def setup
@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 @@ def test_rendering_xml_should_call_to_xml_if_possible
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 @@ def test_rendering_with_object_location_should_set_header_with_url_for
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