diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2008-03-30 23:01:06 +0000 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2008-03-30 23:01:06 +0000 |
commit | 458fd104838c14be4511c86c5739f8368725ecbd (patch) | |
tree | 6e2654845e5cbccfc83f9acbc1b22fab231c4e48 /activerecord/test | |
parent | d4493bc562f4f774bfad075e2ba57be3434046c3 (diff) | |
download | rails-458fd104838c14be4511c86c5739f8368725ecbd.tar.gz rails-458fd104838c14be4511c86c5739f8368725ecbd.tar.bz2 rails-458fd104838c14be4511c86c5739f8368725ecbd.zip |
Removing unnecessary uses_tzinfo helper from tests, given that TZInfo is now bundled
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9150 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rwxr-xr-x | activerecord/test/cases/attribute_methods_test.rb | 76 | ||||
-rwxr-xr-x | activerecord/test/cases/base_test.rb | 36 | ||||
-rw-r--r-- | activerecord/test/cases/helper.rb | 8 |
3 files changed, 54 insertions, 66 deletions
diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 376a70d6fe..61a049ab36 100755 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -138,51 +138,49 @@ class AttributeMethodsTest < ActiveRecord::TestCase end end - uses_tzinfo "Time zone" do - def test_time_attributes_are_retrieved_in_current_time_zone - in_time_zone "Pacific Time (US & Canada)" do - utc_time = Time.utc(2008, 1, 1) - record = @target.new - record[:written_on] = utc_time - assert_equal utc_time, record.written_on # record.written on is equal to (i.e., simultaneous with) utc_time - assert_kind_of ActiveSupport::TimeWithZone, record.written_on # but is a TimeWithZone - assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone # and is in the current Time.zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time # and represents time values adjusted accordingly - end + def test_time_attributes_are_retrieved_in_current_time_zone + in_time_zone "Pacific Time (US & Canada)" do + utc_time = Time.utc(2008, 1, 1) + record = @target.new + record[:written_on] = utc_time + assert_equal utc_time, record.written_on # record.written on is equal to (i.e., simultaneous with) utc_time + assert_kind_of ActiveSupport::TimeWithZone, record.written_on # but is a TimeWithZone + assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone # and is in the current Time.zone + assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time # and represents time values adjusted accordingly end + end - def test_setting_time_zone_aware_attribute_to_utc - in_time_zone "Pacific Time (US & Canada)" do - utc_time = Time.utc(2008, 1, 1) - record = @target.new - record.written_on = utc_time - assert_equal utc_time, record.written_on - assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end + def test_setting_time_zone_aware_attribute_to_utc + in_time_zone "Pacific Time (US & Canada)" do + utc_time = Time.utc(2008, 1, 1) + record = @target.new + record.written_on = utc_time + assert_equal utc_time, record.written_on + assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone + assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time end + end - def test_setting_time_zone_aware_attribute_in_other_time_zone - utc_time = Time.utc(2008, 1, 1) - cst_time = utc_time.in_time_zone("Central Time (US & Canada)") - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = cst_time - assert_equal utc_time, record.written_on - assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end + def test_setting_time_zone_aware_attribute_in_other_time_zone + utc_time = Time.utc(2008, 1, 1) + cst_time = utc_time.in_time_zone("Central Time (US & Canada)") + in_time_zone "Pacific Time (US & Canada)" do + record = @target.new + record.written_on = cst_time + assert_equal utc_time, record.written_on + assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone + assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time end + end - def test_setting_time_zone_aware_attribute_in_current_time_zone - utc_time = Time.utc(2008, 1, 1) - in_time_zone "Pacific Time (US & Canada)" do - record = @target.new - record.written_on = utc_time.in_time_zone - assert_equal utc_time, record.written_on - assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone - assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time - end + def test_setting_time_zone_aware_attribute_in_current_time_zone + utc_time = Time.utc(2008, 1, 1) + in_time_zone "Pacific Time (US & Canada)" do + record = @target.new + record.written_on = utc_time.in_time_zone + assert_equal utc_time, record.written_on + assert_equal TimeZone["Pacific Time (US & Canada)"], record.written_on.time_zone + assert_equal Time.utc(2007, 12, 31, 16), record.written_on.time end end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 3025d20e5f..977c5d7333 100755 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -973,25 +973,23 @@ class BasicsTest < ActiveRecord::TestCase ActiveRecord::Base.default_timezone = :local end - uses_tzinfo "test_multiparameter_attributes_on_time_with_time_zone_aware_attributes" do - def test_multiparameter_attributes_on_time_with_time_zone_aware_attributes - ActiveRecord::Base.time_zone_aware_attributes = true - ActiveRecord::Base.default_timezone = :utc - Time.zone = TimeZone[-28800] - attributes = { - "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", - "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" - } - topic = Topic.find(1) - topic.attributes = 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 + ActiveRecord::Base.time_zone_aware_attributes = true + ActiveRecord::Base.default_timezone = :utc + Time.zone = TimeZone[-28800] + attributes = { + "written_on(1i)" => "2004", "written_on(2i)" => "6", "written_on(3i)" => "24", + "written_on(4i)" => "16", "written_on(5i)" => "24", "written_on(6i)" => "00" + } + topic = Topic.find(1) + topic.attributes = 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 diff --git a/activerecord/test/cases/helper.rb b/activerecord/test/cases/helper.rb index 1040d1ec41..dc83300efa 100644 --- a/activerecord/test/cases/helper.rb +++ b/activerecord/test/cases/helper.rb @@ -29,14 +29,6 @@ rescue LoadError $stderr.puts "Skipping #{description} tests. `gem install mocha` and try again." end -def uses_tzinfo(description) - require 'rubygems' - require 'tzinfo' - yield -rescue LoadError - $stderr.puts "Skipping #{description} tests. `gem install tzinfo` and try again." -end - ActiveRecord::Base.connection.class.class_eval do IGNORED_SQL = [/^PRAGMA/, /^SELECT currval/, /^SELECT CAST/, /^SELECT @@IDENTITY/, /^SELECT @@ROWCOUNT/] |