Skip to content

Commit

Permalink
Fix problems trying to functional test AC::Metal controllers
Browse files Browse the repository at this point in the history
[#5393 state:committed]
  • Loading branch information
spastorino committed Nov 6, 2010
1 parent c11102d commit 2382667
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
10 changes: 1 addition & 9 deletions actionpack/lib/action_controller/metal/testing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,10 @@ def process_with_new_base_test(request, response)
cookies.write(@_response)
end
@_response.prepare!
set_test_assigns
@assigns = respond_to?(:view_assigns) ? view_assigns : {}
ret
end

def set_test_assigns
@assigns = {}
(instance_variable_names - self.class.protected_instance_variables).each do |var|
name, value = var[1..-1], instance_variable_get(var)
@assigns[name] = value
end
end

# TODO : Rewrite tests using controller.headers= to use Rack env
def headers=(new_headers)
@_response ||= ActionDispatch::Response.new
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
@controller.request = @request
@controller.params.merge!(parameters)
build_request_uri(action, parameters)
Base.class_eval { include Testing }
@controller.class.class_eval { include Testing }
@controller.process_with_new_base_test(@request, @response)
@request.session.delete('flash') if @request.session['flash'].blank?
@response
Expand Down Expand Up @@ -448,7 +448,7 @@ def rescue_action_in_public!

def build_request_uri(action, parameters)
unless @request.env["PATH_INFO"]
options = @controller.__send__(:url_options).merge(parameters)
options = @controller.respond_to?(:url_options) ? @controller.__send__(:url_options).merge(parameters) : parameters
options.update(
:only_path => true,
:action => action,
Expand Down
7 changes: 7 additions & 0 deletions actionpack/test/controller/new_base/bare_metal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ class HeadTest < ActiveSupport::TestCase
assert_equal 404, status
end
end

class BareControllerTest < ActionController::TestCase
test "GET index" do
get :index
assert_equal "Hello world", @response.body
end
end
end

0 comments on commit 2382667

Please sign in to comment.