Rails 2.2.2

Updated to Rails 2.2.2.
Added a couple more Ruby 1.9 fixes, but that's pretty much at a standstill,
until one gets Maruku and HTML5lib working right under Ruby 1.9.
This commit is contained in:
Jacques Distler 2008-11-24 15:53:39 -06:00
parent 1b69b148de
commit 2e81ca2d30
716 changed files with 8009 additions and 113047 deletions

View file

@ -39,7 +39,7 @@ class TestController < ActionController::Base
render :action => 'hello_world'
end
before_filter :handle_last_modified_and_etags, :only=>:conditional_hello_with_bangs
def handle_last_modified_and_etags
fresh_when(:last_modified => Time.now.utc.beginning_of_day, :etag => [ :foo, 123 ])
end
@ -154,6 +154,10 @@ class TestController < ActionController::Base
render :json => {:hello => 'world'}.to_json
end
def render_json_with_render_to_string
render :json => {:hello => render_to_string(:partial => 'partial')}
end
def render_custom_code
render :text => "hello world", :status => 404
end
@ -180,6 +184,10 @@ class TestController < ActionController::Base
render("test/hello")
end
def render_vanilla_js_hello
render :js => "alert('hello')"
end
def render_xml_hello
@name = "David"
render :template => "test/hello"
@ -238,6 +246,15 @@ class TestController < ActionController::Base
:locals => { :local_name => name }
end
def helper_method_to_render_to_string(*args)
render_to_string(*args)
end
helper_method :helper_method_to_render_to_string
def render_html_only_partial_within_inline
render :inline => "Hello world <%= helper_method_to_render_to_string :partial => 'test/partial_with_only_html_version' %>"
end
def formatted_html_erb
end
@ -329,6 +346,11 @@ class TestController < ActionController::Base
render :text => "Hi web users! #{@stuff}"
end
def render_to_string_with_inline_and_render
render_to_string :inline => "<%= 'dlrow olleh'.reverse %>"
render :template => "test/hello_world"
end
def rendering_with_conflicting_local_vars
@name = "David"
def @template.name() nil end
@ -772,6 +794,12 @@ class RenderTest < Test::Unit::TestCase
assert_equal 'application/json', @response.content_type
end
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
def test_render_custom_code
get :render_custom_code
assert_response 404
@ -834,8 +862,17 @@ class RenderTest < Test::Unit::TestCase
assert_equal "test", @response.body # name is explicitly set to 'test' inside the controller.
end
def test_render_vanilla_js
get :render_vanilla_js_hello
assert_equal "alert('hello')", @response.body
assert_equal "text/javascript", @response.content_type
end
def test_render_xml
get :render_xml_hello
assert_deprecated do
get :render_xml_hello
end
assert_equal "<html>\n <p>Hello David</p>\n<p>This is grand!</p>\n</html>\n", @response.body
assert_equal "application/xml", @response.content_type
end
@ -869,7 +906,10 @@ class RenderTest < Test::Unit::TestCase
end
def test_render_xml_with_layouts
get :builder_layout_test
assert_deprecated do
get :builder_layout_test
end
assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
end
@ -888,6 +928,11 @@ class RenderTest < Test::Unit::TestCase
assert_equal "The value of foo is: ::this is a test::\n", @response.body
end
def test_render_to_string_inline
get :render_to_string_with_inline_and_render
assert_template "test/hello_world"
end
def test_nested_rendering
@controller = Fun::GamesController.new
get :hello_world
@ -904,6 +949,11 @@ class RenderTest < Test::Unit::TestCase
assert_equal "Goodbye, Local David", @response.body
end
def test_rendering_html_only_partial_within_inline_with_js
get :render_html_only_partial_within_inline, :format => :js
assert_equal "Hello world partial with only html version", @response.body
end
def test_should_render_formatted_template
get :formatted_html_erb
assert_equal 'formatted html erb', @response.body
@ -1348,7 +1398,7 @@ class EtagRenderTest < Test::Unit::TestCase
assert_equal "200 OK", @response.status
assert !@response.body.empty?
end
def test_render_should_not_set_etag_when_last_modified_has_been_specified
get :render_hello_world_with_last_modified_set
assert_equal "200 OK", @response.status
@ -1362,7 +1412,7 @@ class EtagRenderTest < Test::Unit::TestCase
expected_etag = etag_for('hello david')
assert_equal expected_etag, @response.headers['ETag']
@response = ActionController::TestResponse.new
@request.if_none_match = expected_etag
get :render_hello_world_from_variable
assert_equal "304 Not Modified", @response.status
@ -1383,28 +1433,31 @@ class EtagRenderTest < Test::Unit::TestCase
end
def test_etag_should_govern_renders_with_layouts_too
get :builder_layout_test
assert_deprecated do
get :builder_layout_test
end
assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
assert_equal etag_for("<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n"), @response.headers['ETag']
end
def test_etag_with_bang_should_set_etag
get :conditional_hello_with_bangs
assert_equal @expected_bang_etag, @response.headers["ETag"]
assert_response :success
end
def test_etag_with_bang_should_obey_if_none_match
@request.if_none_match = @expected_bang_etag
get :conditional_hello_with_bangs
assert_response :not_modified
end
protected
def etag_for(text)
%("#{Digest::MD5.hexdigest(text)}")
end
def expand_key(args)
ActiveSupport::Cache.expand_cache_key(args)
end
@ -1447,13 +1500,13 @@ class LastModifiedRenderTest < Test::Unit::TestCase
assert !@response.body.blank?
assert_equal @last_modified, @response.headers['Last-Modified']
end
def test_request_with_bang_gets_last_modified
get :conditional_hello_with_bangs
assert_equal @last_modified, @response.headers['Last-Modified']
assert_response :success
end
def test_request_with_bang_obeys_last_modified
@request.if_modified_since = @last_modified
get :conditional_hello_with_bangs