aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorryanwhocodes <22416807+ryanwhocodes@users.noreply.github.com>2018-09-07 10:09:46 +0100
committerryanwhocodes <22416807+ryanwhocodes@users.noreply.github.com>2018-09-10 22:32:41 +0100
commit36e6571a40000a2d7d675384b071c9a009c24499 (patch)
tree7e5b961613c34e9ca0d59487b3824d4e2b4e61dd /activesupport
parent12b32d804996c6bb3d215a22762c0c1a27f223d3 (diff)
downloadrails-36e6571a40000a2d7d675384b071c9a009c24499.tar.gz
rails-36e6571a40000a2d7d675384b071c9a009c24499.tar.bz2
rails-36e6571a40000a2d7d675384b071c9a009c24499.zip
Add #unfreeze_time to ActiveSupport::Testing::TimeHelpers
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/CHANGELOG.md6
-rw-r--r--activesupport/lib/active_support/testing/time_helpers.rb3
-rw-r--r--activesupport/test/time_travel_test.rb4
3 files changed, 12 insertions, 1 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md
index 519e76f553..d1f079b3d8 100644
--- a/activesupport/CHANGELOG.md
+++ b/activesupport/CHANGELOG.md
@@ -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
ActiveSupport::Dependencies.logger = Rails.logger
diff --git a/activesupport/lib/active_support/testing/time_helpers.rb b/activesupport/lib/active_support/testing/time_helpers.rb
index 801ea2909b..decb3179c4 100644
--- a/activesupport/lib/active_support/testing/time_helpers.rb
+++ b/activesupport/lib/active_support/testing/time_helpers.rb
@@ -158,7 +158,7 @@ module ActiveSupport
end
# 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
# travel_to Time.zone.local(2004, 11, 24, 01, 04, 44)
@@ -168,6 +168,7 @@ module ActiveSupport
def travel_back
simple_stubs.unstub_all!
end
+ alias_method :unfreeze_time, :travel_back
# Calls +travel_to+ with +Time.now+.
#
diff --git a/activesupport/test/time_travel_test.rb b/activesupport/test/time_travel_test.rb
index 9c2c635f43..8c47f2cdc7 100644
--- a/activesupport/test/time_travel_test.rb
+++ b/activesupport/test/time_travel_test.rb
@@ -186,4 +186,8 @@ class TimeTravelTest < ActiveSupport::TestCase
assert_operator expected_time.to_s(:db), :<, Time.now.to_s(:db)
end
+
+ def test_time_helper_unfreeze_time
+ assert_equal method(:travel_back), method(:unfreeze_time)
+ end
end