aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2009-08-07 16:10:17 +0200
committerJosé Valim <jose.valim@gmail.com>2009-08-07 16:10:17 +0200
commitdac8927b0576bff89ba3a4fcbf502dffc9b39e89 (patch)
tree58c25132a52ef5cc56f406f8e2df416c5f2776a6 /actionpack/test/controller
parent072c87b532a0bfb334787928248863a2561dc849 (diff)
parent606e950ccbd02a10f724c73543575a2a4e1ed8cb (diff)
downloadrails-dac8927b0576bff89ba3a4fcbf502dffc9b39e89.tar.gz
rails-dac8927b0576bff89ba3a4fcbf502dffc9b39e89.tar.bz2
rails-dac8927b0576bff89ba3a4fcbf502dffc9b39e89.zip
Merge branch 'master' of git://github.com/rails/rails into old
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r--actionpack/test/controller/logging_test.rb3
-rw-r--r--actionpack/test/controller/record_identifier_test.rb57
-rw-r--r--actionpack/test/controller/render_test.rb5
-rw-r--r--actionpack/test/controller/send_file_test.rb17
4 files changed, 20 insertions, 62 deletions
diff --git a/actionpack/test/controller/logging_test.rb b/actionpack/test/controller/logging_test.rb
index a7ed1b8665..98ffbc3813 100644
--- a/actionpack/test/controller/logging_test.rb
+++ b/actionpack/test/controller/logging_test.rb
@@ -17,9 +17,10 @@ class LoggingTest < ActionController::TestCase
@level = Logger::DEBUG
end
- def method_missing(method, *args)
+ def method_missing(method, *args, &blk)
@logged ||= []
@logged << args.first
+ @logged << blk.call if block_given?
end
end
diff --git a/actionpack/test/controller/record_identifier_test.rb b/actionpack/test/controller/record_identifier_test.rb
index 44e49ed3f8..6b6d154faa 100644
--- a/actionpack/test/controller/record_identifier_test.rb
+++ b/actionpack/test/controller/record_identifier_test.rb
@@ -54,24 +54,6 @@ class RecordIdentifierTest < Test::Unit::TestCase
assert_equal "edit_#{@singular}_1", dom_id(@record, :edit)
end
- def test_partial_path
- expected = "#{@plural}/#{@singular}"
- assert_equal expected, partial_path(@record)
- assert_equal expected, partial_path(Comment)
- end
-
- def test_partial_path_with_namespaced_controller_path
- expected = "admin/#{@plural}/#{@singular}"
- assert_equal expected, partial_path(@record, "admin/posts")
- assert_equal expected, partial_path(@klass, "admin/posts")
- end
-
- def test_partial_path_with_not_namespaced_controller_path
- expected = "#{@plural}/#{@singular}"
- assert_equal expected, partial_path(@record, "posts")
- assert_equal expected, partial_path(@klass, "posts")
- end
-
def test_dom_class
assert_equal @singular, dom_class(@record)
end
@@ -101,42 +83,3 @@ class RecordIdentifierTest < Test::Unit::TestCase
RecordIdentifier.send(method, *args)
end
end
-
-class NestedRecordIdentifierTest < RecordIdentifierTest
- def setup
- @klass = Comment::Nested
- @record = @klass.new
- @singular = 'comment_nested'
- @plural = 'comment_nesteds'
- end
-
- def test_partial_path
- expected = "comment/nesteds/nested"
- assert_equal expected, partial_path(@record)
- assert_equal expected, partial_path(Comment::Nested)
- end
-
- def test_partial_path_with_namespaced_controller_path
- expected = "admin/comment/nesteds/nested"
- assert_equal expected, partial_path(@record, "admin/posts")
- assert_equal expected, partial_path(@klass, "admin/posts")
- end
-
- def test_partial_path_with_deeper_namespaced_controller_path
- expected = "deeper/admin/comment/nesteds/nested"
- assert_equal expected, partial_path(@record, "deeper/admin/posts")
- assert_equal expected, partial_path(@klass, "deeper/admin/posts")
- end
-
- def test_partial_path_with_even_deeper_namespaced_controller_path
- expected = "even/more/deeper/admin/comment/nesteds/nested"
- assert_equal expected, partial_path(@record, "even/more/deeper/admin/posts")
- assert_equal expected, partial_path(@klass, "even/more/deeper/admin/posts")
- end
-
- def test_partial_path_with_not_namespaced_controller_path
- expected = "comment/nesteds/nested"
- assert_equal expected, partial_path(@record, "posts")
- assert_equal expected, partial_path(@klass, "posts")
- end
-end
diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb
index acb0c895e0..947ffa9ea6 100644
--- a/actionpack/test/controller/render_test.rb
+++ b/actionpack/test/controller/render_test.rb
@@ -17,8 +17,9 @@ class MockLogger
@logged = []
end
- def method_missing(method, *args)
+ def method_missing(method, *args, &blk)
@logged << args.first
+ @logged << blk.call if block_given?
end
end
@@ -1331,7 +1332,7 @@ class EtagRenderTest < ActionController::TestCase
def test_render_200_should_set_etag
get :render_hello_world_from_variable
assert_equal etag_for("hello david"), @response.headers['ETag']
- assert_equal "private, max-age=0, must-revalidate", @response.headers['Cache-Control']
+ assert_equal "max-age=0, private, must-revalidate", @response.headers['Cache-Control']
end
def test_render_against_etag_request_should_304_when_match
diff --git a/actionpack/test/controller/send_file_test.rb b/actionpack/test/controller/send_file_test.rb
index ae32ee5649..0afebac68c 100644
--- a/actionpack/test/controller/send_file_test.rb
+++ b/actionpack/test/controller/send_file_test.rb
@@ -1,9 +1,10 @@
+# encoding: utf-8
require 'abstract_unit'
module TestFileUtils
def file_name() File.basename(__FILE__) end
def file_path() File.expand_path(__FILE__) end
- def file_data() File.open(file_path, 'rb') { |f| f.read } end
+ def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end
end
class SendFileController < ActionController::Base
@@ -22,6 +23,10 @@ class SendFileController < ActionController::Base
def data
send_data(file_data, options)
end
+
+ def multibyte_text_data
+ send_data("Кирилица\n祝您好運", options)
+ end
end
class SendFileTest < ActionController::TestCase
@@ -55,6 +60,7 @@ class SendFileTest < ActionController::TestCase
require 'stringio'
output = StringIO.new
output.binmode
+ output.string.force_encoding(file_data.encoding) if output.string.respond_to?(:force_encoding)
assert_nothing_raised { response.body_parts.each { |part| output << part.to_s } }
assert_equal file_data, output.string
end
@@ -123,7 +129,7 @@ class SendFileTest < ActionController::TestCase
# test overriding Cache-Control: no-cache header to fix IE open/save dialog
@controller.headers = { 'Cache-Control' => 'no-cache' }
@controller.send(:send_file_headers!, options)
- h = @controller.headers
+ @controller.response.prepare!
assert_equal 'private', h['Cache-Control']
end
@@ -163,4 +169,11 @@ class SendFileTest < ActionController::TestCase
assert_equal 200, @response.status
end
end
+
+ def test_send_data_content_length_header
+ @controller.headers = {}
+ @controller.options = { :type => :text, :filename => 'file_with_utf8_text' }
+ process('multibyte_text_data')
+ assert_equal '29', @controller.headers['Content-Length']
+ end
end