1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Tests pass again

This commit is contained in:
Yehuda Katz 2009-10-27 19:05:29 -07:00
parent 07da304ff8
commit 86596975be
3 changed files with 14 additions and 14 deletions

View file

@ -41,13 +41,13 @@ module Rails
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 file

@ -15,7 +15,7 @@ module Rails
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 @@ module Rails
#
# 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 file

@ -85,29 +85,29 @@ module InitializableTests
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 @@ module InitializableTests
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 @@ module InitializableTests
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