Sha256: 4fc02cae151d1dfc7f7a0068abc74a374b3a46fa34c1cf37bdb1b0e6ff208cac

Contents?: true

Size: 1.79 KB

Versions: 18

Compression:

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

    if ENV['DB'] == 'postgresql'
      it "doesn't die on timestamp without time zone (postgresql)" do
        time = Time.new.utc
        upsert = Upsert.new $conn, :pets
        assert_creates(Pet, [[{:name => 'Jerry'}, {:tsntz => time}]]) do
          upsert.row({:name => 'Jerry'}, {:tsntz => time})
        end
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
upsert-2.9.10-java spec/timezones_spec.rb
upsert-2.9.10 spec/timezones_spec.rb
upsert-2.9.9-universal-java-11 spec/timezones_spec.rb
upsert-2.9.9 spec/timezones_spec.rb
upsert-2.2.1 spec/timezones_spec.rb
upsert-2.2.0 spec/timezones_spec.rb
upsert-2.1.2 spec/timezones_spec.rb
upsert-2.1.1 spec/timezones_spec.rb
upsert-2.1.0 spec/timezones_spec.rb
upsert-2.0.4 spec/timezones_spec.rb
upsert-2.0.3 spec/timezones_spec.rb
upsert-2.0.2 spec/timezones_spec.rb
upsert-2.0.1 spec/timezones_spec.rb
upsert-2.0.0 spec/timezones_spec.rb
upsert-1.2.0 spec/timezones_spec.rb
upsert-1.1.7 spec/timezones_spec.rb
upsert-1.1.6 spec/timezones_spec.rb
upsert-1.1.5 spec/timezones_spec.rb