diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-12-01 21:19:20 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-12-01 21:19:20 -0600 |
commit | 30ae3538a3e281be3d6e8ca337a0790c71f8a9b2 (patch) | |
tree | 8a039067f9deccef929d64f46c4e9d6b6bd2b2af /railties | |
parent | 28657e4f418c84dad08ae1f541d24df2d91d93aa (diff) | |
download | rails-30ae3538a3e281be3d6e8ca337a0790c71f8a9b2.tar.gz rails-30ae3538a3e281be3d6e8ca337a0790c71f8a9b2.tar.bz2 rails-30ae3538a3e281be3d6e8ca337a0790c71f8a9b2.zip |
Some basic route discovery tests
Diffstat (limited to 'railties')
-rw-r--r-- | railties/test/application/routing_test.rb | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb new file mode 100644 index 0000000000..1bfec3805b --- /dev/null +++ b/railties/test/application/routing_test.rb @@ -0,0 +1,85 @@ +require 'isolation/abstract_unit' +require 'rack/test' + +module ApplicationTests + class RoutingTest < Test::Unit::TestCase + include ActiveSupport::Testing::Isolation + include Rack::Test::Methods + + def setup + build_app + end + + def app + @app ||= begin + boot_rails + require "#{app_path}/config/environment" + + Rails.application + end + end + + test "simple controller" do + controller :foo, <<-RUBY + class FooController < ActionController::Base + def index + render :text => "foo" + end + end + RUBY + + get '/foo' + assert_equal 'foo', last_response.body + end + + test "multiple controllers" do + controller :foo, <<-RUBY + class FooController < ActionController::Base + def index + render :text => "foo" + end + end + RUBY + + controller :bar, <<-RUBY + class BarController < ActionController::Base + def index + render :text => "bar" + end + end + RUBY + + get '/foo' + assert_equal 'foo', last_response.body + + get '/bar' + assert_equal 'bar', last_response.body + end + + test "nested controller" do + controller 'foo', <<-RUBY + class FooController < ActionController::Base + def index + render :text => "foo" + end + end + RUBY + + controller 'admin/foo', <<-RUBY + module Admin + class FooController < ActionController::Base + def index + render :text => "admin::foo" + end + end + end + RUBY + + get '/foo' + assert_equal 'foo', last_response.body + + get '/admin/foo' + assert_equal 'admin::foo', last_response.body + end + end +end |