aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-10-16 16:36:52 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-10-16 16:36:52 +0000
commita2172e75f589f038ed10806e9a32be99d4d69f89 (patch)
tree3a891678b3fbbcea6a7dc285b1a96f973733c64f
parentf575757ca47f2bbce9866e2a1b1f23b629352b92 (diff)
downloadrails-a2172e75f589f038ed10806e9a32be99d4d69f89.tar.gz
rails-a2172e75f589f038ed10806e9a32be99d4d69f89.tar.bz2
rails-a2172e75f589f038ed10806e9a32be99d4d69f89.zip
Dispatcher: fix that to_prepare should only run once in production. Closes #9889.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7944 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--actionpack/CHANGELOG2
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb3
-rw-r--r--actionpack/test/controller/dispatcher_test.rb8
3 files changed, 12 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index f1861e6200..0eab355dd4 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Dispatcher: fix that to_prepare should only run once in production. #9889 [Nathaniel Talbott]
+
* Memcached sessions: add session data on initialization; don't silently discard exceptions; add unit tests. #9823 [kamk]
* error_messages_for also takes :message and :header_message options which defaults to the old "There were problems with the following fields:" and "<count> errors prohibited this <object_name> from being saved". #8270 [rmm5t, zach-inglis-lt3]
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index 65f763ca01..df63e0c992 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -91,7 +91,8 @@ module ActionController
cattr_accessor :callbacks
self.callbacks = Hash.new { |h, k| h[k] = [] }
- attr_accessor_with_default :unprepared, true
+ cattr_accessor :unprepared
+ self.unprepared = true
before_dispatch :reload_application
diff --git a/actionpack/test/controller/dispatcher_test.rb b/actionpack/test/controller/dispatcher_test.rb
index 75b99c4d92..ec937ebfd2 100644
--- a/actionpack/test/controller/dispatcher_test.rb
+++ b/actionpack/test/controller/dispatcher_test.rb
@@ -96,6 +96,14 @@ class DispatcherTest < Test::Unit::TestCase
assert_equal nil, b
end
+ def test_to_prepare_only_runs_once_if_not_loading_dependencies
+ Dependencies.stubs(:load?).returns(false)
+ called = 0
+ Dispatcher.to_prepare(:unprepared_test) { called += 1 }
+ 2.times { dispatch }
+ assert_equal 1, called
+ end
+
private
def dispatch(output = @output)
controller = mock