Sha256: 7898074b2c29d81d11bd2b70560c1fe24ac760314264345c4a7aeaf351770e74

Contents?: true

Size: 1.08 KB

Versions: 60

Compression:

Stored size: 1.08 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

60 entries across 60 versions & 8 rubygems

Version Path
mongo_mapper-unstable-2010.1.30 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.29 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.28 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.27 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.26 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.25 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.22 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.21 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.20 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.19 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.7 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.18 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.6 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.5 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.17 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.4 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.2 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.1 test/unit/test_time_zones.rb
jmonteiro-mongo_mapper-0.1.0 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.12 test/unit/test_time_zones.rb