aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/test')
-rw-r--r--actionpack/test/abstract_unit.rb12
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb8
-rw-r--r--actionpack/test/controller/routing_test.rb86
-rw-r--r--actionpack/test/controller/test_test.rb3
-rw-r--r--actionpack/test/lib/controller/fake_controllers.rb9
-rw-r--r--actionpack/test/new_base/test_helper.rb24
6 files changed, 50 insertions, 92 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index a21b00915e..07ba37c51c 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -62,8 +62,20 @@ module ActionController
}
Base.session_store = nil
+ class << Routing
+ def possible_controllers
+ @@possible_controllers ||= []
+ end
+ end
+
class Base
include ActionController::Testing
+
+ def self.inherited(klass)
+ name = klass.name.underscore.sub(/_controller$/, '')
+ ActionController::Routing.possible_controllers << name unless name.blank?
+ super
+ end
end
Base.view_paths = FIXTURE_LOAD_PATH
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 06827e5fbc..453812c128 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -182,14 +182,6 @@ end
# a test case to exercise the new capabilities TestRequest & TestResponse
class ActionPackAssertionsControllerTest < ActionController::TestCase
- # let's get this party started
- def setup
- super
-
- ActionController::Routing.use_controllers!(%w(action_pack_assertions admin/inner_module user content admin/user))
- ActionController::Routing::Routes.load_routes!
- end
-
# -- assertion-based testing ------------------------------------------------
def test_assert_tag_and_url_for
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 5be780dd42..d20684296f 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -44,11 +44,11 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase
end
def test_route_recognition_unescapes_path_components
- options = { :controller => "controller",
+ options = { :controller => "content",
:action => "act#{@segment}ion",
:variable => "var#{@segment}iable",
:additional => ["add#{@segment}itional-1", "add#{@segment}itional-2"] }
- assert_equal options, @set.recognize_path("/controller/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2")
+ assert_equal options, @set.recognize_path("/content/act#{@escaped}ion/var#{@escaped}iable/add#{@escaped}itional-1/add#{@escaped}itional-2")
end
def test_route_generation_allows_passing_non_string_values_to_generated_helper
@@ -60,58 +60,6 @@ class UriReservedCharactersRoutingTest < Test::Unit::TestCase
end
class RoutingTest < Test::Unit::TestCase
- def test_possible_controllers
- true_controller_paths = ActionController::Routing.controller_paths
-
- ActionController::Routing.use_controllers! nil
-
- Object.send(:remove_const, :RAILS_ROOT) if defined?(::RAILS_ROOT)
- Object.const_set(:RAILS_ROOT, File.dirname(__FILE__) + '/controller_fixtures')
-
- ActionController::Routing.controller_paths = [
- RAILS_ROOT, RAILS_ROOT + '/app/controllers', RAILS_ROOT + '/vendor/plugins/bad_plugin/lib'
- ]
-
- assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort
- ensure
- if true_controller_paths
- ActionController::Routing.controller_paths = true_controller_paths
- end
- ActionController::Routing.use_controllers! nil
- Object.send(:remove_const, :RAILS_ROOT) rescue nil
- end
-
- def test_possible_controllers_are_reset_on_each_load
- true_possible_controllers = ActionController::Routing.possible_controllers
- true_controller_paths = ActionController::Routing.controller_paths
-
- ActionController::Routing.use_controllers! nil
- root = File.dirname(__FILE__) + '/controller_fixtures'
-
- ActionController::Routing.controller_paths = []
- assert_equal [], ActionController::Routing.possible_controllers
-
- ActionController::Routing.controller_paths = [
- root, root + '/app/controllers', root + '/vendor/plugins/bad_plugin/lib'
- ]
- ActionController::Routing::Routes.load!
-
- assert_equal ["admin/user", "plugin", "user"], ActionController::Routing.possible_controllers.sort
- ensure
- ActionController::Routing.controller_paths = true_controller_paths
- ActionController::Routing.use_controllers! true_possible_controllers
- Object.send(:remove_const, :RAILS_ROOT) rescue nil
-
- ActionController::Routing::Routes.reload!
- end
-
- def test_with_controllers
- c = %w(admin/accounts admin/users account pages)
- ActionController::Routing.with_controllers c do
- assert_equal c, ActionController::Routing.possible_controllers
- end
- end
-
def test_normalize_unix_paths
load_paths = %w(. config/../app/controllers config/../app//helpers script/../config/../vendor/rails/actionpack/lib vendor/rails/railties/builtin/rails_info app/models lib script/../config/../foo/bar/../../app/models .foo/../.bar foo.bar/../config)
paths = ActionController::Routing.normalize_paths(load_paths)
@@ -1815,22 +1763,20 @@ class RouteSetTest < ActiveSupport::TestCase
end
def test_slashes_are_implied
- ActionController::Routing.with_controllers(['foo']) do
- ['/:controller/:action/:id/', '/:controller/:action/:id',
- ':controller/:action/:id', '/:controller/:action/:id/'
- ].each do |path|
- @set = nil
- set.draw { |map| map.connect(path) }
-
- assert_equal '/foo', set.generate(:controller => 'foo', :action => 'index')
- assert_equal '/foo/list', set.generate(:controller => 'foo', :action => 'list')
- assert_equal '/foo/show/1', set.generate(:controller => 'foo', :action => 'show', :id => '1')
-
- assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/foo'))
- assert_equal({:controller => "foo", :action => "index"}, set.recognize_path('/foo/index'))
- assert_equal({:controller => "foo", :action => "list"}, set.recognize_path('/foo/list'))
- assert_equal({:controller => "foo", :action => "show", :id => "1"}, set.recognize_path('/foo/show/1'))
- end
+ ['/:controller/:action/:id/', '/:controller/:action/:id',
+ ':controller/:action/:id', '/:controller/:action/:id/'
+ ].each do |path|
+ @set = nil
+ set.draw { |map| map.connect(path) }
+
+ assert_equal '/content', set.generate(:controller => 'content', :action => 'index')
+ assert_equal '/content/list', set.generate(:controller => 'content', :action => 'list')
+ assert_equal '/content/show/1', set.generate(:controller => 'content', :action => 'show', :id => '1')
+
+ assert_equal({:controller => "content", :action => "index"}, set.recognize_path('/content'))
+ assert_equal({:controller => "content", :action => "index"}, set.recognize_path('/content/index'))
+ assert_equal({:controller => "content", :action => "list"}, set.recognize_path('/content/list'))
+ assert_equal({:controller => "content", :action => "show", :id => "1"}, set.recognize_path('/content/show/1'))
end
end
diff --git a/actionpack/test/controller/test_test.rb b/actionpack/test/controller/test_test.rb
index 84c97851ee..73870a56bb 100644
--- a/actionpack/test/controller/test_test.rb
+++ b/actionpack/test/controller/test_test.rb
@@ -123,9 +123,6 @@ XML
@controller = TestController.new
@request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new
-
- ActionController::Routing.use_controllers! %w(content admin/user test_test/test)
- ActionController::Routing::Routes.load_routes!
end
def test_raw_post_handling
diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb
index 75c114c103..6e02e2d21b 100644
--- a/actionpack/test/lib/controller/fake_controllers.rb
+++ b/actionpack/test/lib/controller/fake_controllers.rb
@@ -1,15 +1,16 @@
class << Object; alias_method :const_available?, :const_defined?; end
-
-class ContentController < Class.new(ActionController::Base)
+
+class ContentController < ActionController::Base
end
class NotAController
end
module Admin
class << self; alias_method :const_available?, :const_defined?; end
- class UserController < Class.new(ActionController::Base); end
- class NewsFeedController < Class.new(ActionController::Base); end
+ class UserController < ActionController::Base; end
+ class NewsFeedController < ActionController::Base; end
end
+
# For speed test
class SpeedController < ActionController::Base; end
class SearchController < SpeedController; end
diff --git a/actionpack/test/new_base/test_helper.rb b/actionpack/test/new_base/test_helper.rb
index 9271b2dd59..b7ccd3db8d 100644
--- a/actionpack/test/new_base/test_helper.rb
+++ b/actionpack/test/new_base/test_helper.rb
@@ -35,12 +35,6 @@ class Rack::TestCase < ActionController::IntegrationTest
setup do
ActionController::Base.session_options[:key] = "abc"
ActionController::Base.session_options[:secret] = ("*" * 30)
-
- controllers = ActionController::Base.subclasses.map do |k|
- k.underscore.sub(/_controller$/, '')
- end
-
- ActionController::Routing.use_controllers!(controllers)
end
def app
@@ -91,10 +85,26 @@ end
class ::ApplicationController < ActionController::Base
end
+module ActionController
+ class << Routing
+ def possible_controllers
+ @@possible_controllers ||= []
+ end
+ end
+
+ class Base
+ def self.inherited(klass)
+ name = klass.name.underscore.sub(/_controller$/, '')
+ ActionController::Routing.possible_controllers << name unless name.blank?
+ super
+ end
+ end
+end
+
class SimpleRouteCase < Rack::TestCase
setup do
ActionController::Routing::Routes.draw do |map|
map.connect ':controller/:action/:id'
end
end
-end \ No newline at end of file
+end