Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thumblemonks/310088 to your computer and use it in GitHub Desktop.
Save thumblemonks/310088 to your computer and use it in GitHub Desktop.
def submit_request(http_method, action, parameters = nil, session = nil, flash = nil)
@request.recycle!
@response.recycle!
@controller.response_body = nil
@controller.formats = nil
@controller.params = nil
@html_document = nil
@request.env['REQUEST_METHOD'] = http_method
parameters ||= {}
@request.assign_parameters(@controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters)
@request.session = ActionController::TestSession.new(session) unless session.nil?
@request.session["flash"] = @request.flash.update(flash || {})
@request.session["flash"].sweep
@controller.request = @request
@controller.params.merge!(parameters)
build_request_uri(action, parameters)
::ActionController::Base.class_eval { include ::ActionController::Testing }
@controller.process_with_new_base_test(@request, @response)
@request.session.delete('flash') if @request.session['flash'].blank?
@response
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment