mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #7580 from spohlenz/mounted-url-helper-ivars
Use internal instance variable naming scheme for mounted URL helpers
This commit is contained in:
commit
6107407e66
2 changed files with 12 additions and 1 deletions
|
@ -319,7 +319,7 @@ module ActionDispatch
|
||||||
|
|
||||||
MountedHelpers.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
MountedHelpers.class_eval(<<-RUBY, __FILE__, __LINE__ + 1)
|
||||||
def #{name}
|
def #{name}
|
||||||
@#{name} ||= _#{name}
|
@_#{name} ||= _#{name}
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
|
@ -57,6 +57,7 @@ module TestGenerationPrefix
|
||||||
get "/polymorphic_path_for_engine", :to => "outside_engine_generating#polymorphic_path_for_engine"
|
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 "/polymorphic_with_url_for", :to => "outside_engine_generating#polymorphic_with_url_for"
|
||||||
get "/conflicting_url", :to => "outside_engine_generating#conflicting"
|
get "/conflicting_url", :to => "outside_engine_generating#conflicting"
|
||||||
|
get "/ivar_usage", :to => "outside_engine_generating#ivar_usage"
|
||||||
root :to => "outside_engine_generating#index"
|
root :to => "outside_engine_generating#index"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -125,6 +126,11 @@ module TestGenerationPrefix
|
||||||
def conflicting
|
def conflicting
|
||||||
render :text => "application"
|
render :text => "application"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ivar_usage
|
||||||
|
@blog_engine = "Not the engine route helper"
|
||||||
|
render :text => blog_engine.post_path(:id => 1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EngineObject
|
class EngineObject
|
||||||
|
@ -203,6 +209,11 @@ module TestGenerationPrefix
|
||||||
assert_equal "http://example.org/awesome/blog/posts/1", last_response.body
|
assert_equal "http://example.org/awesome/blog/posts/1", last_response.body
|
||||||
end
|
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
|
# Inside any Object
|
||||||
test "[OBJECT] proxy route should override respond_to?() as expected" do
|
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
|
assert_respond_to blog_engine, :named_helper_that_should_be_invoked_only_in_respond_to_test_path
|
||||||
|
|
Loading…
Reference in a new issue