diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-29 11:57:02 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-02-29 11:57:02 -0800 |
commit | 1d215286c9019a0fa98e87bffccc8fc2b97d5a46 (patch) | |
tree | 9195b8636b024fcc6d7acd0abeaeceef2b7bf685 /actionpack/test/dispatch | |
parent | 4244a09c530edafbb5b4186e84f6313321df4189 (diff) | |
parent | d7bf930df5f508a0a201c8511376fb62fa22ff68 (diff) | |
download | rails-1d215286c9019a0fa98e87bffccc8fc2b97d5a46.tar.gz rails-1d215286c9019a0fa98e87bffccc8fc2b97d5a46.tar.bz2 rails-1d215286c9019a0fa98e87bffccc8fc2b97d5a46.zip |
Merge pull request #5219 from mattfawcett/2781-fix-querystring-route-constraint-for-testing
Fix for #2781
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r-- | actionpack/test/dispatch/routing_assertions_test.rb | 12 |
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 |