lib/action_controller/test_process.rb in actionpack-0.9.5 vs lib/action_controller/test_process.rb in actionpack-1.0.0
- old
+ new
@@ -175,21 +175,40 @@
def []=(key, value)
@attributes[key] = value
end
+ def session_id
+ ""
+ end
+
def update() end
def close() end
def delete() @attributes = {} end
end
end
-class Test::Unit::TestCase #:nodoc:
- private
- # execute the request and set/volley the response
- def process(action, parameters = nil, session = nil)
- @request.action = action.to_s
- @request.parameters.update(parameters) unless parameters.nil?
- @request.session = ActionController::TestSession.new(session) unless session.nil?
- @controller.process(@request, @response)
+module Test
+ module Unit
+ class TestCase #:nodoc:
+ private
+ # execute the request and set/volley the response
+ def process(action, parameters = nil, session = nil)
+ @request.env['REQUEST_METHOD'] ||= "GET"
+ @request.action = action.to_s
+ @request.parameters.update(parameters) unless parameters.nil?
+ @request.session = ActionController::TestSession.new(session) unless session.nil?
+ @controller.process(@request, @response)
+ end
+
+ # execute the request simulating a specific http method and set/volley the response
+ %w( get post put delete head ).each do |method|
+ class_eval <<-EOV
+ def #{method}(action, parameters = nil, session = nil)
+ @request.env['REQUEST_METHOD'] = "#{method.upcase}"
+ process(action, parameters, session)
+ end
+ EOV
+ end
end
+ end
end
\ No newline at end of file