aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2013-07-21 17:48:24 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2013-07-21 17:48:24 +0100
commitd8353073d1d00ace843eb5e402ebc7fdb2d7c342 (patch)
tree828afffbabfb6bf0e53c14a3b59f7ed9b1ebde54
parented19c02c8de3789cd26178c50246e8e155d5532f (diff)
downloadrails-d8353073d1d00ace843eb5e402ebc7fdb2d7c342.tar.gz
rails-d8353073d1d00ace843eb5e402ebc7fdb2d7c342.tar.bz2
rails-d8353073d1d00ace843eb5e402ebc7fdb2d7c342.zip
Add test to prevent route reloading regression
Journey doesn't clear its named route hash when the routes are reloaded but Rails 3.2 isn't affected because Journey overwrites the existing route. This is just a backport of the test to make sure it doesn't become affected in some future release.
-rw-r--r--railties/test/application/routing_test.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/railties/test/application/routing_test.rb b/railties/test/application/routing_test.rb
index 4cdc6549db..6b2b2c590c 100644
--- a/railties/test/application/routing_test.rb
+++ b/railties/test/application/routing_test.rb
@@ -324,6 +324,51 @@ module ApplicationTests
end
end
+ test 'named routes are cleared 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
+ Rails.application.routes.draw do
+ get ':locale/foo', to: 'foo#index', as: 'foo'
+ end
+ RUBY
+
+ get '/en/foo'
+ assert_equal 'foo', last_response.body
+ assert_equal '/en/foo', Rails.application.routes.url_helpers.foo_path(:locale => 'en')
+
+ app_file 'config/routes.rb', <<-RUBY
+ Rails.application.routes.draw do
+ get ':locale/bar', to: 'bar#index', as: 'foo'
+ end
+ RUBY
+
+ Rails.application.reload_routes!
+
+ get '/en/foo'
+ assert_equal 404, last_response.status
+
+ get '/en/bar'
+ assert_equal 'bar', last_response.body
+ assert_equal '/en/bar', Rails.application.routes.url_helpers.foo_path(:locale => 'en')
+ end
+
test 'resource routing with irregular inflection' do
app_file 'config/initializers/inflection.rb', <<-RUBY
ActiveSupport::Inflector.inflections do |inflect|