Fixed that Functional tests do not set request.path_parameters properly #1512 [Nicholas Seckar]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1527 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
b17e178981
commit
930b59eb39
|
@ -67,6 +67,13 @@ module ActionController #:nodoc:
|
||||||
@path || super()
|
@path || super()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def assign_parameters(parameters)
|
||||||
|
path, extras = ActionController::Routing::Routes.generate(parameters.symbolize_keys)
|
||||||
|
non_path_parameters = (get? ? query_parameters : request_parameters)
|
||||||
|
parameters.each do |key, value|
|
||||||
|
(extras.key?(key.to_sym) ? non_path_parameters : path_parameters)[key] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def initialize_containers
|
def initialize_containers
|
||||||
|
@ -239,9 +246,12 @@ module Test
|
||||||
@html_document = nil
|
@html_document = nil
|
||||||
@request.env['REQUEST_METHOD'] ||= "GET"
|
@request.env['REQUEST_METHOD'] ||= "GET"
|
||||||
@request.action = action.to_s
|
@request.action = action.to_s
|
||||||
@request.path_parameters = { :controller => @controller.class.controller_path,
|
|
||||||
:action => action.to_s }
|
parameters ||= {}
|
||||||
@request.parameters.update(parameters) unless parameters.nil?
|
parameters[:controller] = @controller.class.controller_path
|
||||||
|
parameters[:action] = action.to_s
|
||||||
|
@request.assign_parameters(parameters)
|
||||||
|
|
||||||
@request.session = ActionController::TestSession.new(session) unless session.nil?
|
@request.session = ActionController::TestSession.new(session) unless session.nil?
|
||||||
@request.session["flash"] = ActionController::Flash::FlashHash.new.update(flash) if flash
|
@request.session["flash"] = ActionController::Flash::FlashHash.new.update(flash) if flash
|
||||||
build_request_uri(action, parameters)
|
build_request_uri(action, parameters)
|
||||||
|
|
|
@ -55,6 +55,10 @@ class ActionPackAssertionsController < ActionController::Base
|
||||||
render_text "Mr. #{@params["name"]}"
|
render_text "Mr. #{@params["name"]}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def render_url
|
||||||
|
render_text "<div>#{url_for(:action => 'flash_me', :only_path => true)}</div>"
|
||||||
|
end
|
||||||
|
|
||||||
# puts something in the session
|
# puts something in the session
|
||||||
def session_stuffing
|
def session_stuffing
|
||||||
session['xmas'] = 'turkey'
|
session['xmas'] = 'turkey'
|
||||||
|
@ -97,6 +101,11 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
# -- assertion-based testing ------------------------------------------------
|
# -- assertion-based testing ------------------------------------------------
|
||||||
|
|
||||||
|
def test_assert_tag_and_url_for
|
||||||
|
get :render_url
|
||||||
|
assert_tag :content => "/action_pack_assertions/flash_me"
|
||||||
|
end
|
||||||
|
|
||||||
# test the session assertion to make sure something is there.
|
# test the session assertion to make sure something is there.
|
||||||
def test_assert_session_has
|
def test_assert_session_has
|
||||||
process :session_stuffing
|
process :session_stuffing
|
||||||
|
@ -359,7 +368,7 @@ class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
||||||
assert_redirected_to :action => "flash_me"
|
assert_redirected_to :action => "flash_me"
|
||||||
|
|
||||||
follow_redirect
|
follow_redirect
|
||||||
assert_equal 1, @request.parameters["id"]
|
assert_equal 1, @request.parameters["id"].to_i
|
||||||
|
|
||||||
assert "Inconceivable!", @response.body
|
assert "Inconceivable!", @response.body
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue