From b27105252bce6a69f6d57c05d4ea28d20e84f8ae Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Sat, 23 Mar 2019 16:47:26 +0900 Subject: Add config.disable_sandbox option to Rails console A long-running `rails console --sandbox` could cause a database server to become out-of-memory as it's holding on to changes that happen on the database. Given that it's common for Ruby on Rails application with huge traffic to have separate write database and read database, we should allow the developers to disable this sandbox option to prevent someone from accidentally causing the Denial-of-Service on their server. --- railties/test/application/configuration_test.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'railties/test/application/configuration_test.rb') diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index e34c075a1c..b8e167b488 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -2476,6 +2476,22 @@ module ApplicationTests assert_includes Rails.application.config.hosts, ".localhost" end + test "disable_sandbox is false by default" do + app "development" + + assert_equal false, Rails.configuration.disable_sandbox + end + + test "disable_sandbox can be overridden" do + add_to_config <<-RUBY + config.disable_sandbox = true + RUBY + + app "development" + + assert Rails.configuration.disable_sandbox + end + private def force_lazy_load_hooks yield # Tasty clarifying sugar, homie! We only need to reference a constant to load it. -- cgit v1.2.3