From 7418a440967586851a182bbcd6d93dbba9497cdb Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Fri, 17 Sep 2010 12:05:40 -0700 Subject: Add RouteSet#append Allows specifying blocks to the routeset that will get appended after the RouteSet is drawn. --- actionpack/test/dispatch/routing_test.rb | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'actionpack/test/dispatch') diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index b642adc06b..8a2311ab3e 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2152,6 +2152,39 @@ private end end +class TestAppendingRoutes < ActionController::IntegrationTest + def simple_app(resp) + lambda { |e| [ 200, { 'Content-Type' => 'text/plain' }, [resp] ] } + end + + setup do + s = self + @app = ActionDispatch::Routing::RouteSet.new + @app.append do + match '/hello' => s.simple_app('fail') + match '/goodbye' => s.simple_app('goodbye') + end + + @app.draw do + match '/hello' => s.simple_app('hello') + end + end + + def test_goodbye_should_be_available + get '/goodbye' + assert_equal 'goodbye', @response.body + end + + def test_hello_should_not_be_overwritten + get '/hello' + assert_equal 'hello', @response.body + end + + def test_missing_routes_are_still_missing + get '/random' + assert_equal 404, @response.status + end +end class TestDefaultScope < ActionController::IntegrationTest module ::Blog -- cgit v1.2.3