Browse files

Use internal instance variable naming scheme for mounted URL helper p…

…roxies
  • Loading branch information...
1 parent 5d264f2 commit a79f8bd25230bda16e3c97d168efa38373ec8749 @spohlenz spohlenz committed Sep 9, 2012
View
2 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -319,7 +319,7 @@ def define_mounted_helper(name)
MountedHelpers.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
def #{name}
- @#{name} ||= _#{name}
+ @_#{name} ||= _#{name}
end
RUBY
end
View
11 actionpack/test/dispatch/prefix_generation_test.rb
@@ -57,6 +57,7 @@ def self.routes
get "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine"
get "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for"
get "/conflicting_url", :to => "outside_engine_generating#conflicting"
+ get "/ivar_usage", :to => "outside_engine_generating#ivar_usage"
root :to => "outside_engine_generating#index"
end
@@ -125,6 +126,11 @@ def polymorphic_with_url_for
def conflicting
render :text => "application"
end
+
+ def ivar_usage
+ @blog_engine = "Not the engine route helper"
+ render :text => blog_engine.post_path(:id => 1)
+ end
end
class EngineObject
@@ -203,6 +209,11 @@ def setup
assert_equal "http://example.org/awesome/blog/posts/1", last_response.body
end
+ test "[APP] instance variable with same name as engine" do
+ get "/ivar_usage"
+ assert_equal "/awesome/blog/posts/1", last_response.body
+ end
+
# Inside any Object
test "[OBJECT] proxy route should override respond_to?() as expected" do
assert_respond_to blog_engine, :named_helper_that_should_be_invoked_only_in_respond_to_test_path

0 comments on commit a79f8bd

Please sign in to comment.