diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-10-05 13:58:43 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-10-05 13:58:43 -0500 |
commit | b480da5cd65de966ac14bbdc52b2fae3ffc06547 (patch) | |
tree | 9b62ce5b6302e289fd2a5ad4cb3fd53d6488bcc8 /actionpack/test/dispatch | |
parent | 570f055c44a0b6da973f63689f8fedbef9fe32d3 (diff) | |
download | rails-b480da5cd65de966ac14bbdc52b2fae3ffc06547.tar.gz rails-b480da5cd65de966ac14bbdc52b2fae3ffc06547.tar.bz2 rails-b480da5cd65de966ac14bbdc52b2fae3ffc06547.zip |
Coerce all out going body parts to Strings
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/string_coercion_test.rb | 40 |
1 files changed, 40 insertions, 0 deletions
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 |