Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
  • Loading branch information
drogus committed Jun 1, 2012
1 parent 5b6b0df commit f550d4d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions 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*


Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_view/test_case.rb
Expand Up @@ -229,7 +229,8 @@ def _routes

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
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/abstract_unit.rb
Expand Up @@ -286,6 +286,7 @@ class Base
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

Expand Down
19 changes: 19 additions & 0 deletions actionpack/test/template/test_case_test.rb
Expand Up @@ -222,6 +222,25 @@ class ATestHelperTest < ActionView::TestCase
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 }
Expand Down

0 comments on commit f550d4d

Please sign in to comment.