From 03ac291526b04586a0f0db0f531f18f14be792c6 Mon Sep 17 00:00:00 2001 From: Brian Hahn Date: Wed, 4 Sep 2013 16:43:36 -0700 Subject: pass the extra params to the rack test environment so that routes with block constraints have access --- actionpack/test/dispatch/routing_assertions_test.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'actionpack/test/dispatch/routing_assertions_test.rb') diff --git a/actionpack/test/dispatch/routing_assertions_test.rb b/actionpack/test/dispatch/routing_assertions_test.rb index 423eeda92c..1ca0895da9 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 -- cgit v1.2.3