提交 5ef040d0 编写于 作者: C Carlos Antonio da Silva

Get rid of hack for freezing time on AR tests

We can now make use of the existent #travel/#travel_to helper methods
added to AS test case and available in all tests.
上级 fe24f356
......@@ -149,23 +149,6 @@ def load_schema
load_schema
class << Time
unless method_defined? :now_before_time_travel
alias_method :now_before_time_travel, :now
end
def now
(@now ||= nil) || now_before_time_travel
end
def travel_to(time, &block)
@now = time
block.call
ensure
@now = nil
end
end
class SQLSubscriber
attr_reader :logged
attr_reader :payloads
......@@ -183,7 +166,6 @@ def start(name, id, payload)
def finish(name, id, payload); end
end
module InTimeZone
private
......
......@@ -743,7 +743,7 @@ def test_copying_migrations_with_timestamps
@migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps"
@existing_migrations = Dir[@migrations_path + "/*.rb"]
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb")
assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb")
......@@ -768,7 +768,7 @@ def test_copying_migrations_with_timestamps_from_2_sources
sources[:bukkits] = MIGRATIONS_ROOT + "/to_copy_with_timestamps"
sources[:omg] = MIGRATIONS_ROOT + "/to_copy_with_timestamps2"
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
copied = ActiveRecord::Migration.copy(@migrations_path, sources)
assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb")
assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb")
......@@ -788,7 +788,7 @@ def test_copying_migrations_with_timestamps_to_destination_with_timestamps_in_fu
@migrations_path = MIGRATIONS_ROOT + "/valid_with_timestamps"
@existing_migrations = Dir[@migrations_path + "/*.rb"]
Time.travel_to(Time.utc(2010, 2, 20, 10, 10, 10)) do
travel_to(Time.utc(2010, 2, 20, 10, 10, 10)) do
ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
assert File.exist?(@migrations_path + "/20100301010102_people_have_hobbies.bukkits.rb")
assert File.exist?(@migrations_path + "/20100301010103_people_have_descriptions.bukkits.rb")
......@@ -863,7 +863,7 @@ def test_copying_migrations_to_non_existing_directory
@migrations_path = MIGRATIONS_ROOT + "/non_existing"
@existing_migrations = []
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb")
assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb")
......@@ -878,7 +878,7 @@ def test_copying_migrations_to_empty_directory
@migrations_path = MIGRATIONS_ROOT + "/empty"
@existing_migrations = []
Time.travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
travel_to(Time.utc(2010, 7, 26, 10, 10, 10)) do
copied = ActiveRecord::Migration.copy(@migrations_path, {:bukkits => MIGRATIONS_ROOT + "/to_copy_with_timestamps"})
assert File.exist?(@migrations_path + "/20100726101010_people_have_hobbies.bukkits.rb")
assert File.exist?(@migrations_path + "/20100726101011_people_have_descriptions.bukkits.rb")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册