diff options
author | Louise Crow <louise.crow@gmail.com> | 2012-12-12 10:40:42 +0000 |
---|---|---|
committer | Louise Crow <louise.crow@gmail.com> | 2012-12-12 10:40:42 +0000 |
commit | 6bf8a2eb3894e5a4fe74baf6b16a41c9554a13d4 (patch) | |
tree | 42f1fe6ee90dfe0bf3f9c7d36a80490b63056978 /spec/spec_helper.rb | |
parent | 7cfa3956fd373db35948ef33cde652b30229f9ad (diff) | |
parent | e898190fe61a4369ee83e94a24327ff437435b07 (diff) |
Merge branch 'feature/set-zone-in-tests' into develop
Diffstat (limited to 'spec/spec_helper.rb')
-rw-r--r-- | spec/spec_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4cf376624..561a75da6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -275,3 +275,18 @@ class ApplicationController < ActionController::Base @popup_banner = nil end end + + +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 + +def with_active_record_default_timezone(zone) + old_zone, ActiveRecord::Base.default_timezone = ActiveRecord::Base.default_timezone, zone + yield +ensure + ActiveRecord::Base.default_timezone = old_zone +end |