blob: 1f04eb9f750b6762d41b8e02a2fd6e6e91de1207 (
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
require "isolation/abstract_unit"
module ApplicationTests
class InitializerTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def new_app
File.expand_path("#{app_path}/../new_app")
end
def copy_app
FileUtils.cp_r(app_path, new_app)
end
def setup
FileUtils.rm_rf(new_app) if File.directory?(new_app)
build_app
boot_rails
end
test "the application root is set correctly" do
require "#{app_path}/config/environment"
assert_equal Pathname.new(app_path), Rails.application.root
end
test "the application root can be set" do
copy_app
add_to_config <<-RUBY
config.root = '#{new_app}'
RUBY
use_frameworks []
require "#{app_path}/config/environment"
assert_equal Pathname.new(new_app), Rails.application.root
end
test "the application root is Dir.pwd if there is no config.ru" do
File.delete("#{app_path}/config.ru")
use_frameworks []
Dir.chdir("#{app_path}") do
require "#{app_path}/config/environment"
assert_equal Pathname.new("#{app_path}"), Rails.application.root
end
end
test "if there's no config.active_support.bare, all of ActiveSupport is required" do
use_frameworks []
require "#{app_path}/config/environment"
assert_nothing_raised { [1,2,3].rand }
end
test "config.active_support.bare does not require all of ActiveSupport" do
add_to_config "config.active_support.bare = true"
use_frameworks []
Dir.chdir("#{app_path}/app") do
require "#{app_path}/config/environment"
assert_raises(NoMethodError) { [1,2,3].rand }
end
end
test "marking the application as threadsafe sets the correct config variables" do
add_to_config <<-RUBY
config.threadsafe!
RUBY
require "#{app_path}/config/application"
assert AppTemplate::Application.config.action_controller.allow_concurrency
end
test "the application can be marked as threadsafe when there are no frameworks" do
FileUtils.rm_rf("#{app_path}/config/environments")
add_to_config <<-RUBY
config.threadsafe!
RUBY
use_frameworks []
assert_nothing_raised do
require "#{app_path}/config/application"
end
end
test "Frameworks are not preloaded by default" do
require "#{app_path}/config/environment"
assert ActionController.autoload?(:RecordIdentifier)
end
test "frameworks are preloaded with config.preload_frameworks is set" do
add_to_config <<-RUBY
config.preload_frameworks = true
RUBY
require "#{app_path}/config/environment"
assert !ActionController.autoload?(:RecordIdentifier)
end
test "runtime error is raised if config.frameworks= is used" do
add_to_config "config.frameworks = []"
assert_raises RuntimeError do
require "#{app_path}/config/environment"
end
end
test "runtime error is raised if config.frameworks is used" do
add_to_config "config.frameworks -= []"
assert_raises RuntimeError do
require "#{app_path}/config/environment"
end
end
end
end
|