Sha256: a82afc9289006ae800fb9e4deb881f2b660babca7f38f203ac484e724d3316eb

Contents?: true

Size: 1.03 KB

Versions: 67

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'

class TimeZonesTest < Test::Unit::TestCase
  context "An instance of an embedded document" do
    setup do
      @document = EDoc do
        key :name, String
        key :created_at, Time
      end
    end

    should "work without Time.zone" do
      Time.zone = nil

      doc = @document.new(:created_at => "2009-08-15 14:00:00")
      doc.created_at.should == Time.local(2009, 8, 15, 14, 0, 0).utc
    end

    should "work with Time.zone set to the (default) UTC" do
      Time.zone = 'UTC'

      doc = @document.new(:created_at => "2009-08-15 14:00:00")
      doc.created_at.is_a?(ActiveSupport::TimeWithZone).should be_true
      doc.created_at.should == Time.utc(2009, 8, 15, 14)

      Time.zone = nil
    end

    should "work with timezones that are not UTC" do
      Time.zone = 'Hawaii'

      doc = @document.new(:created_at => "2009-08-15 14:00:00")
      doc.created_at.is_a?(ActiveSupport::TimeWithZone).should be_true
      doc.created_at.should == Time.utc(2009, 8, 16)

      Time.zone = nil
    end
  end
end

Version data entries

67 entries across 67 versions & 8 rubygems

Version Path
mongo_mapper-0.11.0 test/unit/test_time_zones.rb
mongo_mapper-0.10.1 test/unit/test_time_zones.rb
mongo_mapper-0.10.0 test/unit/test_time_zones.rb
mongo_mapper-0.9.2 test/unit/test_time_zones.rb
jonbell-mongo_mapper-0.8.6 test/unit/test_time_zones.rb
mongo_mapper-0.9.1 test/unit/test_time_zones.rb
mongo_mapper-0.9.0 test/unit/test_time_zones.rb
ign-mongo_mapper-0.8.6.2 test/unit/test_time_zones.rb
ign-mongo_mapper-0.8.6.1 test/unit/test_time_zones.rb
ssherman-mongo_mapper-0.8.6 test/unit/test_time_zones.rb
mongo_mapper-0.8.6 test/unit/test_time_zones.rb
mongo_mapper-0.8.5 test/unit/test_time_zones.rb
honkster-mongo_mapper-0.8.4 test/unit/test_time_zones.rb
mongo_mapper-0.8.4 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.08.19 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.08.18 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.08.17 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.08.16 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.08.15 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.08.14 test/unit/test_time_zones.rb