Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/actionpack/test/controller/integration_upload_test.rb

Revision 9189, 1.2 kB (checked in by bitsweat, 8 months ago)

style & whitespace

Line 
1 require 'abstract_unit'
2 require 'action_controller/integration'
3 require 'action_controller/routing'
4
5 unless defined? ApplicationController
6   class ApplicationController < ActionController::Base
7   end
8 end
9
10 class UploadTestController < ActionController::Base
11   session :off
12
13   def update
14     SessionUploadTest.last_request_type = ActionController::Base.param_parsers[request.content_type]
15     render :text => "got here"
16   end
17 end
18
19 class SessionUploadTest < ActionController::IntegrationTest
20   FILES_DIR = File.dirname(__FILE__) + '/../fixtures/multipart'
21
22   class << self
23     attr_accessor :last_request_type
24   end
25
26   # def setup
27   #   @session = ActionController::Integration::Session.new
28   # end
29   def test_post_with_upload
30     uses_mocha "test_post_with_upload" do
31       Dependencies.stubs(:load?).returns(false)
32       with_routing do |set|
33         set.draw do |map|
34           map.update 'update', :controller => "upload_test", :action => "update", :method => :post
35         end
36
37         params = { :uploaded_data => fixture_file_upload(FILES_DIR + "/mona_lisa.jpg", "image/jpg") }
38         post '/update', params, :location => 'blah'
39         assert_equal(:multipart_form, SessionUploadTest.last_request_type)
40       end
41     end
42    end
43 end
Note: See TracBrowser for help on using the browser.