Sha256: a5e912d4ee7e7b4a0f167bfaa682b16c29e3e36d9fc49fadd12822bc2154f677

Contents?: true

Size: 1.08 KB

Versions: 6

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_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

6 entries across 6 versions & 3 rubygems

Version Path
mrkurt-mongo_mapper-0.6.11 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.6 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.5 test/unit/test_time_zones.rb
mongo_mapper-unstable-2010.1.4 test/unit/test_time_zones.rb
tpitale-mongo_mapper-0.6.10 test/unit/test_time_zones.rb
mrkurt-mongo_mapper-0.6.10 test/unit/test_time_zones.rb