Sha256: 706792f0da05d7c7e950f265f034868bcdb6fa731ef7d66d1892b3d7723d91e9

Contents?: true

Size: 1.13 KB

Versions: 44

Compression:

Stored size: 1.13 KB

Contents

require 'test_helper'

class TimeZonesTest < Test::Unit::TestCase
  context "An instance of an embedded document" do
    setup do      
      @document = Class.new do
        include MongoMapper::EmbeddedDocument
        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_eventually "work with timezones that are not UTC" do
      Time.zone = 'Hawaii'
      
      doc = @document.new(:created_at => @original_time)
      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

44 entries across 44 versions & 7 rubygems

Version Path
mongo_mapper-0.6.2 test/unit/test_time_zones.rb
mongo_mapper-0.6.1 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.11.18 test/unit/test_time_zones.rb
mongo_mapper-0.6.0 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.11.8 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.11.6 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.11.2 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.10.31 test/unit/test_time_zones.rb
mongo_mapper-0.5.8 test/unit/test_time_zones.rb
mongo_mapper-0.5.7 test/unit/test_time_zones.rb
mongo_mapper-0.5.6 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.10.16 test/unit/test_time_zones.rb
mongo_mapper-0.5.5 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.10.12 test/unit/test_time_zones.rb
djsun-mongo_mapper-0.5.4.1 test/unit/test_time_zones.rb
djsun-mongo_mapper-0.5.3.1 test/unit/test_time_zones.rb
mongo_mapper-0.5.4 test/unit/test_time_zones.rb
mongo_mapper-0.5.3 test/unit/test_time_zones.rb
mongo_mapper-unstable-2009.10.11 test/unit/test_time_zones.rb
djsun-mongo_mapper-0.5.2.1 test/unit/test_time_zones.rb