diff options
author | Rick Olson <technoweenie@gmail.com> | 2007-01-17 06:49:43 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2007-01-17 06:49:43 +0000 |
commit | d2205ea5e9e45478f9391e5a6d9ad5767a9415ca (patch) | |
tree | d528ab186a3d28d6478d8784794be2738c80bf05 /actionpack/test/controller | |
parent | 582c028b14bff4229eae5e45a2d4f886a5865ed3 (diff) | |
download | rails-d2205ea5e9e45478f9391e5a6d9ad5767a9415ca.tar.gz rails-d2205ea5e9e45478f9391e5a6d9ad5767a9415ca.tar.bz2 rails-d2205ea5e9e45478f9391e5a6d9ad5767a9415ca.zip |
Improve Test Coverage for ActionController::Routing::Route#matches_controller_and_action? (Heckle++) #7115 [Kevin Clark]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5976 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb index ced8ca2dc6..b7d63db5a0 100644 --- a/actionpack/test/controller/routing_test.rb +++ b/actionpack/test/controller/routing_test.rb @@ -774,6 +774,8 @@ class ControllerSegmentTest < Test::Unit::TestCase end +uses_mocha 'RouteTest' do + class RouteTest < Test::Unit::TestCase def setup @@ -847,7 +849,18 @@ class RouteTest < Test::Unit::TestCase o = {:controller => 'accounts', :action => 'list_all'} assert_equal '/accounts/list_all', default_route.generate(o, o, {}) end - + + def test_matches_controller_and_action + # requirement_for should only be called for the action and controller _once_ + @route.expects(:requirement_for).with(:controller).times(1).returns('pages') + @route.expects(:requirement_for).with(:action).times(1).returns('show') + + @route.requirements = {:controller => 'pages', :action => 'show'} + assert @route.matches_controller_and_action?('pages', 'show') + assert !@route.matches_controller_and_action?('not_pages', 'show') + assert !@route.matches_controller_and_action?('pages', 'not_show') + end + def test_parameter_shell page_url = ROUTING::Route.new page_url.requirements = {:controller => 'pages', :action => 'show', :id => /\d+/} @@ -934,6 +947,8 @@ class RouteTest < Test::Unit::TestCase end end +end # uses_mocha + class RouteBuilderTest < Test::Unit::TestCase def builder |