aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-09-28 17:57:36 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-09-28 18:00:26 -0700
commit6f6a589d4b564f5db78735ad0c7225c22ced57ac (patch)
tree402a661bd4dac4b2271d67214fcb8a5cb2530654 /railties/test
parent8ffc2e3b8de38c485fa24820208b40920dad7ae3 (diff)
downloadrails-6f6a589d4b564f5db78735ad0c7225c22ced57ac.tar.gz
rails-6f6a589d4b564f5db78735ad0c7225c22ced57ac.tar.bz2
rails-6f6a589d4b564f5db78735ad0c7225c22ced57ac.zip
Create the application object from config/environment.rb
This is preliminary and not necessarily reflective of the full plan.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/load_test.rb51
1 files changed, 15 insertions, 36 deletions
diff --git a/railties/test/application/load_test.rb b/railties/test/application/load_test.rb
index 47e425a824..f2041d54c2 100644
--- a/railties/test/application/load_test.rb
+++ b/railties/test/application/load_test.rb
@@ -6,6 +6,10 @@ module ApplicationTests
class LoadTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
+ def rackup
+ ActionDispatch::Utils.parse_config("#{app_path}/config.ru")
+ end
+
def setup
build_app
end
@@ -14,48 +18,23 @@ module ApplicationTests
assert File.exist?(app_path("config"))
end
- test "running Rails::Application.load on the path returns a (vaguely) useful application" do
- app_file "config.ru", <<-CONFIG
- require File.dirname(__FILE__) + '/config/environment'
- run ActionController::Dispatcher.new
- CONFIG
-
- @app = ActionDispatch::Utils.parse_config("#{app_path}/config.ru")
+ test "config.ru can be racked up" do
+ @app = rackup
assert_welcome get("/")
end
- test "config.ru is used" do
- app_file "config.ru", <<-CONFIG
- class MyMiddleware
- def initialize(app)
- @app = app
- end
-
- def call(env)
- status, headers, body = @app.call(env)
- headers["Config-Ru-Test"] = "TESTING"
- [status, headers, body]
- end
- end
-
- use MyMiddleware
- run proc {|env| [200, {"Content-Type" => "text/html"}, ["VICTORY"]] }
- CONFIG
-
- @app = ActionDispatch::Utils.parse_config("#{app_path}/config.ru")
-
- assert_body "VICTORY", get("/omg")
- assert_header "Config-Ru-Test", "TESTING", get("/omg")
+ test "Rails.application is available after config.ru has been racked up" do
+ rackup
+ assert Rails.application.is_a?(Rails::Application)
end
- test "arbitrary.rb can be used as a config" do
- app_file "myapp.rb", <<-CONFIG
- Myapp = proc {|env| [200, {"Content-Type" => "text/html"}, ["OMG ROBOTS"]] }
- CONFIG
-
- @app = ActionDispatch::Utils.parse_config("#{app_path}/myapp.rb")
+ test "class_evaling config/environment.rb returns the application object" do
+ assert Rails::Application.load("#{app_path}/config/environment.rb").is_a?(Rails::Application)
+ end
- assert_body "OMG ROBOTS", get("/omg")
+ test "the config object is available on the application object" do
+ rackup
+ assert_equal 'UTC', Rails.application.config.time_zone
end
end
end