From 7056fc6782cba6dacccbba86cb231b58d8f5b4c8 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Wed, 1 Mar 2006 15:52:40 +0000 Subject: Add 'app' accessor to script/console as an instance of Integration::Session git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3717 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- railties/CHANGELOG | 2 ++ railties/lib/commands/console.rb | 1 + railties/lib/console_app.rb | 13 +++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 railties/lib/console_app.rb diff --git a/railties/CHANGELOG b/railties/CHANGELOG index 8b9fdddda7..f32e60ce8c 100644 --- a/railties/CHANGELOG +++ b/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] diff --git a/railties/lib/commands/console.rb b/railties/lib/commands/console.rb index 696272eba6..3ea1107445 100644 --- a/railties/lib/commands/console.rb +++ b/railties/lib/commands/console.rb @@ -11,6 +11,7 @@ end 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' diff --git a/railties/lib/console_app.rb b/railties/lib/console_app.rb new file mode 100644 index 0000000000..f943d5ab49 --- /dev/null +++ b/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 \ No newline at end of file -- cgit v1.2.3