aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2010-07-03 08:14:17 +0100
committerJosé Valim <jose.valim@gmail.com>2010-07-03 10:06:07 +0200
commit54250a5bfe6992afaaca6357d3b414e6c49651ba (patch)
tree70636f67d57a7c6e0667505ea7aecf94eb159179 /actionpack/test
parent8cc746331c32a6951e5c73c8a21fd32f00680471 (diff)
downloadrails-54250a5bfe6992afaaca6357d3b414e6c49651ba.tar.gz
rails-54250a5bfe6992afaaca6357d3b414e6c49651ba.tar.bz2
rails-54250a5bfe6992afaaca6357d3b414e6c49651ba.zip
Refactor recall parameter normalization [#5021 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/template/url_helper_test.rb29
1 files changed, 27 insertions, 2 deletions
diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb
index 765beebfa3..048f96c9a9 100644
--- a/actionpack/test/template/url_helper_test.rb
+++ b/actionpack/test/template/url_helper_test.rb
@@ -406,6 +406,14 @@ end
class UrlHelperControllerTest < ActionController::TestCase
class UrlHelperController < ActionController::Base
test_routes do |map|
+ match 'url_helper_controller_test/url_helper/show/:id',
+ :to => 'url_helper_controller_test/url_helper#show',
+ :as => :show
+
+ match 'url_helper_controller_test/url_helper/profile/:name',
+ :to => 'url_helper_controller_test/url_helper#show',
+ :as => :profile
+
match 'url_helper_controller_test/url_helper/show_named_route',
:to => 'url_helper_controller_test/url_helper#show_named_route',
:as => :show_named_route
@@ -418,6 +426,14 @@ class UrlHelperControllerTest < ActionController::TestCase
:as => :normalize_recall_params
end
+ def show
+ if params[:name]
+ render :inline => 'ok'
+ else
+ redirect_to profile_path(params[:id])
+ end
+ end
+
def show_url_for
render :inline => "<%= url_for :controller => 'url_helper_controller_test/url_helper', :action => 'show_url_for' %>"
end
@@ -484,15 +500,24 @@ class UrlHelperControllerTest < ActionController::TestCase
assert_equal 'http://testtwo.host/url_helper_controller_test/url_helper/show_named_route', @response.body
end
- def test_recall_params_should_be_normalized_when_using_block_route
+ def test_recall_params_should_be_normalized
get :normalize_recall_params
assert_equal '/url_helper_controller_test/url_helper/normalize_recall_params', @response.body
end
- def test_recall_params_should_not_be_changed_when_using_normal_route
+ def test_recall_params_should_not_be_changed
get :recall_params_not_changed
assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body
end
+
+ def test_recall_params_should_normalize_id
+ get :show, :id => '123'
+ assert_equal 302, @response.status
+ assert_equal 'http://test.host/url_helper_controller_test/url_helper/profile/123', @response.location
+
+ get :show, :name => '123'
+ assert_equal 'ok', @response.body
+ end
end
class TasksController < ActionController::Base