aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
Diffstat (limited to 'railties')
-rw-r--r--railties/builtin/rails_info/rails/info.rb4
-rw-r--r--railties/lib/rails/bootstrap.rb8
-rw-r--r--railties/lib/rails/deprecation.rb34
-rw-r--r--railties/lib/rails/tasks/misc.rake1
-rw-r--r--railties/test/generators/generators_test_helper.rb2
-rw-r--r--railties/test/initializer/path_test.rb8
6 files changed, 39 insertions, 18 deletions
diff --git a/railties/builtin/rails_info/rails/info.rb b/railties/builtin/rails_info/rails/info.rb
index c3784cff32..269fe488b0 100644
--- a/railties/builtin/rails_info/rails/info.rb
+++ b/railties/builtin/rails_info/rails/info.rb
@@ -129,12 +129,12 @@ module Rails
# The current Rails environment (development, test, or production).
property 'Environment' do
- RAILS_ENV
+ Rails.env
end
# The name of the database adapter for the current environment.
property 'Database adapter' do
- ActiveRecord::Base.configurations[RAILS_ENV]['adapter']
+ ActiveRecord::Base.configurations[Rails.env]['adapter']
end
property 'Database schema version' do
diff --git a/railties/lib/rails/bootstrap.rb b/railties/lib/rails/bootstrap.rb
index 99a5ddeb8a..5d9165bf9a 100644
--- a/railties/lib/rails/bootstrap.rb
+++ b/railties/lib/rails/bootstrap.rb
@@ -38,11 +38,6 @@ module Rails
config.load_once_paths.freeze
end
- # TODO: Wrap in deprecation warning, everyone should be using Rails.env now
- initializer :set_rails_env do
- silence_warnings { Object.const_set "RAILS_ENV", Rails.env }
- end
-
# Create tmp directories
initializer :ensure_tmp_directories_exist do
%w(cache pids sessions sockets).each do |dir_to_make|
@@ -83,9 +78,6 @@ module Rails
)
logger
end
-
- # TODO: Wrap it in a deprecation proxy
- silence_warnings { Object.const_set "RAILS_DEFAULT_LOGGER", Rails.logger }
end
# Sets the logger for Active Record, Action Controller, and Action Mailer
diff --git a/railties/lib/rails/deprecation.rb b/railties/lib/rails/deprecation.rb
index 155166a113..43f08d13df 100644
--- a/railties/lib/rails/deprecation.rb
+++ b/railties/lib/rails/deprecation.rb
@@ -6,8 +6,8 @@ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
Rails.root
end
- def replace(val)
- puts OMG
+ def replace(*args)
+ warn(caller, :replace, *args)
end
def warn(callstack, called, args)
@@ -15,3 +15,33 @@ RAILS_ROOT = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
ActiveSupport::Deprecation.warn(msg, callstack)
end
end).new
+
+RAILS_ENV = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
+ def target
+ Rails.env
+ end
+
+ def replace(*args)
+ warn(caller, :replace, *args)
+ end
+
+ def warn(callstack, called, args)
+ msg = "RAILS_ENV is deprecated! Use Rails.env instead."
+ ActiveSupport::Deprecation.warn(msg, callstack)
+ end
+end).new
+
+RAILS_DEFAULT_LOGGER = (Class.new(ActiveSupport::Deprecation::DeprecationProxy) do
+ def target
+ Rails.logger
+ end
+
+ def replace(*args)
+ warn(caller, :replace, *args)
+ end
+
+ def warn(callstack, called, args)
+ msg = "RAILS_DEFAULT_LOGGER is deprecated! Use Rails.logger instead."
+ ActiveSupport::Deprecation.warn(msg, callstack)
+ end
+end).new
diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake
index 9433b3556a..4696f02a98 100644
--- a/railties/lib/rails/tasks/misc.rake
+++ b/railties/lib/rails/tasks/misc.rake
@@ -1,6 +1,7 @@
task :default => :test
task :rails_env do
+ # TODO Do we really need this?
unless defined? RAILS_ENV
RAILS_ENV = ENV['RAILS_ENV'] ||= 'development'
end
diff --git a/railties/test/generators/generators_test_helper.rb b/railties/test/generators/generators_test_helper.rb
index 35567f7929..54953b76c8 100644
--- a/railties/test/generators/generators_test_helper.rb
+++ b/railties/test/generators/generators_test_helper.rb
@@ -1,5 +1,3 @@
-# TODO: Fix this RAILS_ENV stuff
-RAILS_ENV = 'test' unless defined?(RAILS_ENV)
require 'abstract_unit'
module Rails
diff --git a/railties/test/initializer/path_test.rb b/railties/test/initializer/path_test.rb
index bfb1887d11..328dda6d2c 100644
--- a/railties/test/initializer/path_test.rb
+++ b/railties/test/initializer/path_test.rb
@@ -63,7 +63,7 @@ module InitializerTests
end
test "environments has a glob equal to the current environment" do
- assert_equal "#{RAILS_ENV}.rb", @paths.config.environments.glob
+ assert_equal "#{Rails.env}.rb", @paths.config.environments.glob
end
test "load path includes each of the paths in config.paths as long as the directories exist" do
@@ -85,17 +85,17 @@ module InitializerTests
end
test "controller paths include builtin in development mode" do
- RAILS_ENV.replace "development"
+ Rails.env.replace "development"
assert Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
end
test "controller paths does not have builtin_directories in test mode" do
- RAILS_ENV.replace "test"
+ Rails.env.replace "test"
assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
end
test "controller paths does not have builtin_directories in production mode" do
- RAILS_ENV.replace "production"
+ Rails.env.replace "production"
assert !Rails::Configuration.new.paths.app.controllers.paths.any? { |p| p =~ /builtin/ }
end