mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add #unfreeze_time to ActiveSupport::Testing::TimeHelpers
This commit is contained in:
parent
12b32d8049
commit
36e6571a40
3 changed files with 12 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
* Define `unfreeze_time` as an alias of `travel_back` in `ActiveSupport::Testing::TimeHelpers`.
|
||||||
|
|
||||||
|
The alias is provided for symmetry with `freeze_time`.
|
||||||
|
|
||||||
|
*Ryan Davidson*
|
||||||
|
|
||||||
* Add support for tracing constant autoloads. Just throw
|
* Add support for tracing constant autoloads. Just throw
|
||||||
|
|
||||||
ActiveSupport::Dependencies.logger = Rails.logger
|
ActiveSupport::Dependencies.logger = Rails.logger
|
||||||
|
|
|
@ -158,7 +158,7 @@ module ActiveSupport
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the current time back to its original state, by removing the stubs added by
|
# Returns the current time back to its original state, by removing the stubs added by
|
||||||
# +travel+ and +travel_to+.
|
# +travel+, +travel_to+ and +freeze_time+.
|
||||||
#
|
#
|
||||||
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
|
# Time.current # => Sat, 09 Nov 2013 15:34:49 EST -05:00
|
||||||
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
|
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
|
||||||
|
@ -168,6 +168,7 @@ module ActiveSupport
|
||||||
def travel_back
|
def travel_back
|
||||||
simple_stubs.unstub_all!
|
simple_stubs.unstub_all!
|
||||||
end
|
end
|
||||||
|
alias_method :unfreeze_time, :travel_back
|
||||||
|
|
||||||
# Calls +travel_to+ with +Time.now+.
|
# Calls +travel_to+ with +Time.now+.
|
||||||
#
|
#
|
||||||
|
|
|
@ -186,4 +186,8 @@ class TimeTravelTest < ActiveSupport::TestCase
|
||||||
|
|
||||||
assert_operator expected_time.to_s(:db), :<, Time.now.to_s(:db)
|
assert_operator expected_time.to_s(:db), :<, Time.now.to_s(:db)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_time_helper_unfreeze_time
|
||||||
|
assert_equal method(:travel_back), method(:unfreeze_time)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue