<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/fake_application/app/views/tst_another/do_upload.html.erb</filename>
    </added>
    <added>
      <filename>test/fake_application/app/views/tst_another/upload_multiple.html.erb</filename>
    </added>
    <added>
      <filename>test/unit/controller/images/homer_brain2.jpg</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,4 @@
-* [#68] Removed const redefined warnings if mack-l10n is used along with mack-activerecord
+* [#15] File upload testing support (ability to do multipart form post in testing)
 * [#88] Implemented pending SQLite3 tests in mack-activerecord
 * [#68] Transactional support in mack-AR
 * [#87] Refactored out common ORM code from mack-active_record and mack-data_mapper into mack-orm
@@ -16,6 +16,7 @@
 * [#74] Added optional feature to disable initialization logging.
 * [#73] Tests no longer use the functional/unit directories
 * [#69] Added ViewHelperGenerator and ControllerHelperGenerator
+* [#68] Removed const redefined warnings if mack-l10n is used along with mack-activerecord
 * [#67] Added test:setup tasks for active_record and data_mapper
 * [#39] HAML 2.0.2 support
 * [#28] Refactored out encryption into the mack-encryption gem.</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -7,12 +7,20 @@ module Mack
       attr_reader :file_name
       attr_reader :content
       attr_reader :size
+      attr_reader :mime
       
       def initialize(path)
         @path = path
         @file_name = File.basename(path)
+        extension = File.extname(path)
+        extension = extension.gsub!(&quot;.&quot;, &quot;&quot;)
+        if extension and !extension.empty?
+          @mime     = Mack::Utils::MimeTypes.instance.get(extension) if extension
+        else
+          @mime     = &quot;application/octet-stream&quot;
+        end
         raw_content = File.read(path)
-        @content = Base64.encode64(raw_content)
+        @content = Base64.encode64(raw_content).strip
         @size    = @content.size
       end
     end</diff>
      <filename>lib/mack/testing/file.rb</filename>
    </modified>
    <modified>
      <diff>@@ -86,33 +86,12 @@ module Mack
       def build_file(path)
         return Mack::Testing::FileWrapper.new(path)
       end
-    
+          
       # Performs a 'post' request for the specified uri.
       def post(uri, options = {})
         if options[:multipart]
-          form_input = &quot;&quot;
-          boundary = &quot;--Mack-boundary\r\n&quot;
-          options.each_pair do |k, v|
-            if v.kind_of?(Mack::Testing::FileWrapper)
-              form_input += boundary
-              form_input += &quot;content-disposition: form-data; name=\&quot;#{k}\&quot;; filename=\&quot;#{v.file_name}\&quot;\r\n&quot;
-              form_input += &quot;Content-Type: application/octet-stream\r\n\r\n&quot;
-              form_input += &quot;#{v.content}\r\n&quot;
-            elsif k != :multipart 
-              form_input += boundary
-              form_input += &quot;content-disposition: form-data; name=\&quot;#{k}\&quot;\r\n&quot;
-              form_input += &quot;Content-Type: text/plain\r\n\r\n&quot;
-              form_input += &quot;#{v}\r\n&quot;
-            end
-          end
-          
-          form_input += boundary + &quot;\r\n&quot;
-          # request.env_for(&quot;/&quot;,
-          #                 &quot;CONTENT_TYPE&quot; =&gt; &quot;multipart/form-data, boundary=AaB03x&quot;,
-          #                 &quot;CONTENT_LENGTH&quot; =&gt; form_input.size)
-          # build_response(request.post(uri, build_request_options({:input =&gt; form_input})))
+          form_input = build_multipart_data(options)
           build_response(request.post(uri, build_request_options({&quot;CONTENT_TYPE&quot; =&gt; &quot;multipart/form-data, boundary=Mack-boundary&quot;, &quot;CONTENT_LENGTH&quot; =&gt; form_input.size, :input =&gt; form_input})))
-          # build_response(request.post(uri, build_request_options({:content_type =&gt; &quot;multipart/form-data, boundary=Mack-boundary&quot;, :content_length =&gt; form_input.size, :input =&gt; form_input})))
         else
           build_response(request.post(uri, build_request_options({:input =&gt; options.to_params})))
         end
@@ -182,6 +161,28 @@ module Mack
       end
     
       private
+      
+      def build_multipart_data(options)
+        form_input = &quot;&quot;
+        boundary = &quot;--Mack-boundary\r\n&quot;
+        options.each_pair do |k, v|
+          if v.kind_of?(Mack::Testing::FileWrapper)
+            form_input += boundary
+            form_input += &quot;content-disposition: form-data; name=\&quot;#{k}\&quot;; filename=\&quot;#{v.file_name}\&quot;\r\n&quot;
+            form_input += &quot;Content-Type: #{v.mime}\r\n\r\n&quot;
+            form_input += &quot;#{v.content}\r\n&quot;
+          elsif k != :multipart 
+            form_input += boundary
+            form_input += &quot;content-disposition: form-data; name=\&quot;#{k}\&quot;\r\n&quot;
+            form_input += &quot;Content-Type: text/plain\r\n\r\n&quot;
+            form_input += &quot;#{v}\r\n&quot;
+          end
+        end
+        form_input += boundary
+        return form_input
+      end
+      
+      
       def test_cookies
         @test_cookies = {} if @test_cookies.nil?
         @test_cookies</diff>
      <filename>lib/mack/testing/helpers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -49,10 +49,16 @@ class TstAnotherController
   end
   
   def do_upload
-    debugger
     file = request.file(&quot;file0&quot;)
     @saved_file_name = file.file_name
-    redirect_to(upload_successful_url)
+    @album = params[:album]
+  end
+  
+  def upload_multiple
+    file = request.file(&quot;file0&quot;)
+    @saved_file1 = file.file_name.dup
+    file = request.file(&quot;file1&quot;)
+    @saved_file2 = file.file_name.dup
   end
   
   def regardless_of_string_or_symbol</diff>
      <filename>test/fake_application/app/controllers/tst_another_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -25,7 +25,7 @@ Mack::Routes.build do |r|
     map.kill_kenny_no_meth &quot;/tst_another/kill_kenny&quot;, :action =&gt; :kill_kenny
     map.kill_kenny_bad &quot;/tst_another/kill_kenny_bad&quot;, :action =&gt; :kill_kenny_bad
     map.upload_file &quot;/tst_another/do_upload&quot;, :action =&gt; :do_upload
-    map.upload_successful &quot;/tst_another/upload_successful&quot;
+    map.upload_multiple &quot;/tst_another/upload_multiple&quot;, :action =&gt; :upload_multiple
   end
   
   r.with_options(:controller =&gt; &quot;vtt/view_template&quot;) do |map|</diff>
      <filename>test/fake_application/config/routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,8 +2,19 @@ require 'pathname'
 require Pathname(__FILE__).dirname.expand_path.parent.parent + 'spec_helper'
 
 describe &quot;File Upload Request&quot; do
-  it &quot;should handle multipart content properly&quot; do
-    post upload_file_url, :multipart =&gt; true, :file0 =&gt; build_file(File.join(File.dirname(__FILE__), &quot;images&quot;, &quot;homer_brain.jpg&quot;))
-    pp response
+  it &quot;should generate proper multipart content&quot; do
+    post upload_file_url, :multipart =&gt; true, :file0 =&gt; build_file(File.join(File.dirname(__FILE__), &quot;images&quot;, &quot;homer_brain.jpg&quot;)), :album =&gt; 'simpsons'
+    assigns(:saved_file_name).should_not be_nil
+    assigns(:saved_file_name).should == &quot;homer_brain.jpg&quot;
+    assigns(:album).should_not be_nil
+    assigns(:album).should == &quot;simpsons&quot;
+  end
+  
+  it &quot;should be able to upload multiple files&quot; do  
+    post upload_multiple_url, :multipart =&gt; true, :file0 =&gt; build_file(File.join(File.dirname(__FILE__), &quot;images&quot;, &quot;homer_brain.jpg&quot;)), :file1 =&gt; build_file(File.join(File.dirname(__FILE__), &quot;images&quot;, &quot;homer_brain2.jpg&quot;))
+    assigns(:saved_file1).should_not be_nil
+    assigns(:saved_file2).should_not be_nil
+    assigns(:saved_file1).should == &quot;homer_brain.jpg&quot;
+    assigns(:saved_file2).should == &quot;homer_brain2.jpg&quot;
   end
 end
\ No newline at end of file</diff>
      <filename>test/unit/controller/file_upload_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/fake_application/app/views/tst_another/upload_successful.html.erb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>e8b236b2ef78a838448edc36d4141985620bceb6</id>
    </parent>
  </parents>
  <author>
    <name>dsutedja</name>
    <email>dsutedja@helium.com</email>
  </author>
  <url>http://github.com/markbates/mack/commit/f634e81de2541bfbfbf8232592c5409ad06b4112</url>
  <id>f634e81de2541bfbfbf8232592c5409ad06b4112</id>
  <committed-date>2008-08-15T14:00:00-07:00</committed-date>
  <authored-date>2008-08-15T14:00:00-07:00</authored-date>
  <message>file upload testing [#15 state:resolved]</message>
  <tree>de23838b8f10a555a627dbff0b95135bc09653f2</tree>
  <committer>
    <name>dsutedja</name>
    <email>dsutedja@helium.com</email>
  </committer>
</commit>
