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