diff options
author | Jamis Buck <jamis@37signals.com> | 2005-06-24 11:57:40 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2005-06-24 11:57:40 +0000 |
commit | 0d8455c1a285c6d58fc7a3180f5c72d9c3c42fa1 (patch) | |
tree | 7568f688004d2743071e3a2a40c31c71160b6bad | |
parent | 0c3298f2f205dac516216a1d48dcc21112312c2d (diff) | |
download | rails-0d8455c1a285c6d58fc7a3180f5c72d9c3c42fa1.tar.gz rails-0d8455c1a285c6d58fc7a3180f5c72d9c3c42fa1.tar.bz2 rails-0d8455c1a285c6d58fc7a3180f5c72d9c3c42fa1.zip |
ActionMailer::Base subclasses are reloaded with other rails components #1262
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1492 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | railties/CHANGELOG | 2 | ||||
-rw-r--r-- | railties/lib/dispatcher.rb | 1 | ||||
-rw-r--r-- | railties/test/dispatcher_test.rb | 63 |
3 files changed, 66 insertions, 0 deletions
diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 62e7fdcaae..58a69dbef7 100644 --- a/railties/CHANGELOG +++ b/railties/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* ActionMailer::Base subclasses are reloaded with the other rails components #1262 + * Made the WEBrick adapter not use a mutex around action performance if ActionController::Base.allow_concurrency is true (default is false) * Fixed that mailer generator generated fixtures/plural while units expected fixtures/singular #1457 [Scott Barron] diff --git a/railties/lib/dispatcher.rb b/railties/lib/dispatcher.rb index b2f9650e65..1455168ba9 100644 --- a/railties/lib/dispatcher.rb +++ b/railties/lib/dispatcher.rb @@ -49,6 +49,7 @@ class Dispatcher Controllers.clear! Dependencies.clear Dependencies.remove_subclasses_for(ActiveRecord::Base, ActiveRecord::Observer, ActionController::Base) + Dependencies.remove_subclasses_for(ActionMailer::Base) if defined?(ActionMailer::Base) end Breakpoint.deactivate_drb if defined?(BREAKPOINT_SERVER_PORT) diff --git a/railties/test/dispatcher_test.rb b/railties/test/dispatcher_test.rb new file mode 100644 index 0000000000..ba41b93b24 --- /dev/null +++ b/railties/test/dispatcher_test.rb @@ -0,0 +1,63 @@ +$:.unshift File.dirname(__FILE__) + "/../lib" +$:.unshift File.dirname(__FILE__) + "/../../actionpack/lib" +$:.unshift File.dirname(__FILE__) + "/../../actionmailer/lib" + +require 'test/unit' +require 'stringio' +require 'cgi' + +require 'dispatcher' +require 'action_controller' +require 'action_mailer' + +ACTION_MAILER_DEF = <<AM + class DispatcherTestMailer < ActionMailer::Base + end +AM + +ACTION_CONTROLLER_DEF = <<AM + class DispatcherControllerTest < ActionController::Base + end +AM + +class DispatcherTest < Test::Unit::TestCase + def setup + @output = StringIO.new + ENV['REQUEST_METHOD'] = "GET" + setup_minimal_environment + end + + def teardown + ENV['REQUEST_METHOD'] = nil + teardown_minimal_environment + end + + def test_ac_subclasses_cleared_on_reset + Object.class_eval(ACTION_CONTROLLER_DEF) + assert_equal 1, ActionController::Base.subclasses.length + Dispatcher.dispatch(CGI.new, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output) + + GC.start # force the subclass to be collected + assert_equal 0, ActionController::Base.subclasses.length + end + + def test_am_subclasses_cleared_on_reset + Object.class_eval(ACTION_MAILER_DEF) + assert_equal 1, ActionMailer::Base.subclasses.length + Dispatcher.dispatch(CGI.new, ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS, @output) + + GC.start # force the subclass to be collected + assert_equal 0, ActionMailer::Base.subclasses.length + end + + private + + def setup_minimal_environment + value = Dependencies::LoadingModule.root + Object.const_set("Controllers", value) + end + + def teardown_minimal_environment + Object.send(:remove_const, "Controllers") + end +end |