aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamis Buck <jamis@37signals.com>2006-03-01 15:52:40 +0000
committerJamis Buck <jamis@37signals.com>2006-03-01 15:52:40 +0000
commit7056fc6782cba6dacccbba86cb231b58d8f5b4c8 (patch)
treee95709dd97d30d8775bd237a8cd302c196e020ab
parent491554f6dd8b7f63005b5c7c89c01e6b35f69597 (diff)
downloadrails-7056fc6782cba6dacccbba86cb231b58d8f5b4c8.tar.gz
rails-7056fc6782cba6dacccbba86cb231b58d8f5b4c8.tar.bz2
rails-7056fc6782cba6dacccbba86cb231b58d8f5b4c8.zip
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
-rw-r--r--railties/CHANGELOG2
-rw-r--r--railties/lib/commands/console.rb1
-rw-r--r--railties/lib/console_app.rb13
3 files changed, 16 insertions, 0 deletions
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