Sha256: 245a8a03cdedb4f464ea08cacb1ca2487c41f148aa461b4f73e251b19173261d

Contents?: true

Size: 859 Bytes

Versions: 45

Compression:

Stored size: 859 Bytes

Contents

require_relative "spec_helper"

describe "current_datetime_timestamp extension" do
  before do
    @ds = Sequel.mock[:table].extension(:current_datetime_timestamp)
  end
  after do
    Sequel.datetime_class = Time
  end

  it "should have current_timestamp respect Sequel.datetime_class" do
    t = Sequel::Dataset.new(nil).current_datetime 
    t.must_be_kind_of(Time)
    (Time.now - t < 0.1).must_equal true

    Sequel.datetime_class = DateTime
    t = Sequel::Dataset.new(nil).current_datetime 
    t.must_be_kind_of(DateTime)
    (DateTime.now - t < (0.1/86400)).must_equal true
  end

  it "should have current_timestamp value be literalized as CURRENT_TIMESTAMP" do
    @ds.literal(@ds.current_datetime).must_equal 'CURRENT_TIMESTAMP'
    Sequel.datetime_class = DateTime
    @ds.literal(@ds.current_datetime).must_equal 'CURRENT_TIMESTAMP'
  end
end

Version data entries

45 entries across 41 versions & 2 rubygems

Version Path
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/current_datetime_timestamp_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/sequel-5.26.0/spec/extensions/current_datetime_timestamp_spec.rb
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/sequel-5.29.0/spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.29.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.28.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.27.0 spec/extensions/current_datetime_timestamp_spec.rb
tdiary-5.1.0 vendor/bundle/gems/sequel-5.26.0/spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.26.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.25.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.24.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.23.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.22.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.21.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.20.0 spec/extensions/current_datetime_timestamp_spec.rb
tdiary-5.0.13 vendor/bundle/gems/sequel-5.18.0/spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.19.0 spec/extensions/current_datetime_timestamp_spec.rb
tdiary-5.0.12.1 vendor/bundle/gems/sequel-5.18.0/spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.18.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.17.0 spec/extensions/current_datetime_timestamp_spec.rb
sequel-5.16.0 spec/extensions/current_datetime_timestamp_spec.rb