Sha256: aeccf3741b993909e579f07af963da71f4140fe4f4458c589c07bf8fafd671a6

Contents?: true

Size: 1.47 KB

Versions: 4

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'
describe Upsert do
  describe "timezone support" do
    it "takes times in UTC" do
      time = Time.new.utc
      if ENV['DB'] == 'mysql'
        time = time.change(:usec => 0)
      end
      upsert = Upsert.new $conn, :pets
      assert_creates(Pet, [[{:name => 'Jerry'}, {:morning_walk_time => time}]]) do
        upsert.row({:name => 'Jerry'}, {:morning_walk_time => time})
      end
    end

    it "takes times in local" do
      time = Time.new
      if ENV['DB'] == 'mysql'
        time = time.change(:usec => 0)
      end
      upsert = Upsert.new $conn, :pets
      assert_creates(Pet, [[{:name => 'Jerry'}, {:morning_walk_time => time}]]) do
        upsert.row({:name => 'Jerry'}, {:morning_walk_time => time})
      end
    end

    it "takes datetimes in UTC" do
      time = DateTime.now.new_offset(Rational(0, 24))
      if ENV['DB'] == 'mysql'
        time = time.change(:usec => 0)
      end
      upsert = Upsert.new $conn, :pets
      assert_creates(Pet, [[{:name => 'Jerry'}, {:morning_walk_time => time}]]) do
        upsert.row({:name => 'Jerry'}, {:morning_walk_time => time})
      end
    end

    it "takes datetimes in local" do
      time = DateTime.now
      if ENV['DB'] == 'mysql'
        time = time.change(:usec => 0)
      end
      upsert = Upsert.new $conn, :pets
      assert_creates(Pet, [[{:name => 'Jerry'}, {:morning_walk_time => time}]]) do
        upsert.row({:name => 'Jerry'}, {:morning_walk_time => time})
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
upsert-1.1.4 spec/timezones_spec.rb
upsert-1.1.3 spec/timezones_spec.rb
upsert-1.1.1 spec/timezones_spec.rb
upsert-1.1.0 spec/timezones_spec.rb