aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2007-01-17 06:49:43 +0000
committerRick Olson <technoweenie@gmail.com>2007-01-17 06:49:43 +0000
commitd2205ea5e9e45478f9391e5a6d9ad5767a9415ca (patch)
treed528ab186a3d28d6478d8784794be2738c80bf05
parent582c028b14bff4229eae5e45a2d4f886a5865ed3 (diff)
downloadrails-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
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/test/controller/routing_test.rb17
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