Skip to content
This repository
Browse code

Tests pass again

  • Loading branch information...
commit 86596975be45fa9088fba4db99b67518434f3afc 1 parent 07da304
Yehuda Katz authored
4  railties/lib/rails/application.rb
@@ -41,13 +41,13 @@ def call(env)
41 41
       end
42 42
 
43 43
       def new
44  
-        initializers.run
  44
+        run_initializers
45 45
         self
46 46
       end
47 47
     end
48 48
 
49 49
     initializer :initialize_rails do
50  
-      Rails.initializers.run
  50
+      Rails.run_initializers
51 51
     end
52 52
 
53 53
     # Set the <tt>$LOAD_PATH</tt> based on the value of
4  railties/lib/rails/initializable.rb
@@ -15,7 +15,7 @@ def self.extended(klass)
15 15
     class Collection < Array
16 16
       def initialize(klasses)
17 17
         klasses.each do |klass|
18  
-          klass.added_initializers.each do |initializer|
  18
+          (klass.added_initializers || []).each do |initializer|
19 19
             index = if initializer.before
20 20
               index_for(initializer.before)
21 21
             elsif initializer.after
@@ -44,7 +44,7 @@ def index_for(name)
44 44
     #
45 45
     # The #initializers method is set up to return the right list of
46 46
     # initializers for the context in question.
47  
-    def initialize!
  47
+    def run_initializers
48 48
       return if @_initialized
49 49
 
50 50
       initializers.each {|initializer| instance_eval(&initializer.block) }
20  railties/test/initializable_test.rb
@@ -85,29 +85,29 @@ class Basic < ActiveSupport::TestCase
85 85
     include ActiveSupport::Testing::Isolation
86 86
 
87 87
     test "initializers run" do
88  
-      Foo.initialize!
  88
+      Foo.run_initializers
89 89
       assert_equal 1, Foo.foo
90 90
     end
91 91
 
92 92
     test "initializers are inherited" do
93  
-      Bar.initialize!
  93
+      Bar.run_initializers
94 94
       assert_equal [1, 1], [Bar.foo, Bar.bar]
95 95
     end
96 96
 
97 97
     test "initializers only get run once" do
98  
-      Foo.initialize!
99  
-      Foo.initialize!
  98
+      Foo.run_initializers
  99
+      Foo.run_initializers
100 100
       assert_equal 1, Foo.foo
101 101
     end
102 102
 
103 103
     test "running initializers on children does not effect the parent" do
104  
-      Bar.initialize!
  104
+      Bar.run_initializers
105 105
       assert_nil Foo.foo
106 106
       assert_nil Foo.bar
107 107
     end
108 108
 
109 109
     test "initializing with modules" do
110  
-      Word.initialize!
  110
+      Word.run_initializers
111 111
       assert_equal "bird", $word
112 112
     end
113 113
   end
@@ -115,13 +115,13 @@ class Basic < ActiveSupport::TestCase
115 115
   class BeforeAfter < ActiveSupport::TestCase
116 116
     test "running on parent" do
117 117
       $arr = []
118  
-      Parent.initialize!
  118
+      Parent.run_initializers
119 119
       assert_equal [5, 1, 2], $arr
120 120
     end
121 121
 
122 122
     test "running on child" do
123 123
       $arr = []
124  
-      Child.initialize!
  124
+      Child.run_initializers
125 125
       assert_equal [5, 3, 1, 4, 2], $arr
126 126
     end
127 127
   end
@@ -130,13 +130,13 @@ class InstanceTest < ActiveSupport::TestCase
130 130
     test "running locals" do
131 131
       $arr = []
132 132
       instance = Instance.new
133  
-      instance.initialize!
  133
+      instance.run_initializers
134 134
       assert_equal [1, 2], $arr
135 135
     end
136 136
 
137 137
     test "running globals" do
138 138
       $arr = []
139  
-      Instance.initialize!
  139
+      Instance.run_initializers
140 140
       assert_equal [3, 4], $arr
141 141
     end
142 142
   end

0 notes on commit 8659697

Please sign in to comment.
Something went wrong with that request. Please try again.