diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/abstract_controller/rendering.rb | 16 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 17 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/base.rb | 17 | ||||
-rw-r--r-- | actionpack/test/dispatch/mapper_test.rb | 3 | ||||
-rw-r--r-- | actionpack/test/dispatch/routing_test.rb | 49 | ||||
-rw-r--r-- | actionpack/test/fixtures/routes/bogus.rb | 1 | ||||
-rw-r--r-- | actionpack/test/fixtures/routes/external.rb | 1 |
8 files changed, 14 insertions, 92 deletions
diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 7d73c6af8d..3da2834af0 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -49,9 +49,19 @@ module AbstractController module ClassMethods def view_context_class @view_context_class ||= begin - routes = _routes if respond_to?(:_routes) - helpers = _helpers if respond_to?(:_helpers) - ActionView::Base.prepare(routes, helpers) + routes = respond_to?(:_routes) && _routes + helpers = respond_to?(:_helpers) && _helpers + + Class.new(ActionView::Base) do + if routes + include routes.url_helpers + include routes.mounted_helpers + end + + if helpers + include helpers + end + end end end end diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 94242ad962..53a4afecb3 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1316,22 +1316,6 @@ module ActionDispatch parent_resource.instance_of?(Resource) && @scope[:shallow] end - def draw(name) - path = @draw_paths.find do |_path| - File.exists? "#{_path}/#{name}.rb" - end - - unless path - msg = "Your router tried to #draw the external file #{name}.rb,\n" \ - "but the file was not found in:\n\n" - msg += @draw_paths.map { |_path| " * #{_path}" }.join("\n") - raise ArgumentError, msg - end - - route_path = "#{path}/#{name}.rb" - instance_eval(File.read(route_path), route_path.to_s) - end - # match 'path' => 'controller#action' # match 'path', to: 'controller#action' # match 'path', 'otherpath', on: :member, via: :get @@ -1581,7 +1565,6 @@ module ActionDispatch def initialize(set) #:nodoc: @set = set - @draw_paths = set.draw_paths @scope = { :path_names => @set.resources_path_names } end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 64b1d58ae9..1d6ca0c78d 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -237,7 +237,6 @@ module ActionDispatch attr_accessor :formatter, :set, :named_routes, :default_scope, :router attr_accessor :disable_clear_and_finalize, :resources_path_names attr_accessor :default_url_options, :request_class, :valid_conditions - attr_accessor :draw_paths alias :routes :set @@ -249,7 +248,6 @@ module ActionDispatch self.named_routes = NamedRouteCollection.new self.resources_path_names = self.class.default_resources_path_names.dup self.default_url_options = {} - self.draw_paths = [] self.request_class = request_class @valid_conditions = { :controller => true, :action => true } diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index f98648d930..7bfbc1f0aa 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -148,7 +148,6 @@ module ActionView #:nodoc: cattr_accessor :prefix_partial_path_with_controller_namespace @@prefix_partial_path_with_controller_namespace = true - class_attribute :helpers class_attribute :_routes class_attribute :logger @@ -166,22 +165,6 @@ module ActionView #:nodoc: def xss_safe? #:nodoc: true end - - # This method receives routes and helpers from the controller - # and return a subclass ready to be used as view context. - def prepare(routes, helpers) #:nodoc: - Class.new(self) do - if routes - include routes.url_helpers - include routes.mounted_helpers - end - - if helpers - include helpers - self.helpers = helpers - end - end - end end attr_accessor :view_renderer diff --git a/actionpack/test/dispatch/mapper_test.rb b/actionpack/test/dispatch/mapper_test.rb index bd078d2b21..8070bdec8a 100644 --- a/actionpack/test/dispatch/mapper_test.rb +++ b/actionpack/test/dispatch/mapper_test.rb @@ -4,12 +4,11 @@ module ActionDispatch module Routing class MapperTest < ActiveSupport::TestCase class FakeSet - attr_reader :routes, :draw_paths + attr_reader :routes alias :set :routes def initialize @routes = [] - @draw_paths = [] end def resources_path_names diff --git a/actionpack/test/dispatch/routing_test.rb b/actionpack/test/dispatch/routing_test.rb index f15dd7214b..fed26d89f8 100644 --- a/actionpack/test/dispatch/routing_test.rb +++ b/actionpack/test/dispatch/routing_test.rb @@ -2324,55 +2324,6 @@ class TestNamespaceWithControllerOption < ActionDispatch::IntegrationTest end end -class TestDrawExternalFile < ActionDispatch::IntegrationTest - class ExternalController < ActionController::Base - def index - render :text => "external#index" - end - end - - DRAW_PATH = File.expand_path('../../fixtures/routes', __FILE__) - - DefaultScopeRoutes = ActionDispatch::Routing::RouteSet.new.tap do |app| - app.draw_paths << DRAW_PATH - end - - def app - DefaultScopeRoutes - end - - def test_draw_external_file - DefaultScopeRoutes.draw do - scope :module => 'test_draw_external_file' do - draw :external - end - end - - get '/external' - assert_equal "external#index", @response.body - end - - def test_draw_nonexistent_file - exception = assert_raise ArgumentError do - DefaultScopeRoutes.draw do - draw :nonexistent - end - end - assert_match 'Your router tried to #draw the external file nonexistent.rb', exception.message - assert_match DRAW_PATH.to_s, exception.message - end - - def test_draw_bogus_file - exception = assert_raise NoMethodError do - DefaultScopeRoutes.draw do - draw :bogus - end - end - assert_match "undefined method `wrong'", exception.message - assert_match 'test/fixtures/routes/bogus.rb:1', exception.backtrace.first - end -end - class TestDefaultScope < ActionDispatch::IntegrationTest module ::Blog class PostsController < ActionController::Base diff --git a/actionpack/test/fixtures/routes/bogus.rb b/actionpack/test/fixtures/routes/bogus.rb deleted file mode 100644 index 41fbf0cd64..0000000000 --- a/actionpack/test/fixtures/routes/bogus.rb +++ /dev/null @@ -1 +0,0 @@ -wrong :route diff --git a/actionpack/test/fixtures/routes/external.rb b/actionpack/test/fixtures/routes/external.rb deleted file mode 100644 index d103c39f53..0000000000 --- a/actionpack/test/fixtures/routes/external.rb +++ /dev/null @@ -1 +0,0 @@ -get '/external' => 'external#index' |