Browse files

Add 'app' accessor to script/console as an instance of Integration::S…

…ession

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3717 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 491554f commit 7056fc6782cba6dacccbba86cb231b58d8f5b4c8 @jamis jamis committed Mar 1, 2006
Showing with 16 additions and 0 deletions.
  1. +2 −0 railties/CHANGELOG
  2. +1 −0 railties/lib/commands/console.rb
  3. +13 −0 railties/lib/console_app.rb
View
2 railties/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add 'app' accessor to script/console as an instance of Integration::Session [Jamis Buck]
+
* Generator::Base#usage takes an optional message argument which defaults to Generator::Base#usage_message. [Jeremy Kemper]
* Remove the extraneous AR::Base.threaded_connections setting from the webrick server. [Jeremy Kemper]
View
1 railties/lib/commands/console.rb
@@ -11,6 +11,7 @@
libs = " -r irb/completion"
libs << " -r #{RAILS_ROOT}/config/environment"
+libs << " -r console_app"
libs << " -r console_sandbox" if options[:sandbox]
ENV['RAILS_ENV'] = ARGV.first || ENV['RAILS_ENV'] || 'development'
View
13 railties/lib/console_app.rb
@@ -0,0 +1,13 @@
+require 'action_controller/integration_test'
+
+# work around the at_exit hook in test/unit, which kills IRB
+Test::Unit.run = true
+
+def app(create=false)
+ @app_integration_instance = nil if create
+ unless @app_integration_instance
+ @app_integration_instance = ActionController::Integration::Session.new
+ @app_integration_instance.host! "www.example.test"
+ end
+ @app_integration_instance
+end

0 comments on commit 7056fc6

Please sign in to comment.