Sha256: 3e67f863a923636ac5056cb4145d81ba13a0e7dd70bc09d437730b360e970856

Contents?: true

Size: 888 Bytes

Versions: 27

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

describe 'Queries on Date fields' do
  let(:query) do
    Band.where(founded: arg)
  end

  let(:selector) { query.selector }

  shared_examples 'converts to beginning of day in UTC' do
    it 'converts to beginning of day in UTC' do
      selector['founded'].should == Time.utc(arg.year, arg.month, arg.day)
    end
  end

  context 'using Time' do
    let(:arg) do
      Time.now.freeze
    end

    it_behaves_like 'converts to beginning of day in UTC'
  end

  context 'using TimeWithZone' do
    let(:time_zone_name) { 'Pacific Time (US & Canada)' }
    let(:arg) { Time.now.in_time_zone(time_zone_name).freeze }

    it_behaves_like 'converts to beginning of day in UTC'
  end

  context 'using DateTime' do
    let(:arg) do
      DateTime.now.freeze
    end

    it_behaves_like 'converts to beginning of day in UTC'
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
mongoid-8.1.9 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.9 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.8 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.7 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.6 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.8 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.5 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.4 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.7 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.3 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.2 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.6 spec/integration/criteria/date_field_spec.rb
mongoid-7.5.4 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.1 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.5 spec/integration/criteria/date_field_spec.rb
mongoid-8.1.0 spec/integration/criteria/date_field_spec.rb
mongoid-7.5.3 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.4 spec/integration/criteria/date_field_spec.rb
mongoid-8.0.3 spec/integration/criteria/date_field_spec.rb
mongoid-7.5.2 spec/integration/criteria/date_field_spec.rb