blob: 84bd6ed16bd2d8b5c3edf4f45db8e92454a066df (
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
|
require "isolation/abstract_unit"
module RailtiesTest
class FrameworkExtensionTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
FileUtils.rm_rf("#{app_path}/config/environments")
require "rails/all"
end
test "rake_tasks block is executed when MyApp.load_tasks is called" do
$ran_block = false
class MyTie < Rails::Railtie
rake_tasks do
$ran_block = true
end
end
require "#{app_path}/config/environment"
assert !$ran_block
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
AppTemplate::Application.load_tasks
assert $ran_block
end
test "generators block is executed when MyApp.load_generators is called" do
$ran_block = false
class MyTie < Rails::Railtie
generators do
$ran_block = true
end
end
require "#{app_path}/config/environment"
assert !$ran_block
AppTemplate::Application.load_generators
assert $ran_block
end
end
class ActiveRecordExtensionTest < Test::Unit::TestCase
include ActiveSupport::Testing::Isolation
def setup
build_app
boot_rails
FileUtils.rm_rf("#{app_path}/config/environments")
end
test "active_record extensions are applied to ActiveRecord" do
add_to_config "config.active_record.table_name_prefix = 'tbl_'"
require "#{app_path}/config/environment"
assert_equal 'tbl_', ActiveRecord::Base.table_name_prefix
end
end
end
|