TeX and CSS tweaks.

Sync with latest Instiki Trunk
(Updates Rails to 1.2.2)
This commit is contained in:
Jacques Distler 2007-02-09 02:04:31 -06:00
parent 0ac586ee25
commit c358389f25
443 changed files with 24218 additions and 9823 deletions

View file

@ -34,15 +34,36 @@ class TestController < ActionController::Base
def render_action_hello_world_with_symbol
render_action :hello_world
end
def render_text_hello_world
render_text "hello world"
end
def render_json_hello_world
render_json({:hello => 'world'}.to_json)
end
def render_json_hello_world_with_callback
render_json({:hello => 'world'}.to_json, 'alert')
end
def render_symbol_json
render :json => {:hello => 'world'}.to_json
end
def render_custom_code
render_text "hello world", "404 Moved"
end
def render_text_appendix
render_text "hello world"
render_text ", goodbye!", "404 Not Found", true
end
def render_nothing_with_appendix
render_text "appended", nil, true
end
def render_xml_hello
@name = "David"
render "test/hello"
@ -55,11 +76,15 @@ class TestController < ActionController::Base
def layout_test
render_action "hello_world"
end
def builder_layout_test
render_action "hello"
end
def builder_partial_test
render_action "hello_world_container"
end
def partials_list
@test_unchanged = 'hello'
@customers = [ Customer.new("david"), Customer.new("mary") ]
@ -74,7 +99,7 @@ class TestController < ActionController::Base
@customers = [ Customer.new("david"), Customer.new("mary") ]
render_text "How's there? #{render_to_string("test/list")}"
end
def accessing_params_in_template
render_template "Hello: <%= params[:name] %>"
end
@ -84,7 +109,7 @@ class TestController < ActionController::Base
render :inline => "<%= 'Goodbye, ' + local_name %>",
:locals => { :local_name => name }
end
def accessing_local_assigns_in_inline_template_with_string_keys
name = params[:local_name]
ActionView::Base.local_assigns_support_string_keys = true
@ -98,12 +123,13 @@ class TestController < ActionController::Base
end
def rescue_action(e) raise end
private
def determine_layout
case action_name
case action_name
when "layout_test": "layouts/standard"
when "builder_layout_test": "layouts/builder"
when "render_symbol_json": "layouts/standard" # to make sure layouts don't interfere
end
end
end
@ -127,7 +153,7 @@ class RenderTest < Test::Unit::TestCase
end
def test_do_with_render
get :render_hello_world
assert_deprecated_render { get :render_hello_world }
assert_template "test/hello_world"
end
@ -151,11 +177,41 @@ class RenderTest < Test::Unit::TestCase
assert_equal "hello world", @response.body
end
def test_do_with_render_json
get :render_json_hello_world
assert_equal '{hello: "world"}', @response.body
assert_equal 'application/json', @response.content_type
end
def test_do_with_render_json_with_callback
get :render_json_hello_world_with_callback
assert_equal 'alert({hello: "world"})', @response.body
assert_equal 'application/json', @response.content_type
end
def test_do_with_render_symbol_json
get :render_symbol_json
assert_equal '{hello: "world"}', @response.body
assert_equal 'application/json', @response.content_type
end
def test_do_with_render_custom_code
get :render_custom_code
assert_response 404
end
def test_do_with_render_text_appendix
get :render_text_appendix
assert_response 404
assert_equal 'hello world, goodbye!', @response.body
end
def test_do_with_render_nothing_with_appendix
get :render_nothing_with_appendix
assert_response 200
assert_equal 'appended', @response.body
end
def test_attempt_to_access_object_method
assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
end
@ -164,27 +220,8 @@ class RenderTest < Test::Unit::TestCase
assert_raises(ActionController::UnknownAction, "No action responded to [determine_layout]") { get :determine_layout }
end
def test_access_to_request_in_view
view_internals_old_value = ActionController::Base.view_controller_internals
ActionController::Base.view_controller_internals = false
ActionController::Base.protected_variables_cache = nil
get :hello_world
assert_nil assigns["request"]
ActionController::Base.view_controller_internals = true
ActionController::Base.protected_variables_cache = nil
get :hello_world
assert_kind_of ActionController::AbstractRequest, assigns["request"]
ActionController::Base.view_controller_internals = view_internals_old_value
ActionController::Base.protected_variables_cache = nil
end
def test_render_xml
get :render_xml_hello
assert_deprecated_render { get :render_xml_hello }
assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
end
@ -193,6 +230,11 @@ class RenderTest < Test::Unit::TestCase
assert_equal "<p>This is grand!</p>\n", @response.body
end
def test_render_xml_with_partial
get :builder_partial_test
assert_equal "<test>\n <hello/>\n</test>\n", @response.body
end
def test_layout_rendering
get :layout_test
assert_equal "<html>Hello world!</html>", @response.body
@ -238,9 +280,14 @@ class RenderTest < Test::Unit::TestCase
get :accessing_local_assigns_in_inline_template, :local_name => "Local David"
assert_equal "Goodbye, Local David", @response.body
end
def test_accessing_local_assigns_in_inline_template_with_string_keys
get :accessing_local_assigns_in_inline_template_with_string_keys, :local_name => "Local David"
assert_equal "Goodbye, Local David", @response.body
end
protected
def assert_deprecated_render(&block)
assert_deprecated(/render/, &block)
end
end