aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/integration_upload_test.rb
blob: 0968ae684526288f0dd1cd0cfac03bf436fdcedc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'abstract_unit'
require 'action_controller/integration'
require 'action_controller/routing'

unless defined? ApplicationController
  class ApplicationController < ActionController::Base
  end
end

class UploadTestController < ActionController::Base
  session :off

  def update
    SessionUploadTest.last_request_type = ActionController::Base.param_parsers[request.content_type]
    render :text => "got here"
  end
end

class SessionUploadTest < ActionController::IntegrationTest
  FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'

  class << self
    attr_accessor :last_request_type
  end


  # def setup
  #   @session = ActionController::Integration::Session.new
  # end
  #
  def test_post_with_upload
    uses_mocha "test_post_with_upload" do
      Dependencies.stubs(:load?).returns(false)
      with_routing do |set|
        set.draw do |map|
          map.update 'update', :controller => "upload_test", :action => "update", :method => :post
        end
        path = "/update"
        params = {:uploaded_data => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg")}
        headers = {:location => 'blah' }
        post(path,params,headers)
        assert_equal(:multipart_form, SessionUploadTest.last_request_type)
      end
    end

   end
end