Permalink
Browse files

Allow generated url helpers to be overriden [#5243 state:resolved]

  • Loading branch information...
1 parent 5f6a02f commit 63b0d0e9d29522ae8dd6b58ea094b8bc54f7bf70 @pixeltrix pixeltrix committed Oct 26, 2010
Showing with 22 additions and 4 deletions.
  1. +4 −4 actionpack/lib/abstract_controller/rendering.rb
  2. +18 −0 actionpack/test/template/url_helper_test.rb
View
8 actionpack/lib/abstract_controller/rendering.rb
@@ -47,13 +47,13 @@ def view_context_class
@view_context_class ||= begin
controller = self
Class.new(ActionView::Base) do
+ if controller.respond_to?(:_routes)
+ include controller._routes.url_helpers
+ end
+
if controller.respond_to?(:_helpers)
include controller._helpers
- if controller.respond_to?(:_routes)
- include controller._routes.url_helpers
- end
-
# TODO: Fix RJS to not require this
self.helpers = controller._helpers
end
View
18 actionpack/test/template/url_helper_test.rb
@@ -441,6 +441,10 @@ class UrlHelperController < ActionController::Base
match 'url_helper_controller_test/url_helper/normalize_recall_params',
:to => UrlHelperController.action(:normalize_recall),
:as => :normalize_recall_params
+
+ match '/url_helper_controller_test/url_helper/override_url_helper/default',
+ :to => 'url_helper_controller_test/url_helper#override_url_helper',
+ :as => :override_url_helper
end
def show
@@ -476,6 +480,15 @@ def recall_params_not_changed
end
def rescue_action(e) raise e end
+
+ def override_url_helper
+ render :inline => '<%= override_url_helper_path %>'
+ end
+
+ def override_url_helper_path
+ '/url_helper_controller_test/url_helper/override_url_helper/override'
+ end
+ helper_method :override_url_helper_path
end
tests UrlHelperController
@@ -535,6 +548,11 @@ def test_recall_params_should_normalize_id
get :show, :name => '123'
assert_equal 'ok', @response.body
end
+
+ def test_url_helper_can_be_overriden
+ get :override_url_helper
+ assert_equal '/url_helper_controller_test/url_helper/override_url_helper/override', @response.body
+ end
end
class TasksController < ActionController::Base

0 comments on commit 63b0d0e

Please sign in to comment.