From 6f6a589d4b564f5db78735ad0c7225c22ced57ac Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Mon, 28 Sep 2009 17:57:36 -0700 Subject: Create the application object from config/environment.rb This is preliminary and not necessarily reflective of the full plan. --- railties/test/application/load_test.rb | 51 ++++++++++------------------------ 1 file changed, 15 insertions(+), 36 deletions(-) (limited to 'railties/test') 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 -- cgit v1.2.3