aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/routing_assertions_test.rb
diff options
context:
space:
mode:
authorMatt Fawcett <mail@matthewfawcett.co.uk>2012-02-24 13:16:31 +0000
committerMatt Fawcett <mail@matthewfawcett.co.uk>2012-02-24 13:16:31 +0000
commitd7bf930df5f508a0a201c8511376fb62fa22ff68 (patch)
treeb6840e594da4ccc6046f4df6eb2012018e140b30 /actionpack/test/dispatch/routing_assertions_test.rb
parent335fac56b671cd627ed55cbd41a62d3890342de4 (diff)
downloadrails-d7bf930df5f508a0a201c8511376fb62fa22ff68.tar.gz
rails-d7bf930df5f508a0a201c8511376fb62fa22ff68.tar.bz2
rails-d7bf930df5f508a0a201c8511376fb62fa22ff68.zip
Fix the assert_recognizes test method so that it works when there are
constraints on the querystring. Issue #2781
Diffstat (limited to 'actionpack/test/dispatch/routing_assertions_test.rb')
-rw-r--r--actionpack/test/dispatch/routing_assertions_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/routing_assertions_test.rb b/actionpack/test/dispatch/routing_assertions_test.rb
index 9f95d82129..e953029456 100644
--- a/actionpack/test/dispatch/routing_assertions_test.rb
+++ b/actionpack/test/dispatch/routing_assertions_test.rb
@@ -3,6 +3,7 @@ require 'controller/fake_controllers'
class SecureArticlesController < ArticlesController; end
class BlockArticlesController < ArticlesController; end
+class QueryArticlesController < ArticlesController; end
class RoutingAssertionsTest < ActionController::TestCase
@@ -18,6 +19,10 @@ class RoutingAssertionsTest < ActionController::TestCase
scope 'block', :constraints => lambda { |r| r.ssl? } do
resources :articles, :controller => 'block_articles'
end
+
+ scope 'query', :constraints => lambda { |r| r.params[:use_query] == 'true' } do
+ resources :articles, :controller => 'query_articles'
+ end
end
end
@@ -62,6 +67,13 @@ class RoutingAssertionsTest < ActionController::TestCase
assert_recognizes({ :controller => 'block_articles', :action => 'index' }, 'https://test.host/block/articles')
end
+ def test_assert_recognizes_with_query_constraint
+ assert_raise(ActionController::RoutingError) do
+ assert_recognizes({ :controller => 'query_articles', :action => 'index', :use_query => 'false' }, '/query/articles', { :use_query => 'false' })
+ end
+ assert_recognizes({ :controller => 'query_articles', :action => 'index', :use_query => 'true' }, '/query/articles', { :use_query => 'true' })
+ end
+
def test_assert_routing
assert_routing('/articles', :controller => 'articles', :action => 'index')
end