Instiki 0.16.3: Rails 2.3.0
Instiki now runs on the Rails 2.3.0 Candidate Release. Among other improvements, this means that it now automagically selects between WEBrick and Mongrel. Just run ./instiki --daemon
This commit is contained in:
parent
43aadecc99
commit
4e14ccc74d
893 changed files with 71965 additions and 28511 deletions
|
@ -21,6 +21,8 @@ class MockLogger
|
|||
end
|
||||
|
||||
class TestController < ActionController::Base
|
||||
protect_from_forgery
|
||||
|
||||
class LabellingFormBuilder < ActionView::Helpers::FormBuilder
|
||||
end
|
||||
|
||||
|
@ -79,6 +81,10 @@ class TestController < ActionController::Base
|
|||
render :action => "hello_world"
|
||||
end
|
||||
|
||||
def render_action_hello_world_as_string
|
||||
render "hello_world"
|
||||
end
|
||||
|
||||
def render_action_hello_world_with_symbol
|
||||
render :action => :hello_world
|
||||
end
|
||||
|
@ -102,6 +108,12 @@ class TestController < ActionController::Base
|
|||
render :file => path
|
||||
end
|
||||
|
||||
def render_file_as_string_with_instance_variables
|
||||
@secret = 'in the sauce'
|
||||
path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb'))
|
||||
render path
|
||||
end
|
||||
|
||||
def render_file_not_using_full_path
|
||||
@secret = 'in the sauce'
|
||||
render :file => 'test/render_file_with_ivar'
|
||||
|
@ -122,6 +134,11 @@ class TestController < ActionController::Base
|
|||
render :file => path, :locals => {:secret => 'in the sauce'}
|
||||
end
|
||||
|
||||
def render_file_as_string_with_locals
|
||||
path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb'))
|
||||
render path, :locals => {:secret => 'in the sauce'}
|
||||
end
|
||||
|
||||
def accessing_request_in_template
|
||||
render :inline => "Hello: <%= request.host %>"
|
||||
end
|
||||
|
@ -180,10 +197,6 @@ class TestController < ActionController::Base
|
|||
render :text => "appended"
|
||||
end
|
||||
|
||||
def render_invalid_args
|
||||
render("test/hello")
|
||||
end
|
||||
|
||||
def render_vanilla_js_hello
|
||||
render :js => "alert('hello')"
|
||||
end
|
||||
|
@ -193,6 +206,11 @@ class TestController < ActionController::Base
|
|||
render :template => "test/hello"
|
||||
end
|
||||
|
||||
def render_xml_hello_as_string_template
|
||||
@name = "David"
|
||||
render "test/hello"
|
||||
end
|
||||
|
||||
def render_xml_with_custom_content_type
|
||||
render :xml => "<blah/>", :content_type => "application/atomsvc+xml"
|
||||
end
|
||||
|
@ -209,6 +227,10 @@ class TestController < ActionController::Base
|
|||
# let's just rely on the template
|
||||
end
|
||||
|
||||
def blank_response
|
||||
render :text => ' '
|
||||
end
|
||||
|
||||
def layout_test
|
||||
render :action => "hello_world"
|
||||
end
|
||||
|
@ -246,13 +268,13 @@ class TestController < ActionController::Base
|
|||
:locals => { :local_name => name }
|
||||
end
|
||||
|
||||
def helper_method_to_render_to_string(*args)
|
||||
render_to_string(*args)
|
||||
def render_implicit_html_template
|
||||
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' %>"
|
||||
def render_explicit_html_template
|
||||
end
|
||||
|
||||
def render_implicit_html_template_from_xhr_request
|
||||
end
|
||||
|
||||
def formatted_html_erb
|
||||
|
@ -281,6 +303,14 @@ class TestController < ActionController::Base
|
|||
render :action => "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
def layout_test_with_different_layout_and_string_action
|
||||
render "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
def layout_test_with_different_layout_and_symbol_action
|
||||
render :hello_world, :layout => "standard"
|
||||
end
|
||||
|
||||
def rendering_without_layout
|
||||
render :action => "hello_world", :layout => false
|
||||
end
|
||||
|
@ -322,6 +352,10 @@ class TestController < ActionController::Base
|
|||
render :template => "test/hello_world"
|
||||
end
|
||||
|
||||
def render_with_explicit_string_template
|
||||
render "test/hello_world"
|
||||
end
|
||||
|
||||
def render_with_explicit_template_with_locals
|
||||
render :template => "test/render_file_with_locals", :locals => { :secret => 'area51' }
|
||||
end
|
||||
|
@ -644,6 +678,7 @@ class TestController < ActionController::Base
|
|||
"accessing_params_in_template",
|
||||
"accessing_params_in_template_with_layout",
|
||||
"render_with_explicit_template",
|
||||
"render_with_explicit_string_template",
|
||||
"render_js_with_explicit_template",
|
||||
"render_js_with_explicit_action_template",
|
||||
"delete_with_js", "update_page", "update_page_with_instance_variables"
|
||||
|
@ -655,12 +690,10 @@ class TestController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
class RenderTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@controller = TestController.new
|
||||
class RenderTest < ActionController::TestCase
|
||||
tests TestController
|
||||
|
||||
def setup
|
||||
# enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
|
||||
# a more accurate simulation of what happens in "real life".
|
||||
@controller.logger = Logger.new(nil)
|
||||
|
@ -725,6 +758,12 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_template "test/hello_world"
|
||||
end
|
||||
|
||||
def test_render_action_hello_world_as_string
|
||||
get :render_action_hello_world_as_string
|
||||
assert_equal "Hello world!", @response.body
|
||||
assert_template "test/hello_world"
|
||||
end
|
||||
|
||||
def test_render_action_with_symbol
|
||||
get :render_action_hello_world_with_symbol
|
||||
assert_template "test/hello_world"
|
||||
|
@ -750,6 +789,11 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
end
|
||||
|
||||
def test_render_file_as_string_with_instance_variables
|
||||
get :render_file_as_string_with_instance_variables
|
||||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
end
|
||||
|
||||
def test_render_file_not_using_full_path
|
||||
get :render_file_not_using_full_path
|
||||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
|
@ -765,6 +809,11 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
end
|
||||
|
||||
def test_render_file_as_string_with_locals
|
||||
get :render_file_as_string_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
|
||||
|
@ -830,10 +879,6 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_equal 'appended', @response.body
|
||||
end
|
||||
|
||||
def test_attempt_to_render_with_invalid_arguments
|
||||
assert_raises(ActionController::RenderError) { get :render_invalid_args }
|
||||
end
|
||||
|
||||
def test_attempt_to_access_object_method
|
||||
assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
|
||||
end
|
||||
|
@ -869,10 +914,13 @@ class RenderTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_render_xml
|
||||
assert_deprecated do
|
||||
get :render_xml_hello
|
||||
end
|
||||
get :render_xml_hello
|
||||
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
|
||||
|
||||
def test_render_xml_as_string_template
|
||||
get :render_xml_hello_as_string_template
|
||||
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
|
||||
|
@ -888,12 +936,13 @@ class RenderTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_enum_rjs_test
|
||||
ActiveSupport::SecureRandom.stubs(:base64).returns("asdf")
|
||||
get :enum_rjs_test
|
||||
body = %{
|
||||
$$(".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)})}});
|
||||
Sortable.create(value, {onUpdate:function(){new Ajax.Request('/test/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize(value) + '&authenticity_token=' + encodeURIComponent('asdf')})}});
|
||||
new Draggable(value, {});
|
||||
});
|
||||
}.gsub(/^ /, '').strip
|
||||
|
@ -906,10 +955,7 @@ class RenderTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_render_xml_with_layouts
|
||||
assert_deprecated do
|
||||
get :builder_layout_test
|
||||
end
|
||||
|
||||
get :builder_layout_test
|
||||
assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body
|
||||
end
|
||||
|
||||
|
@ -949,9 +995,27 @@ 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
|
||||
def test_render_in_an_rjs_template_should_pick_html_templates_when_available
|
||||
[:js, "js"].each do |format|
|
||||
assert_nothing_raised do
|
||||
get :render_implicit_html_template, :format => format
|
||||
assert_equal %(document.write("Hello world\\n");), @response.body
|
||||
end
|
||||
end
|
||||
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
|
||||
get :render_explicit_html_template, :format => format
|
||||
assert_equal %(document.write("Hello world\\n");), @response.body
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def test_should_implicitly_render_html_template_from_xhr_request
|
||||
get :render_implicit_html_template_from_xhr_request, :format => :js
|
||||
assert_equal "Hello HTML!", @response.body
|
||||
end
|
||||
|
||||
def test_should_render_formatted_template
|
||||
|
@ -1005,6 +1069,16 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_equal "<html>Hello world!</html>", @response.body
|
||||
end
|
||||
|
||||
def test_layout_test_with_different_layout_and_string_action
|
||||
get :layout_test_with_different_layout_and_string_action
|
||||
assert_equal "<html>Hello world!</html>", @response.body
|
||||
end
|
||||
|
||||
def test_layout_test_with_different_layout_and_symbol_action
|
||||
get :layout_test_with_different_layout_and_symbol_action
|
||||
assert_equal "<html>Hello world!</html>", @response.body
|
||||
end
|
||||
|
||||
def test_rendering_without_layout
|
||||
get :rendering_without_layout
|
||||
assert_equal "Hello world!", @response.body
|
||||
|
@ -1051,6 +1125,11 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_response :success
|
||||
end
|
||||
|
||||
def test_render_with_explicit_string_template
|
||||
get :render_with_explicit_string_template
|
||||
assert_equal "<html>Hello world!</html>", @response.body
|
||||
end
|
||||
|
||||
def test_double_render
|
||||
assert_raises(ActionController::DoubleRenderError) { get :double_render }
|
||||
end
|
||||
|
@ -1092,14 +1171,14 @@ class RenderTest < Test::Unit::TestCase
|
|||
def test_update_page
|
||||
get :update_page
|
||||
assert_template nil
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers['Content-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
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
|
||||
assert_match /balance/, @response.body
|
||||
assert_match /\$37/, @response.body
|
||||
end
|
||||
|
@ -1107,7 +1186,7 @@ class RenderTest < Test::Unit::TestCase
|
|||
def test_update_page_with_view_method
|
||||
get :update_page_with_view_method
|
||||
assert_template nil
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
|
||||
assert_match /2 people/, @response.body
|
||||
end
|
||||
|
||||
|
@ -1140,13 +1219,18 @@ class RenderTest < Test::Unit::TestCase
|
|||
|
||||
def test_head_with_symbolic_status
|
||||
get :head_with_symbolic_status, :status => "ok"
|
||||
assert_equal "200 OK", @response.headers["Status"]
|
||||
assert_equal "200 OK", @response.status
|
||||
assert_response :ok
|
||||
|
||||
get :head_with_symbolic_status, :status => "not_found"
|
||||
assert_equal "404 Not Found", @response.headers["Status"]
|
||||
assert_equal "404 Not Found", @response.status
|
||||
assert_response :not_found
|
||||
|
||||
get :head_with_symbolic_status, :status => "no_content"
|
||||
assert_equal "204 No Content", @response.status
|
||||
assert !@response.headers.include?('Content-Length')
|
||||
assert_response :no_content
|
||||
|
||||
ActionController::StatusCodes::SYMBOL_TO_STATUS_CODE.each do |status, code|
|
||||
get :head_with_symbolic_status, :status => status.to_s
|
||||
assert_equal code, @response.response_code
|
||||
|
@ -1307,21 +1391,28 @@ class RenderTest < Test::Unit::TestCase
|
|||
def test_partial_collection_with_spacer
|
||||
get :partial_collection_with_spacer
|
||||
assert_equal "Hello: davidonly partialHello: mary", @response.body
|
||||
assert_template :partial => 'test/_partial_only'
|
||||
assert_template :partial => '_customer'
|
||||
end
|
||||
|
||||
def test_partial_collection_shorthand_with_locals
|
||||
get :partial_collection_shorthand_with_locals
|
||||
assert_equal "Bonjour: davidBonjour: mary", @response.body
|
||||
assert_template :partial => 'customers/_customer', :count => 2
|
||||
assert_template :partial => '_completely_fake_and_made_up_template_that_cannot_possibly_be_rendered', :count => 0
|
||||
end
|
||||
|
||||
def test_partial_collection_shorthand_with_different_types_of_records
|
||||
get :partial_collection_shorthand_with_different_types_of_records
|
||||
assert_equal "Bonjour bad customer: mark0Bonjour good customer: craig1Bonjour bad customer: john2Bonjour good customer: zach3Bonjour good customer: brandon4Bonjour bad customer: dan5", @response.body
|
||||
assert_template :partial => 'good_customers/_good_customer', :count => 3
|
||||
assert_template :partial => 'bad_customers/_bad_customer', :count => 3
|
||||
end
|
||||
|
||||
def test_empty_partial_collection
|
||||
get :empty_partial_collection
|
||||
assert_equal " ", @response.body
|
||||
assert_template :partial => false
|
||||
end
|
||||
|
||||
def test_partial_with_hash_object
|
||||
|
@ -1363,16 +1454,19 @@ class RenderTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class EtagRenderTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@controller = TestController.new
|
||||
class EtagRenderTest < ActionController::TestCase
|
||||
tests TestController
|
||||
|
||||
def setup
|
||||
@request.host = "www.nextangle.com"
|
||||
@expected_bang_etag = etag_for(expand_key([:foo, 123]))
|
||||
end
|
||||
|
||||
def test_render_blank_body_shouldnt_set_etag
|
||||
get :blank_response
|
||||
assert !@response.etag?
|
||||
end
|
||||
|
||||
def test_render_200_should_set_etag
|
||||
get :render_hello_world_from_variable
|
||||
assert_equal etag_for("hello david"), @response.headers['ETag']
|
||||
|
@ -1389,7 +1483,7 @@ class EtagRenderTest < Test::Unit::TestCase
|
|||
def test_render_against_etag_request_should_have_no_content_length_when_match
|
||||
@request.if_none_match = etag_for("hello david")
|
||||
get :render_hello_world_from_variable
|
||||
assert !@response.headers.has_key?("Content-Length")
|
||||
assert !@response.headers.has_key?("Content-Length"), @response.headers['Content-Length']
|
||||
end
|
||||
|
||||
def test_render_against_etag_request_should_200_when_no_match
|
||||
|
@ -1433,10 +1527,7 @@ class EtagRenderTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_etag_should_govern_renders_with_layouts_too
|
||||
assert_deprecated do
|
||||
get :builder_layout_test
|
||||
end
|
||||
|
||||
get :builder_layout_test
|
||||
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
|
||||
|
@ -1463,12 +1554,10 @@ class EtagRenderTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class LastModifiedRenderTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@controller = TestController.new
|
||||
class LastModifiedRenderTest < ActionController::TestCase
|
||||
tests TestController
|
||||
|
||||
def setup
|
||||
@request.host = "www.nextangle.com"
|
||||
@last_modified = Time.now.utc.beginning_of_day.httpdate
|
||||
end
|
||||
|
@ -1520,12 +1609,10 @@ class LastModifiedRenderTest < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class RenderingLoggingTest < Test::Unit::TestCase
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
@controller = TestController.new
|
||||
class RenderingLoggingTest < ActionController::TestCase
|
||||
tests TestController
|
||||
|
||||
def setup
|
||||
@request.host = "www.nextangle.com"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue