diff options
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rw-r--r-- | actionpack/test/controller/routing_test.rb | 17 |
2 files changed, 18 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index d9b5f3eb54..bced4254d7 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Improve Test Coverage for ActionController::Routing::Route#matches_controller_and_action? (Heckle++) #7115 [Kevin Clark] + * Heckling ActionController::Resources::Resource revealed that set_prefixes didn't break when :name_prefix was munged. #7081 [Kevin Clark] * Fix #distance_of_time_in_words to report accurately against the Duration class. #7114 [eventualbuddha] 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 |