aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2012-03-15 08:48:38 +0100
committerJosé Valim <jose.valim@gmail.com>2012-03-15 08:48:38 +0100
commitfbc9d0f44f090a9873834f4966760c3e80682559 (patch)
tree70a3a93f8af3653b0ed8557b9c385fc3f105bf18 /railties
parent5b94e73d1a604c59ecd1ebb9441d60ea864fa1b5 (diff)
downloadrails-fbc9d0f44f090a9873834f4966760c3e80682559.tar.gz
rails-fbc9d0f44f090a9873834f4966760c3e80682559.tar.bz2
rails-fbc9d0f44f090a9873834f4966760c3e80682559.zip
Simplify helpers handling. Ensure Metal can run AC hooks.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/engine.rb2
-rw-r--r--railties/test/application/loading_test.rb31
2 files changed, 31 insertions, 2 deletions
diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb
index 9629ac55c2..131d6e5711 100644
--- a/railties/lib/rails/engine.rb
+++ b/railties/lib/rails/engine.rb
@@ -561,7 +561,7 @@ module Rails
initializer :add_view_paths do
views = paths["app/views"].existent
unless views.empty?
- ActiveSupport.on_load(:action_controller){ prepend_view_path(views) }
+ ActiveSupport.on_load(:action_controller){ prepend_view_path(views) if respond_to?(:prepend_view_path) }
ActiveSupport.on_load(:action_mailer){ prepend_view_path(views) }
end
end
diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb
index 0354c08067..9302443c98 100644
--- a/railties/test/application/loading_test.rb
+++ b/railties/test/application/loading_test.rb
@@ -95,7 +95,7 @@ class LoadingTest < ActiveSupport::TestCase
assert_equal [ActiveRecord::SchemaMigration], ActiveRecord::Base.descendants
end
- test "initialize_cant_be_called_twice" do
+ test "initialize cant be called twice" do
require "#{app_path}/config/environment"
assert_raise(RuntimeError) { ::AppTemplate::Application.initialize! }
end
@@ -256,6 +256,35 @@ class LoadingTest < ActiveSupport::TestCase
assert_equal "BODY", last_response.body
end
+ test "AC load hooks can be used with metal" do
+ app_file "app/controllers/omg_controller.rb", <<-RUBY
+ begin
+ class OmgController < ActionController::Metal
+ ActiveSupport.run_load_hooks(:action_controller, self)
+ def show
+ self.response_body = ["OK"]
+ end
+ end
+ rescue => e
+ puts "Error loading metal: \#{e.class} \#{e.message}"
+ end
+ RUBY
+
+ app_file "config/routes.rb", <<-RUBY
+ AppTemplate::Application.routes.draw do
+ match "/:controller(/:action)"
+ end
+ RUBY
+
+ require "#{rails_root}/config/environment"
+
+ require 'rack/test'
+ extend Rack::Test::Methods
+
+ get '/omg/show'
+ assert_equal 'OK', last_response.body
+ end
+
protected
def setup_ar!