diff options
-rw-r--r-- | actionpack/test/controller/url_for_test.rb | 12 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/deep_dup.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails.rb | 6 | ||||
-rw-r--r-- | railties/lib/rails/application.rb | 4 | ||||
-rw-r--r-- | railties/test/application/loading_test.rb | 10 |
5 files changed, 28 insertions, 7 deletions
diff --git a/actionpack/test/controller/url_for_test.rb b/actionpack/test/controller/url_for_test.rb index 288efbf7c3..aa233d6135 100644 --- a/actionpack/test/controller/url_for_test.rb +++ b/actionpack/test/controller/url_for_test.rb @@ -16,6 +16,10 @@ module AbstractController W.default_url_options[:host] = 'www.basecamphq.com' end + def add_port! + W.default_url_options[:port] = 3000 + end + def add_numeric_host! W.default_url_options[:host] = '127.0.0.1' end @@ -121,6 +125,14 @@ module AbstractController ) end + def test_default_port + add_host! + add_port! + assert_equal('http://www.basecamphq.com:3000/c/a/i', + W.new.url_for(:controller => 'c', :action => 'a', :id => 'i') + ) + end + def test_protocol add_host! assert_equal('https://www.basecamphq.com/c/a/i', diff --git a/activesupport/lib/active_support/core_ext/hash/deep_dup.rb b/activesupport/lib/active_support/core_ext/hash/deep_dup.rb index 447142605c..9ab179c566 100644 --- a/activesupport/lib/active_support/core_ext/hash/deep_dup.rb +++ b/activesupport/lib/active_support/core_ext/hash/deep_dup.rb @@ -3,8 +3,7 @@ class Hash def deep_dup duplicate = self.dup duplicate.each_pair do |k,v| - tv = duplicate[k] - duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_dup : v + duplicate[k] = v.is_a?(Hash) ? v.deep_dup : v end duplicate end diff --git a/railties/lib/rails.rb b/railties/lib/rails.rb index 77a09507a8..6b431d3ee3 100644 --- a/railties/lib/rails.rb +++ b/railties/lib/rails.rb @@ -42,11 +42,7 @@ module Rails end def initialized? - @@initialized || false - end - - def initialized=(initialized) - @@initialized ||= initialized + application.initialized? end def logger diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index d7b8350963..fcb981bb9a 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -134,6 +134,10 @@ module Rails self end + def initialized? + @initialized + end + # Load the application and its railties tasks and invoke the registered hooks. # Check <tt>Rails::Railtie.rake_tasks</tt> for more info. def load_tasks(app=self) diff --git a/railties/test/application/loading_test.rb b/railties/test/application/loading_test.rb index 9302443c98..92951e1676 100644 --- a/railties/test/application/loading_test.rb +++ b/railties/test/application/loading_test.rb @@ -285,6 +285,16 @@ class LoadingTest < ActiveSupport::TestCase assert_equal 'OK', last_response.body end + def test_initialize_can_be_called_at_any_time + require "#{app_path}/config/application" + + assert !Rails.initialized? + assert !AppTemplate::Application.initialized? + Rails.initialize! + assert Rails.initialized? + assert AppTemplate::Application.initialized? + end + protected def setup_ar! |