Skip to content

Commit a7c6e9e

Browse files
authored
Merge pull request rails#54380 from Edouard-chin/ec-load-routes-console
Load the routes in the console when calling the `app` IRB helper
2 parents 20f6edf + c175d8e commit a7c6e9e

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

railties/lib/rails/commands/console/irb_console.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class NewSession < RailsHelperBase
3131

3232
def execute(*)
3333
app = Rails.application
34+
app.reload_routes_unless_loaded
3435
session = ActionDispatch::Integration::Session.new(app)
3536

3637
# This makes app.url_for and app.foo_path available in the console

railties/test/application/console_test.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ def test_app_helper_method
186186
write_prompt "app.foo_path", "/foo"
187187
end
188188

189+
def test_app_routes_are_loaded
190+
app_file "config/routes.rb", <<-RUBY
191+
Rails.application.routes.draw do
192+
get 'foo', to: 'foo#index'
193+
end
194+
RUBY
195+
196+
spawn_console("-e development")
197+
198+
write_prompt "app.methods.grep(/foo_path/)", "[:foo_path]"
199+
end
200+
189201
def test_reload_command_fires_preparation_and_cleanup_callbacks
190202
options = "-e development"
191203
spawn_console(options)

0 commit comments

Comments
 (0)