Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Setup each test with default ActiveRecord timezone settings to ensure…

… each test starts with a clean slate.

Fixes #6867.
  • Loading branch information...
commit 600f02713df7be23f12efbcecdbf4ccabf0ac20f 1 parent 99e10eb
Erich Menge authored
Showing with 8 additions and 20 deletions.
  1. +8 −20 activerecord/test/cases/base_test.rb
View
28 activerecord/test/cases/base_test.rb
@@ -81,6 +81,12 @@ def setup
class BasicsTest < ActiveRecord::TestCase
fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts
+ def setup
+ ActiveRecord::Base.time_zone_aware_attributes = false
+ ActiveRecord::Base.default_timezone = :local
+ Time.zone = nil
+ end
+
def test_generated_methods_modules
modules = Computer.ancestors
assert modules.include?(Computer::GeneratedFeatureMethods)
@@ -686,7 +692,7 @@ def test_multiparameter_attributes_on_time
}
topic = Topic.find(1)
topic.attributes = attributes
- assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on
+ assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
end
def test_multiparameter_attributes_on_time_with_no_date
@@ -793,8 +799,6 @@ def test_multiparameter_attributes_on_time_with_utc
topic = Topic.find(1)
topic.attributes = attributes
assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on
- ensure
- ActiveRecord::Base.default_timezone = :local
end
def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes
@@ -810,14 +814,9 @@ def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes
assert_equal Time.utc(2004, 6, 24, 23, 24, 0), topic.written_on
assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on.time
assert_equal Time.zone, topic.written_on.time_zone
- ensure
- ActiveRecord::Base.time_zone_aware_attributes = false
- ActiveRecord::Base.default_timezone = :local
- Time.zone = nil
end
def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_false
- ActiveRecord::Base.time_zone_aware_attributes = false
Time.zone = ActiveSupport::TimeZone[-28800]
attributes = {
"written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24",
@@ -827,8 +826,6 @@ def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes_false
topic.attributes = attributes
assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
assert_equal false, topic.written_on.respond_to?(:time_zone)
- ensure
- Time.zone = nil
end
def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_attributes
@@ -845,9 +842,6 @@ def test_multiparameter_attributes_on_time_with_skip_time_zone_conversion_for_at
assert_equal Time.utc(2004, 6, 24, 16, 24, 0), topic.written_on
assert_equal false, topic.written_on.respond_to?(:time_zone)
ensure
- ActiveRecord::Base.time_zone_aware_attributes = false
- ActiveRecord::Base.default_timezone = :local
- Time.zone = nil
Topic.skip_time_zone_conversion_for_attributes = []
end
@@ -865,10 +859,6 @@ def test_multiparameter_attributes_on_time_only_column_with_time_zone_aware_attr
topic.attributes = attributes
assert_equal Time.utc(2000, 1, 1, 16, 24, 0), topic.bonus_time
assert topic.bonus_time.utc?
- ensure
- ActiveRecord::Base.time_zone_aware_attributes = false
- ActiveRecord::Base.default_timezone = :local
- Time.zone = nil
end
end
@@ -911,7 +901,7 @@ def test_attributes_on_dummy_time
}
topic = Topic.find(1)
topic.attributes = attributes
- assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time
+ assert_equal Time.local(2000, 1, 1, 5, 42, 0), topic.bonus_time
end
def test_boolean
@@ -1876,8 +1866,6 @@ def test_cache_key_for_existing_record_is_not_timezone_dependent
est_key = Developer.first.cache_key
assert_equal utc_key, est_key
- ensure
- ActiveRecord::Base.time_zone_aware_attributes = false
end
def test_cache_key_format_for_existing_record_with_updated_at
Please sign in to comment.
Something went wrong with that request. Please try again.