Skip to content

Commit

Permalink
Merge pull request #51732 from Shopify/fix-rails-console-prompt
Browse files Browse the repository at this point in the history
Avoid setting fixed app name in console prompt
  • Loading branch information
carlosantoniodasilva committed May 14, 2024
2 parents d60890c + beba30b commit 5e3611e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion railties/lib/rails/commands/console/irb_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ def start

env = colorized_env
app_name = @app.class.module_parent_name.underscore.dasherize
prompt_prefix = "#{app_name}(#{env})"
prompt_prefix = "%N(#{env})"
IRB.conf[:IRB_NAME] = app_name

IRB.conf[:PROMPT][:RAILS_PROMPT] = {
PROMPT_I: "#{prompt_prefix}> ",
Expand Down
16 changes: 16 additions & 0 deletions railties/test/application/console_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,22 @@ def test_sandbox_by_default_with_development_environment
@primary.puts "quit"
end

def test_prompt_is_properly_set
options = "-e test"
spawn_console(options)

write_prompt "a = 1", "a = 1", prompt: "app-template(test)>"
end

def test_prompt_allows_changing_irb_name
options = "-e test"
spawn_console(options)

write_prompt "conf.irb_name = 'foo'"
write_prompt "a = 1", "a = 1", prompt: "foo(test)>"
@primary.puts "quit"
end

def test_environment_option_and_irb_option
options = "-e test -- --verbose"
spawn_console(options)
Expand Down

0 comments on commit 5e3611e

Please sign in to comment.