File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
spec/integration/criteria Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 486
486
end
487
487
end
488
488
end
489
+
490
+ context 'Mongoid::RawValue<Date>' do
491
+ let! ( :band7 ) { Band . create! ( updated : Time . at ( 1577923200 ) ) }
492
+
493
+ context 'Date field' do
494
+ 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 ]
496
+ end
497
+
498
+ 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 ]
500
+ end
501
+ end
502
+
503
+ context 'Time field' do
504
+ it 'matches objects with raw value' do
505
+ expect ( Band . where ( updated : Mongoid ::RawValue ( Time . at ( 1577923200 ) . to_date ) ) . to_a ) . to eq [ band7 ]
506
+ end
507
+
508
+ it 'matches objects without raw value' do
509
+ Time . use_zone ( 'UTC' ) do
510
+ expect ( Band . where ( updated : Time . at ( 1577923200 ) . to_date ) . to_a ) . to eq [ band7 ]
511
+ end
512
+ end
513
+
514
+ it 'does not matches objects without raw value when in other timezone' do
515
+ Time . use_zone ( 'Asia/Tokyo' ) do
516
+ expect ( Band . where ( updated : Time . at ( 1577923200 ) . to_date ) . to_a ) . to eq [ ]
517
+ end
518
+ end
519
+ end
520
+ end
489
521
end
You can’t perform that action at this time.
0 commit comments