Merge pull request #47818 from RubyElders/only-local-autocomplete

Enable IRB autocomplete only in Rails.env.local? environment.
This commit is contained in:
Rafael Mendonça França 2023-03-30 15:19:47 -04:00 committed by GitHub
commit aa3787ca10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -37,7 +37,7 @@ module Rails
IRB::WorkSpace.prepend(BacktraceCleaner)
if Rails.env.production?
if !Rails.env.local?
ENV["IRB_USE_AUTOCOMPLETE"] ||= "false"
end

View File

@ -58,12 +58,13 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
assert_equal "IRB", Rails::Console.new(app).console.name
end
def test_console_disables_IRB_auto_completion_in_production
def test_console_disables_IRB_auto_completion_in_non_local
original_use_autocomplete = ENV["IRB_USE_AUTOCOMPLETE"]
ENV["IRB_USE_AUTOCOMPLETE"] = nil
with_rack_env "production" do
app = build_app(nil)
assert_not_predicate Rails.env, :local?
assert_equal "IRB", Rails::Console.new(app).console.name
assert_equal "false", ENV["IRB_USE_AUTOCOMPLETE"]
end
@ -84,12 +85,13 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
ENV["IRB_USE_AUTOCOMPLETE"] = original_use_autocomplete
end
def test_console_doesnt_disable_IRB_auto_completion_in_non_production
def test_console_doesnt_disable_IRB_auto_completion_in_local
original_use_autocomplete = ENV["IRB_USE_AUTOCOMPLETE"]
ENV["IRB_USE_AUTOCOMPLETE"] = nil
with_rails_env nil do
app = build_app(nil)
assert_predicate Rails.env, :local?
assert_equal "IRB", Rails::Console.new(app).console.name
assert_nil ENV["IRB_USE_AUTOCOMPLETE"]
end