aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext/string_ext_test.rb
diff options
context:
space:
mode:
authorZuhao Wan <wanzuhao@gmail.com>2014-06-18 19:46:04 +0800
committerZuhao Wan <wanzuhao@gmail.com>2014-06-18 19:46:04 +0800
commit9c492885d178b1a3d0de2f710a8a276db3d867b2 (patch)
tree1bcf8d640a8d302e1df5a56587f0f7e58b3922c6 /activesupport/test/core_ext/string_ext_test.rb
parente2f232aba15937a4b9d14bd91e0392c6d55be58d (diff)
downloadrails-9c492885d178b1a3d0de2f710a8a276db3d867b2.tar.gz
rails-9c492885d178b1a3d0de2f710a8a276db3d867b2.tar.bz2
rails-9c492885d178b1a3d0de2f710a8a276db3d867b2.zip
Extract out with_env_tz helper method.
It’s used at so many places that extracting it out into a helper file is worth doing.
Diffstat (limited to 'activesupport/test/core_ext/string_ext_test.rb')
-rw-r--r--activesupport/test/core_ext/string_ext_test.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb
index 95df173880..515144245a 100644
--- a/activesupport/test/core_ext/string_ext_test.rb
+++ b/activesupport/test/core_ext/string_ext_test.rb
@@ -10,10 +10,12 @@ require 'active_support/time'
require 'active_support/core_ext/string/strip'
require 'active_support/core_ext/string/output_safety'
require 'active_support/core_ext/string/indent'
+require 'time_zone_test_helpers'
class StringInflectionsTest < ActiveSupport::TestCase
include InflectorTestCases
include ConstantizeTestCases
+ include TimeZoneTestHelpers
def test_strip_heredoc_on_an_empty_string
assert_equal '', ''.strip_heredoc
@@ -354,6 +356,8 @@ class StringAccessTest < ActiveSupport::TestCase
end
class StringConversionsTest < ActiveSupport::TestCase
+ include TimeZoneTestHelpers
+
def test_string_to_time
with_env_tz "Europe/Moscow" do
assert_equal Time.utc(2005, 2, 27, 23, 50), "2005-02-27 23:50".to_time(:utc)
@@ -523,14 +527,6 @@ class StringConversionsTest < ActiveSupport::TestCase
assert_nil "".to_date
assert_equal Date.new(Date.today.year, 2, 3), "Feb 3rd".to_date
end
-
- protected
- def with_env_tz(new_tz = 'US/Eastern')
- old_tz, ENV['TZ'] = ENV['TZ'], new_tz
- yield
- ensure
- old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ')
- end
end
class StringBehaviourTest < ActiveSupport::TestCase