blob: 5c3d35fb16e4177bf70c88b048354c22e95a5666 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
require "isolation/abstract_unit"
# require "rails"
# require 'action_dispatch'
module ApplicationTests
class LoadTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def rackup
config = "#{app_path}/config.ru"
# Copied from ActionDispatch::Utils.parse_config
# ActionDispatch is not necessarily available at this point.
require 'rack'
if config =~ /\.ru$/
cfgfile = ::File.read(config)
if cfgfile[/^#\\(.*)/]
opts.parse! $1.split(/\s+/)
end
inner_app = eval "Rack::Builder.new {( " + cfgfile + "\n )}.to_app",
nil, config
else
require config
inner_app = Object.const_get(::File.basename(config, '.rb').capitalize)
end
end
def setup
build_app
boot_rails
end
test "rails app is present" do
assert File.exist?(app_path("config"))
end
test "config.ru can be racked up" do
@app = rackup
assert_welcome get("/")
end
test "Rails.application is available after config.ru has been racked up" do
rackup
assert Rails.application.new < Rails::Application
end
# Passenger still uses AC::Dispatcher, so we need to
# keep it working for now
test "deprecated ActionController::Dispatcher still works" do
rackup
assert ActionController::Dispatcher.new < Rails::Application
end
test "the config object is available on the application object" do
rackup
assert_equal 'UTC', Rails.application.config.time_zone
end
end
end
|