Rails 2.1

Update to Rails 2.1 final.
This commit is contained in:
Jacques Distler 2008-06-02 01:35:38 -05:00
parent fd554cce90
commit 516d6dfac0
257 changed files with 4058 additions and 1933 deletions

View file

@ -511,16 +511,26 @@ XML
FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'
if RUBY_VERSION < '1.9'
READ_BINARY = 'rb'
READ_PLAIN = 'r'
else
READ_BINARY = 'rb:binary'
READ_PLAIN = 'r:binary'
end
def test_test_uploaded_file
filename = 'mona_lisa.jpg'
path = "#{FILES_DIR}/#{filename}"
content_type = 'image/png'
expected = File.read(path)
expected.force_encoding(Encoding::BINARY) if expected.respond_to?(:force_encoding)
file = ActionController::TestUploadedFile.new(path, content_type)
assert_equal filename, file.original_filename
assert_equal content_type, file.content_type
assert_equal file.path, file.local_path
assert_equal File.read(path), file.read
assert_equal expected, file.read
end
def test_test_uploaded_file_with_binary
@ -529,10 +539,10 @@ XML
content_type = 'image/png'
binary_uploaded_file = ActionController::TestUploadedFile.new(path, content_type, :binary)
assert_equal File.open(path, 'rb').read, binary_uploaded_file.read
assert_equal File.open(path, READ_BINARY).read, binary_uploaded_file.read
plain_uploaded_file = ActionController::TestUploadedFile.new(path, content_type)
assert_equal File.open(path, 'r').read, plain_uploaded_file.read
assert_equal File.open(path, READ_PLAIN).read, plain_uploaded_file.read
end
def test_fixture_file_upload_with_binary
@ -541,10 +551,10 @@ XML
content_type = 'image/jpg'
binary_file_upload = fixture_file_upload(path, content_type, :binary)
assert_equal File.open(path, 'rb').read, binary_file_upload.read
assert_equal File.open(path, READ_BINARY).read, binary_file_upload.read
plain_file_upload = fixture_file_upload(path, content_type)
assert_equal File.open(path, 'r').read, plain_file_upload.read
assert_equal File.open(path, READ_PLAIN).read, plain_file_upload.read
end
def test_fixture_file_upload