Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Tests pass again

  • Loading branch information...
commit 86596975be45fa9088fba4db99b67518434f3afc 1 parent 07da304
@wycats wycats authored
View
4 railties/lib/rails/application.rb
@@ -41,13 +41,13 @@ def call(env)
end
def new
- initializers.run
+ run_initializers
self
end
end
initializer :initialize_rails do
- Rails.initializers.run
+ Rails.run_initializers
end
# Set the <tt>$LOAD_PATH</tt> based on the value of
View
4 railties/lib/rails/initializable.rb
@@ -15,7 +15,7 @@ def self.extended(klass)
class Collection < Array
def initialize(klasses)
klasses.each do |klass|
- klass.added_initializers.each do |initializer|
+ (klass.added_initializers || []).each do |initializer|
index = if initializer.before
index_for(initializer.before)
elsif initializer.after
@@ -44,7 +44,7 @@ def index_for(name)
#
# The #initializers method is set up to return the right list of
# initializers for the context in question.
- def initialize!
+ def run_initializers
return if @_initialized
initializers.each {|initializer| instance_eval(&initializer.block) }
View
20 railties/test/initializable_test.rb
@@ -85,29 +85,29 @@ class Basic < ActiveSupport::TestCase
include ActiveSupport::Testing::Isolation
test "initializers run" do
- Foo.initialize!
+ Foo.run_initializers
assert_equal 1, Foo.foo
end
test "initializers are inherited" do
- Bar.initialize!
+ Bar.run_initializers
assert_equal [1, 1], [Bar.foo, Bar.bar]
end
test "initializers only get run once" do
- Foo.initialize!
- Foo.initialize!
+ Foo.run_initializers
+ Foo.run_initializers
assert_equal 1, Foo.foo
end
test "running initializers on children does not effect the parent" do
- Bar.initialize!
+ Bar.run_initializers
assert_nil Foo.foo
assert_nil Foo.bar
end
test "initializing with modules" do
- Word.initialize!
+ Word.run_initializers
assert_equal "bird", $word
end
end
@@ -115,13 +115,13 @@ class Basic < ActiveSupport::TestCase
class BeforeAfter < ActiveSupport::TestCase
test "running on parent" do
$arr = []
- Parent.initialize!
+ Parent.run_initializers
assert_equal [5, 1, 2], $arr
end
test "running on child" do
$arr = []
- Child.initialize!
+ Child.run_initializers
assert_equal [5, 3, 1, 4, 2], $arr
end
end
@@ -130,13 +130,13 @@ class InstanceTest < ActiveSupport::TestCase
test "running locals" do
$arr = []
instance = Instance.new
- instance.initialize!
+ instance.run_initializers
assert_equal [1, 2], $arr
end
test "running globals" do
$arr = []
- Instance.initialize!
+ Instance.run_initializers
assert_equal [3, 4], $arr
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.