aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2015-06-06 00:07:45 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2015-06-06 00:07:45 -0300
commit847a5ea7dbb723728cda0bda5d5d744ba2c7118b (patch)
treedb70e1235f14add48f59dde10daf394521e60138
parenteb460725f4a4105b1765a2f917d25b9e709fceb7 (diff)
parent4fded7c069c4fc0ea0909ebc86a624bce25eb3f5 (diff)
downloadrails-847a5ea7dbb723728cda0bda5d5d744ba2c7118b.tar.gz
rails-847a5ea7dbb723728cda0bda5d5d744ba2c7118b.tar.bz2
rails-847a5ea7dbb723728cda0bda5d5d744ba2c7118b.zip
Merge pull request #20444 from y-yagi/can_use_path_helper_method_in_console
modify console of app method in that can use the path helpers
-rw-r--r--railties/lib/rails/console/app.rb5
-rw-r--r--railties/test/application/console_test.rb12
2 files changed, 17 insertions, 0 deletions
diff --git a/railties/lib/rails/console/app.rb b/railties/lib/rails/console/app.rb
index 2a69c26deb..ac5836a588 100644
--- a/railties/lib/rails/console/app.rb
+++ b/railties/lib/rails/console/app.rb
@@ -18,6 +18,11 @@ module Rails
app = Rails.application
session = ActionDispatch::Integration::Session.new(app)
yield session if block_given?
+
+ # This makes app.url_for and app.foo_path available in the console
+ session.extend(app.routes.url_helpers)
+ session.extend(app.routes.mounted_helpers)
+
session
end
diff --git a/railties/test/application/console_test.rb b/railties/test/application/console_test.rb
index 31bc003dcb..7bf123d12b 100644
--- a/railties/test/application/console_test.rb
+++ b/railties/test/application/console_test.rb
@@ -29,6 +29,18 @@ class ConsoleTest < ActiveSupport::TestCase
assert_instance_of ActionDispatch::Integration::Session, console_session
end
+ def test_app_can_access_path_helper_method
+ app_file 'config/routes.rb', <<-RUBY
+ Rails.application.routes.draw do
+ get 'foo', to: 'foo#index'
+ end
+ RUBY
+
+ load_environment
+ console_session = irb_context.app
+ assert_equal '/foo', console_session.foo_path
+ end
+
def test_new_session_should_return_integration_session
load_environment
session = irb_context.new_session