diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-10-06 16:17:02 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-10-06 16:17:02 -0300 |
commit | c3b4da7796f0aab23b11521cf86171a83d84ad3e (patch) | |
tree | 754b08169f3297623ab0754bed6833109483830e /actionpack/test | |
parent | 97aba353c80d3a55f79f9d280035be566c3bc0ef (diff) | |
parent | 126f623711ce421b7b1bbf7e94099403ecaf2d20 (diff) | |
download | rails-c3b4da7796f0aab23b11521cf86171a83d84ad3e.tar.gz rails-c3b4da7796f0aab23b11521cf86171a83d84ad3e.tar.bz2 rails-c3b4da7796f0aab23b11521cf86171a83d84ad3e.zip |
Merge commit 'rails/master'
Diffstat (limited to 'actionpack/test')
-rw-r--r-- | actionpack/test/abstract_unit.rb | 1 | ||||
-rw-r--r-- | actionpack/test/dispatch/string_coercion_test.rb | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb index 1214d608a4..4820f00aa1 100644 --- a/actionpack/test/abstract_unit.rb +++ b/actionpack/test/abstract_unit.rb @@ -93,6 +93,7 @@ end class ActionController::IntegrationTest < ActiveSupport::TestCase def self.build_app(routes = nil) ActionDispatch::MiddlewareStack.new { |middleware| + middleware.use "ActionDispatch::StringCoercion" middleware.use "ActionDispatch::ShowExceptions" middleware.use "ActionDispatch::Callbacks" middleware.use "ActionDispatch::ParamsParser" diff --git a/actionpack/test/dispatch/string_coercion_test.rb b/actionpack/test/dispatch/string_coercion_test.rb new file mode 100644 index 0000000000..d79b17b932 --- /dev/null +++ b/actionpack/test/dispatch/string_coercion_test.rb @@ -0,0 +1,40 @@ +require 'abstract_unit' + +class StringCoercionTest < ActiveSupport::TestCase + test "body responds to each" do + original_body = [] + body = ActionDispatch::StringCoercion::UglyBody.new(original_body) + + assert original_body.respond_to?(:each) + assert body.respond_to?(:each) + end + + test "body responds to to_path" do + original_body = [] + def original_body.to_path; end + body = ActionDispatch::StringCoercion::UglyBody.new(original_body) + + assert original_body.respond_to?(:to_path) + assert body.respond_to?(:to_path) + end + + test "body does not responds to to_path" do + original_body = [] + body = ActionDispatch::StringCoercion::UglyBody.new(original_body) + + assert !original_body.respond_to?(:to_path) + assert !body.respond_to?(:to_path) + end + + test "calls to_s on body parts" do + app = lambda { |env| + [200, {'Content-Type' => 'html'}, [1, 2, 3]] + } + app = ActionDispatch::StringCoercion.new(app) + parts = [] + status, headers, body = app.call({}) + body.each { |part| parts << part } + + assert_equal %w( 1 2 3 ), parts + end +end |