aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-06-01 17:42:33 +0200
committerPiotr Sarnacki <drogus@gmail.com>2012-06-01 20:58:19 +0200
commitf550d4db96b406efc91f92a9c8ebdcda7d407bc9 (patch)
tree06e7ddde6f54871b45236e2b6ea64dc5abb5adbc /actionpack
parent5b6b0df8c585326266275b2fb25cfdfce924fe9b (diff)
downloadrails-f550d4db96b406efc91f92a9c8ebdcda7d407bc9.tar.gz
rails-f550d4db96b406efc91f92a9c8ebdcda7d407bc9.tar.bz2
rails-f550d4db96b406efc91f92a9c8ebdcda7d407bc9.zip
Allow to use mounted helpers in ActionView::TestCase
Similarly to 6525002, this allows to use routes helpers for mounted helpers, but this time in ActionView::TestCase
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG.md2
-rw-r--r--actionpack/lib/action_view/test_case.rb3
-rw-r--r--actionpack/test/abstract_unit.rb1
-rw-r--r--actionpack/test/template/test_case_test.rb19
4 files changed, 24 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 5571513186..567e1b8a06 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 3.2.6 (unreleased) ##
+* Allow to use mounted_helpers (helpers for accessing mounted engines) in ActionView::TestCase. *Piotr Sarnacki*
+
* Include mounted_helpers (helpers for accessing mounted engines) in ActionDispatch::IntegrationTest by default. *Piotr Sarnacki*
diff --git a/actionpack/lib/action_view/test_case.rb b/actionpack/lib/action_view/test_case.rb
index 98ce21ce1d..658a503f7f 100644
--- a/actionpack/lib/action_view/test_case.rb
+++ b/actionpack/lib/action_view/test_case.rb
@@ -229,7 +229,8 @@ module ActionView
def method_missing(selector, *args)
if @controller.respond_to?(:_routes) &&
- @controller._routes.named_routes.helpers.include?(selector)
+ ( @controller._routes.named_routes.helpers.include?(selector) ||
+ @controller._routes.mounted_helpers.method_defined?(selector) )
@controller.__send__(selector, *args)
else
super
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index 40ca23a39d..74efcba666 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -286,6 +286,7 @@ module ActionController
include ActionController::Testing
# This stub emulates the Railtie including the URL helpers from a Rails application
include SharedTestRoutes.url_helpers
+ include SharedTestRoutes.mounted_helpers
self.view_paths = FIXTURE_LOAD_PATH
diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb
index a75f1bc981..13a2b7fb6f 100644
--- a/actionpack/test/template/test_case_test.rb
+++ b/actionpack/test/template/test_case_test.rb
@@ -222,6 +222,25 @@ module ActionView
end
end
+ test "is able to use mounted routes" do
+ with_routing do |set|
+ app = Class.new do
+ def self.routes
+ @routes ||= ActionDispatch::Routing::RouteSet.new
+ end
+
+ routes.draw { get "bar", :to => lambda {} }
+
+ def self.call(*)
+ end
+ end
+
+ set.draw { mount app => "/foo", :as => "foo_app" }
+
+ assert_equal '/foo/bar', foo_app.bar_path
+ end
+ end
+
test "named routes can be used from helper included in view" do
with_routing do |set|
set.draw { resources :contents }