aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/new_render_test.rb
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2008-06-25 15:24:12 -0500
committerJoshua Peek <josh@joshpeek.com>2008-06-25 15:24:12 -0500
commit339491a6b37722497ebafe9998e17507f47e8fd6 (patch)
tree96e7dc63607054c6e3ce6f08e41a9e96d8a44ea5 /actionpack/test/controller/new_render_test.rb
parenta9259ccfe05690dc4cb7993d551603c39619c27f (diff)
downloadrails-339491a6b37722497ebafe9998e17507f47e8fd6.tar.gz
rails-339491a6b37722497ebafe9998e17507f47e8fd6.tar.bz2
rails-339491a6b37722497ebafe9998e17507f47e8fd6.zip
Set precompiled fixture load path constant to speed up tests
Diffstat (limited to 'actionpack/test/controller/new_render_test.rb')
-rw-r--r--actionpack/test/controller/new_render_test.rb109
1 files changed, 54 insertions, 55 deletions
diff --git a/actionpack/test/controller/new_render_test.rb b/actionpack/test/controller/new_render_test.rb
index b77b3ceffa..deda47f352 100644
--- a/actionpack/test/controller/new_render_test.rb
+++ b/actionpack/test/controller/new_render_test.rb
@@ -45,11 +45,11 @@ class NewRenderTestController < ActionController::Base
def render_action_hello_world_as_symbol
render :action => :hello_world
end
-
+
def render_text_hello_world
render :text => "hello world"
end
-
+
def render_text_hello_world_with_layout
@variable_for_layout = ", I'm here!"
render :text => "hello world", :layout => true
@@ -68,7 +68,7 @@ class NewRenderTestController < ActionController::Base
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')
render :file => path
end
-
+
def render_file_from_template
@secret = 'in the sauce'
@path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb'))
@@ -76,14 +76,14 @@ class NewRenderTestController < ActionController::Base
def render_file_with_locals
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb')
- render :file => path, :locals => {:secret => 'in the sauce'}
+ render :file => path, :locals => {:secret => 'in the sauce'}
end
def render_file_not_using_full_path
@secret = 'in the sauce'
render :file => 'test/render_file_with_ivar', :use_full_path => true
end
-
+
def render_file_not_using_full_path_with_dot_in_path
@secret = 'in the sauce'
render :file => 'test/dot.directory/render_file_with_ivar', :use_full_path => true
@@ -105,7 +105,7 @@ class NewRenderTestController < ActionController::Base
def layout_test_with_different_layout
render :action => "hello_world", :layout => "standard"
end
-
+
def rendering_without_layout
render :action => "hello_world", :layout => false
end
@@ -113,11 +113,11 @@ class NewRenderTestController < ActionController::Base
def layout_overriding_layout
render :action => "hello_world", :layout => "standard"
end
-
+
def rendering_nothing_on_layout
render :nothing => true
end
-
+
def builder_layout_test
render :action => "hello"
end
@@ -135,9 +135,9 @@ class NewRenderTestController < ActionController::Base
def partial_only_with_layout
render :partial => "partial_only", :layout => true
end
-
+
def partial_with_locals
- render :partial => "customer", :locals => { :customer => Customer.new("david") }
+ render :partial => "customer", :locals => { :customer => Customer.new("david") }
end
def partial_with_form_builder
@@ -151,11 +151,11 @@ class NewRenderTestController < ActionController::Base
def partial_collection
render :partial => "customer", :collection => [ Customer.new("david"), Customer.new("mary") ]
end
-
+
def partial_collection_with_spacer
render :partial => "customer", :spacer_template => "partial_only", :collection => [ Customer.new("david"), Customer.new("mary") ]
end
-
+
def partial_collection_with_counter
render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ]
end
@@ -186,33 +186,33 @@ class NewRenderTestController < ActionController::Base
def empty_partial_collection
render :partial => "customer", :collection => []
end
-
+
def partial_with_hash_object
render :partial => "hash_object", :object => {:first_name => "Sam"}
end
-
+
def partial_hash_collection
render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ]
end
-
+
def partial_hash_collection_with_locals
render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" }
end
-
+
def partial_with_implicit_local_assignment
@customer = Customer.new("Marcel")
render :partial => "customer"
end
-
+
def missing_partial
render :partial => 'thisFileIsntHere'
end
-
+
def hello_in_a_string
@customers = [ Customer.new("david"), Customer.new("mary") ]
render :text => "How's there? " << render_to_string(:template => "test/list")
end
-
+
def render_to_string_with_assigns
@before = "i'm before the render"
render_to_string :text => "foo"
@@ -222,14 +222,14 @@ class NewRenderTestController < ActionController::Base
def render_to_string_with_partial
@partial_only = render_to_string :partial => "partial_only"
- @partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") }
- render :action => "test/hello_world"
- end
-
+ @partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") }
+ render :action => "test/hello_world"
+ end
+
def render_to_string_with_exception
render_to_string :file => "exception that will not be caught - this will certainly not work", :use_full_path => true
end
-
+
def render_to_string_with_caught_exception
@before = "i'm before the render"
begin
@@ -282,7 +282,7 @@ class NewRenderTestController < ActionController::Base
render :text => "hello"
redirect_to :action => "double_render"
end
-
+
def render_to_string_and_render
@stuff = render_to_string :text => "here is some cached stuff"
render :text => "Hi web users! #{@stuff}"
@@ -329,7 +329,7 @@ class NewRenderTestController < ActionController::Base
def render_with_location
render :xml => "<hello/>", :location => "http://example.com", :status => 201
end
-
+
def render_with_object_location
customer = Customer.new("Some guy", 1)
render :xml => "<customer/>", :location => customer_url(customer), :status => :created
@@ -341,12 +341,12 @@ class NewRenderTestController < ActionController::Base
"<i-am-xml/>"
end
end.new
-
+
render :xml => to_xmlable
end
helper NewRenderTestHelper
- helper do
+ helper do
def rjs_helper_method(value)
page.visual_effect :highlight, value
end
@@ -383,7 +383,7 @@ class NewRenderTestController < ActionController::Base
page.visual_effect :highlight, 'balance'
end
end
-
+
def update_page_with_instance_variables
@money = '$37,000,000.00'
@div_id = 'balance'
@@ -426,12 +426,12 @@ class NewRenderTestController < ActionController::Base
def render_using_layout_around_block_in_main_layout_and_within_content_for_layout
render :action => "using_layout_around_block"
end
-
+
def rescue_action(e) raise end
-
+
private
def determine_layout
- case action_name
+ 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",
@@ -443,7 +443,7 @@ class NewRenderTestController < ActionController::Base
"render_js_with_explicit_template",
"render_js_with_explicit_action_template",
"delete_with_js", "update_page", "update_page_with_instance_variables"
-
+
"layouts/standard"
when "builder_layout_test"
"layouts/builder"
@@ -457,8 +457,8 @@ class NewRenderTestController < ActionController::Base
end
end
-NewRenderTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
-Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
+NewRenderTestController.view_paths = [FIXTURE_LOAD_PATH]
+Fun::GamesController.view_paths = [FIXTURE_LOAD_PATH]
class NewRenderTest < Test::Unit::TestCase
def setup
@@ -527,7 +527,7 @@ class NewRenderTest < Test::Unit::TestCase
end
def test_render_file_not_using_full_path
- get :render_file_not_using_full_path
+ get :render_file_not_using_full_path
assert_equal "The secret is in the sauce\n", @response.body
end
@@ -540,7 +540,7 @@ class NewRenderTest < Test::Unit::TestCase
get :render_file_with_locals
assert_equal "The secret is in the sauce\n", @response.body
end
-
+
def test_render_file_from_template
get :render_file_from_template
assert_equal "The secret is in the sauce\n", @response.body
@@ -661,7 +661,7 @@ EOS
assert_not_deprecated { get :hello_in_a_string }
assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body
end
-
+
def test_render_to_string_doesnt_break_assigns
get :render_to_string_with_assigns
assert_equal "i'm before the render", assigns(:before)
@@ -672,12 +672,12 @@ EOS
get :render_to_string_with_partial
assert_equal "only partial", assigns(:partial_only)
assert_equal "Hello: david", assigns(:partial_with_locals)
- end
+ end
def test_bad_render_to_string_still_throws_exception
assert_raises(ActionView::MissingTemplate) { get :render_to_string_with_exception }
end
-
+
def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns
assert_nothing_raised { get :render_to_string_with_caught_exception }
assert_equal "i'm before the render", assigns(:before)
@@ -715,7 +715,7 @@ EOS
def test_render_and_redirect
assert_raises(ActionController::DoubleRenderError) { get :render_and_redirect }
end
-
+
# specify the one exception to double render rule - render_to_string followed by render
def test_render_to_string_and_render
get :render_to_string_and_render
@@ -736,7 +736,7 @@ EOS
get :partials_list
assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body
end
-
+
def test_partial_with_locals
get :partial_with_locals
assert_equal "Hello: david", @response.body
@@ -758,17 +758,17 @@ EOS
get :partial_collection
assert_equal "Hello: davidHello: mary", @response.body
end
-
+
def test_partial_collection_with_counter
get :partial_collection_with_counter
assert_equal "david0mary1", @response.body
end
-
+
def test_partial_collection_with_locals
get :partial_collection_with_locals
assert_equal "Bonjour: davidBonjour: mary", @response.body
end
-
+
def test_partial_collection_with_spacer
get :partial_collection_with_spacer
assert_equal "Hello: davidonly partialHello: mary", @response.body
@@ -793,12 +793,12 @@ EOS
get :partial_with_hash_object
assert_equal "Sam\nmaS\n", @response.body
end
-
+
def test_hash_partial_collection
get :partial_hash_collection
assert_equal "Pratik\nkitarP\nAmy\nymA\n", @response.body
end
-
+
def test_partial_hash_collection_with_locals
get :partial_hash_collection_with_locals
assert_equal "Hola: PratikHola: Amy", @response.body
@@ -808,25 +808,25 @@ EOS
get :partial_with_implicit_local_assignment
assert_equal "Hello: Marcel", @response.body
end
-
+
def test_render_missing_partial_template
assert_raises(ActionView::MissingTemplate) do
get :missing_partial
end
end
-
+
def test_render_text_with_assigns
get :render_text_with_assigns
assert_equal "world", assigns["hello"]
end
-
+
def test_update_page
get :update_page
assert_template nil
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
assert_equal 2, @response.body.split($/).length
end
-
+
def test_update_page_with_instance_variables
get :update_page_with_instance_variables
assert_template nil
@@ -834,7 +834,7 @@ EOS
assert_match /balance/, @response.body
assert_match /\$37/, @response.body
end
-
+
def test_yield_content_for
assert_not_deprecated { get :yield_content_for }
assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body
@@ -906,12 +906,12 @@ EOS
get :render_with_location
assert_equal "http://example.com", @response.headers["Location"]
end
-
+
def test_rendering_xml_should_call_to_xml_if_possible
get :render_with_to_xml
assert_equal "<i-am-xml/>", @response.body
end
-
+
def test_rendering_with_object_location_should_set_header_with_url_for
ActionController::Routing::Routes.draw do |map|
map.resources :customers
@@ -941,5 +941,4 @@ EOS
get :render_using_layout_around_block_in_main_layout_and_within_content_for_layout
assert_equal "Before (Anthony)\nInside from first block in layout\nAfter\nBefore (David)\nInside from block\nAfter\nBefore (Ramm)\nInside from second block in layout\nAfter\n", @response.body
end
-
end