Skip to content

Commit 0c22046

Browse files
committed
Add specs for Date
1 parent a258594 commit 0c22046

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

spec/integration/criteria/raw_value_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,4 +486,36 @@
486486
end
487487
end
488488
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
489521
end

0 commit comments

Comments
 (0)