|
468 | 468 | end |
469 | 469 |
|
470 | 470 | it 'matches objects without raw value when exact' do |
471 | | - expect(Band.where(founded: Time.at(1577923200)).to_a).to eq [band3, band4] |
| 471 | + expect(Band.where(founded: Time.at(1577923200).utc).to_a).to eq [band3, band4] |
472 | 472 | end |
473 | 473 |
|
474 | | - it 'matches objects without raw value when non-exact' do |
475 | | - expect(Band.where(founded: Time.at(1577923199)).to_a).to eq [band3, band4] |
| 474 | + it 'matches objects without raw value when 1 second before midnight' do |
| 475 | + expect(Band.where(founded: Time.at(1577923199).utc).to_a).to eq [band1, band2] |
| 476 | + end |
| 477 | + |
| 478 | + it 'matches objects without raw value when 1 second after midnight' do |
| 479 | + expect(Band.where(founded: Time.at(1577923201).utc).to_a).to eq [band3, band4] |
476 | 480 | end |
477 | 481 | end |
478 | 482 |
|
|
492 | 496 |
|
493 | 497 | context 'Date field' do |
494 | 498 | it 'matches objects with raw value' do |
495 | | - expect(Band.where(founded: Mongoid::RawValue(Time.at(1577923200).to_date)).to_a).to eq [band3, band4] |
| 499 | + expect(Band.where(founded: Mongoid::RawValue(Time.at(1577923200).utc.to_date)).to_a).to eq [band3, band4] |
496 | 500 | end |
497 | 501 |
|
498 | 502 | it 'matches objects without raw value when non-exact' do |
499 | | - expect(Band.where(founded: Time.at(1577923200).to_date).to_a).to eq [band3, band4] |
| 503 | + expect(Band.where(founded: Time.at(1577923200).utc.to_date).to_a).to eq [band3, band4] |
500 | 504 | end |
501 | 505 | end |
502 | 506 |
|
503 | 507 | context 'Time field' do |
504 | 508 | it 'matches objects with raw value' do |
505 | | - expect(Band.where(updated: Mongoid::RawValue(Time.at(1577923200).to_date)).to_a).to eq [band7] |
| 509 | + expect(Band.where(updated: Mongoid::RawValue(Time.at(1577923200).utc.to_date)).to_a).to eq [band7] |
506 | 510 | end |
507 | 511 |
|
508 | 512 | it 'matches objects without raw value' do |
509 | 513 | Time.use_zone('UTC') do |
510 | | - expect(Band.where(updated: Time.at(1577923200).to_date).to_a).to eq [band7] |
| 514 | + expect(Band.where(updated: Time.at(1577923200).utc.to_date).to_a).to eq [band7] |
511 | 515 | end |
512 | 516 | end |
513 | 517 |
|
514 | 518 | it 'does not matches objects without raw value when in other timezone' do |
515 | 519 | Time.use_zone('Asia/Tokyo') do |
516 | | - expect(Band.where(updated: Time.at(1577923200).to_date).to_a).to eq [] |
| 520 | + expect(Band.where(updated: Time.at(1577923200).utc.to_date).to_a).to eq [] |
517 | 521 | end |
518 | 522 | end |
519 | 523 | end |
|
0 commit comments