aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/routing_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-10-13 03:28:35 +0000
committerMichael Koziarski <michael@koziarski.com>2007-10-13 03:28:35 +0000
commitbd03bf9f5e2a1a8a667785e82658e3efa3f08a25 (patch)
treeafc3085082a64434a14be2bd6a7b7beb6ccff83c /actionpack/test/controller/routing_test.rb
parentfaff774f9d48095163161562480dfb426c0462f9 (diff)
downloadrails-bd03bf9f5e2a1a8a667785e82658e3efa3f08a25.tar.gz
rails-bd03bf9f5e2a1a8a667785e82658e3efa3f08a25.tar.bz2
rails-bd03bf9f5e2a1a8a667785e82658e3efa3f08a25.zip
Make sure that custom inflections are picked up by map.resources by triggering a routing reload when new inflections are defined. Closes #9815 [mislav, kampers]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7849 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/test/controller/routing_test.rb')
-rw-r--r--actionpack/test/controller/routing_test.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 2522b2398b..ce897db238 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -2031,3 +2031,63 @@ class RoutingTest < Test::Unit::TestCase
end
end
+
+uses_mocha 'route loading' do
+ class RouteLoadingTest < Test::Unit::TestCase
+
+ def setup
+ routes.instance_variable_set '@routes_last_modified', nil
+ silence_warnings { Object.const_set :RAILS_ROOT, '.' }
+
+ @stat = stub_everything
+ end
+
+ def teardown
+ Object.send :remove_const, :RAILS_ROOT
+ end
+
+ def test_load
+ File.expects(:stat).returns(@stat)
+ routes.expects(:load).with(regexp_matches(/routes\.rb$/))
+
+ routes.reload
+ end
+
+ def test_no_reload_when_not_modified
+ @stat.expects(:mtime).times(2).returns(1)
+ File.expects(:stat).times(2).returns(@stat)
+ routes.expects(:load).with(regexp_matches(/routes\.rb$/)).at_most_once
+
+ 2.times { routes.reload }
+ end
+
+ def test_reload_when_modified
+ @stat.expects(:mtime).at_least(2).returns(1, 2)
+ File.expects(:stat).at_least(2).returns(@stat)
+ routes.expects(:load).with(regexp_matches(/routes\.rb$/)).times(2)
+
+ 2.times { routes.reload }
+ end
+
+ def test_bang_forces_reload
+ @stat.expects(:mtime).at_least(2).returns(1)
+ File.expects(:stat).at_least(2).returns(@stat)
+ routes.expects(:load).with(regexp_matches(/routes\.rb$/)).times(2)
+
+ 2.times { routes.reload! }
+ end
+
+ def test_adding_inflections_forces_reload
+ Inflector::Inflections.instance.expects(:uncountable).with('equipment')
+ routes.expects(:reload!)
+
+ Inflector.inflections { |inflect| inflect.uncountable('equipment') }
+ end
+
+ private
+ def routes
+ ActionController::Routing::Routes
+ end
+
+ end
+end