aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test/application/initializers/frameworks_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2010-11-18 00:06:03 +0100
committerJosé Valim <jose.valim@gmail.com>2010-11-18 00:20:57 +0100
commit250fb3f6c297e1f0bdc80a44ae6ac77c04cd9c85 (patch)
tree26501df142c4c458f64cec56d993f63c5863f997 /railties/test/application/initializers/frameworks_test.rb
parent4d35f8b6615d31fbed4806ee3c260e24447f435b (diff)
downloadrails-250fb3f6c297e1f0bdc80a44ae6ac77c04cd9c85.tar.gz
rails-250fb3f6c297e1f0bdc80a44ae6ac77c04cd9c85.tar.bz2
rails-250fb3f6c297e1f0bdc80a44ae6ac77c04cd9c85.zip
Add config.action_controller.include_all_helpers, by default it is set to true.
In older rails versions there was a way to use only helpers from helper file corresponding to current controller and you could also include all helpers by saying 'helper :all' in controller. This config allows to return to older behavior by setting it to false.
Diffstat (limited to 'railties/test/application/initializers/frameworks_test.rb')
-rw-r--r--railties/test/application/initializers/frameworks_test.rb60
1 files changed, 60 insertions, 0 deletions
diff --git a/railties/test/application/initializers/frameworks_test.rb b/railties/test/application/initializers/frameworks_test.rb
index 6970ea7b7a..475091f789 100644
--- a/railties/test/application/initializers/frameworks_test.rb
+++ b/railties/test/application/initializers/frameworks_test.rb
@@ -65,6 +65,66 @@ module ApplicationTests
assert_equal ["notify"], Foo.action_methods
end
+ test "allows to not load all helpers for controllers" do
+ add_to_config "config.action_controller.include_all_helpers = false"
+
+ app_file "app/controllers/application_controller.rb", <<-RUBY
+ class ApplicationController < ActionController::Base
+ end
+ RUBY
+
+ app_file "app/controllers/foo_controller.rb", <<-RUBY
+ class FooController < ApplicationController
+ def included_helpers
+ render :inline => "<%= from_app_helper -%> <%= from_foo_helper %>"
+ end
+
+ def not_included_helper
+ render :inline => "<%= respond_to?(:from_bar_helper) -%>"
+ end
+ end
+ RUBY
+
+ app_file "app/helpers/application_helper.rb", <<-RUBY
+ module ApplicationHelper
+ def from_app_helper
+ "from_app_helper"
+ end
+ end
+ RUBY
+
+ app_file "app/helpers/foo_helper.rb", <<-RUBY
+ module FooHelper
+ def from_foo_helper
+ "from_foo_helper"
+ end
+ end
+ RUBY
+
+ app_file "app/helpers/bar_helper.rb", <<-RUBY
+ module BarHelper
+ def from_bar_helper
+ "from_bar_helper"
+ end
+ end
+ RUBY
+
+ app_file "config/routes.rb", <<-RUBY
+ AppTemplate::Application.routes.draw do
+ match "/:controller(/:action)"
+ end
+ RUBY
+
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get "/foo/included_helpers"
+ assert_equal "from_app_helper from_foo_helper", last_response.body
+
+ get "/foo/not_included_helper"
+ assert_equal "false", last_response.body
+ end
+
# AD
test "action_dispatch extensions are applied to ActionDispatch" do
add_to_config "config.action_dispatch.tld_length = 2"