diff options
Diffstat (limited to 'railties/test/application')
-rw-r--r-- | railties/test/application/rack/logger_test.rb | 1 | ||||
-rw-r--r-- | railties/test/application/route_inspect_test.rb | 2 | ||||
-rw-r--r-- | railties/test/application/routing_test.rb | 71 |
3 files changed, 73 insertions, 1 deletions
diff --git a/railties/test/application/rack/logger_test.rb b/railties/test/application/rack/logger_test.rb index c13f9a49e7..984d8374fb 100644 --- a/railties/test/application/rack/logger_test.rb +++ b/railties/test/application/rack/logger_test.rb @@ -1,6 +1,7 @@ require "isolation/abstract_unit" require "active_support/log_subscriber/test_helper" require "rack/test" +require "mocha/setup" module ApplicationTests module RackTests diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb index b897cf15b8..5c920cb33a 100644 --- a/railties/test/application/route_inspect_test.rb +++ b/railties/test/application/route_inspect_test.rb @@ -1,5 +1,5 @@ require 'test/unit' -require 'mocha' +require 'mocha/setup' require 'rails/application/route_inspector' require 'action_controller' require 'rails/engine' diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb index a05e39658d..e50d744e26 100644 --- a/railties/test/application/routing_test.rb +++ b/railties/test/application/routing_test.rb @@ -229,6 +229,77 @@ module ApplicationTests end end + test 'routes are added and removed when reloading' do + app('development') + + controller :foo, <<-RUBY + class FooController < ApplicationController + def index + render :text => "foo" + end + end + RUBY + + controller :bar, <<-RUBY + class BarController < ApplicationController + def index + render :text => "bar" + end + end + RUBY + + app_file 'config/routes.rb', <<-RUBY + AppTemplate::Application.routes.draw do + get 'foo', :to => 'foo#index' + end + RUBY + + get '/foo' + assert_equal 'foo', last_response.body + assert_equal '/foo', Rails.application.routes.url_helpers.foo_path + + get '/bar' + assert_equal 404, last_response.status + assert_raises NoMethodError do + assert_equal '/bar', Rails.application.routes.url_helpers.bar_path + end + + app_file 'config/routes.rb', <<-RUBY + AppTemplate::Application.routes.draw do + get 'foo', :to => 'foo#index' + get 'bar', :to => 'bar#index' + end + RUBY + + Rails.application.reload_routes! + + get '/foo' + assert_equal 'foo', last_response.body + assert_equal '/foo', Rails.application.routes.url_helpers.foo_path + + get '/bar' + assert_equal 'bar', last_response.body + assert_equal '/bar', Rails.application.routes.url_helpers.bar_path + + app_file 'config/routes.rb', <<-RUBY + AppTemplate::Application.routes.draw do + get 'foo', :to => 'foo#index' + end + RUBY + + Rails.application.reload_routes! + + get '/foo' + assert_equal 'foo', last_response.body + assert_equal '/foo', Rails.application.routes.url_helpers.foo_path + + get '/bar' + assert_equal 404, last_response.status + assert_raises NoMethodError do + assert_equal '/bar', Rails.application.routes.url_helpers.bar_path + end + end + test 'resource routing with irregular inflection' do app_file 'config/initializers/inflection.rb', <<-RUBY ActiveSupport::Inflector.inflections do |inflect| |