Skip to content

Commit bda25d0

Browse files
committed
Fix remaining specs
1 parent 19c82cc commit bda25d0

File tree

1 file changed

+48
-52
lines changed

1 file changed

+48
-52
lines changed

spec/integration/criteria/raw_value_spec.rb

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@
1111
[ Label.new(age: 12), Label.new(age: 16) ]
1212
end
1313

14-
let!(:band1) { Band.create!(name: '1', likes: 0, rating: 0.9, sales: BigDecimal('90'), decibels: 20..80, founded: today, updated_at: now_utc) }
15-
let!(:band2) { Band.create!(name: '2', likes: 1, rating: 1.0, sales: BigDecimal('100'), decibels: 30..90, founded: today, updated_at: now_utc + 1.days) }
16-
let!(:band3) { Band.create!(name: '3', likes: 1, rating: 2.2, sales: BigDecimal('220'), decibels: 40..100, founded: today + 1.days, updated_at: now_utc + 2.days) }
17-
let!(:band4) { Band.create!(name: '3', likes: 2, rating: 3.1, sales: BigDecimal('310'), decibels: 50..120, founded: today + 1.days, updated_at: now_utc + 3.days) }
18-
let!(:band5) { Band.create!(name: '4', likes: 3, rating: 3.1, sales: BigDecimal('310'), decibels: 60..150, founded: today + 2.days, updated_at: now_utc + 3.days, labels: labels) }
14+
let!(:band1) { Band.create!(name: '1', likes: 0, rating: 0.9, sales: BigDecimal('90'), decibels: 20..80, founded: today, updated: now_utc) }
15+
let!(:band2) { Band.create!(name: '2', likes: 1, rating: 1.0, sales: BigDecimal('100'), decibels: 30..90, founded: today, updated: now_utc + 1.days) }
16+
let!(:band3) { Band.create!(name: '3', likes: 1, rating: 2.2, sales: BigDecimal('220'), decibels: 40..100, founded: today + 1.days, updated: now_utc + 2.days) }
17+
let!(:band4) { Band.create!(name: '3', likes: 2, rating: 3.1, sales: BigDecimal('310'), decibels: 50..120, founded: today + 1.days, updated: now_utc + 3.days) }
18+
let!(:band5) { Band.create!(name: '4', likes: 3, rating: 3.1, sales: BigDecimal('310'), decibels: 60..150, founded: today + 2.days, updated: now_utc + 3.days, labels: labels) }
19+
1920
let!(:band6) do
2021
id = BSON::ObjectId.new
21-
Band.collection.insert_one(_id: id, name: 1, likes: '1', rating: '3.1', sales: '310', decibels: '90', founded: today, updated_at: now_utc)
22+
Band.collection.insert_one(_id: id, name: 1, likes: '1', rating: '3.1', sales: '310', decibels: '90', founded: '2020-01-02', updated: '2020-01-04 16:00:00 UTC')
2223
Band.find(id)
2324
end
25+
2426
let!(:band7) do
2527
id = BSON::ObjectId.new
26-
Band.collection.insert_one(_id: id, name: 1.0, decibels: 90.0)
28+
Band.collection.insert_one(_id: id, name: 1.0, decibels: 90.0, founded: 1577923200)
2729
Band.find(id)
2830
end
2931

@@ -78,25 +80,24 @@
7880
expect(Band.where(decibels: '90').to_a).to eq [band6]
7981
end
8082
end
81-
83+
8284
context 'Date field' do
8385
it 'does not match objects with raw value' do
84-
expect(Band.where(founded: Mongoid::RawValue('2020-01-02')).to_a).to eq []
86+
expect(Band.where(founded: Mongoid::RawValue('2020-01-02')).to_a).to eq [band6]
8587
end
86-
88+
8789
it 'matches objects without raw value' do
8890
expect(Band.where(founded: '2020-01-02').to_a).to eq [band3, band4]
8991
end
9092
end
91-
93+
9294
context 'Time field' do
9395
it 'does not match objects with raw value' do
94-
expect(Band.where(updated_at: Mongoid::RawValue('2020-01-04 16:00:00 UTC')).to_a).to eq []
96+
expect(Band.where(updated: Mongoid::RawValue('2020-01-04 16:00:00 UTC')).to_a).to eq [band6]
9597
end
96-
97-
# TODO: this isn't working for some reason
98-
xit 'matches objects without raw value' do
99-
expect(Band.where(updated_at: '2020-01-04 16:00:00 UTC').to_a).to eq [band4, band5]
98+
99+
it 'matches objects without raw value' do
100+
expect(Band.where(updated: '2020-01-04 16:00:00 UTC').to_a).to eq [band4, band5]
100101
end
101102
end
102103
end
@@ -107,18 +108,18 @@
107108
it 'matches objects with raw value' do
108109
expect(Band.where(likes: Mongoid::RawValue(1)).to_a).to eq [band2, band3]
109110
end
110-
111+
111112
it 'matches objects without raw value' do
112113
expect(Band.where(likes: 1).to_a).to eq [band2, band3]
113114
end
114115
end
115-
116+
116117
context 'Float field' do
117118
it 'does not match objects with raw value' do
118119
expect(Band.where(rating: Mongoid::RawValue(1)).to_a).to eq [band2]
119120
expect(Band.where(rating: Mongoid::RawValue(3)).to_a).to eq []
120121
end
121-
122+
122123
it 'matches objects without raw value' do
123124
expect(Band.where(rating: 1).to_a).to eq [band2]
124125
expect(Band.where(rating: 3).to_a).to eq []
@@ -134,17 +135,17 @@
134135
expect(Band.where(sales: 310).to_a).to eq [band4, band5]
135136
end
136137
end
137-
138+
138139
context 'String field' do
139140
it 'matches objects with raw value' do
140141
expect(Band.where(name: Mongoid::RawValue(1)).to_a).to eq [band6, band7]
141142
end
142-
143+
143144
it 'matches objects without raw value' do
144145
expect(Band.where(name: 3).to_a).to eq [band3, band4]
145146
end
146147
end
147-
148+
148149
context 'Range field' do
149150
it 'does not match objects with raw value' do
150151
expect(Band.where(decibels: Mongoid::RawValue(90)).to_a).to eq [band7]
@@ -157,22 +158,21 @@
157158

158159
context 'Date field' do
159160
it 'does not match objects with raw value' do
160-
expect(Band.where(founded: Mongoid::RawValue(1577923200)).to_a).to eq []
161+
expect(Band.where(founded: Mongoid::RawValue(1577923200)).to_a).to eq [band7]
161162
end
162-
163+
163164
it 'matches objects without raw value' do
164165
expect(Band.where(founded: 1577923200).to_a).to eq [band3, band4]
165166
end
166167
end
167-
168+
168169
context 'Time field' do
169170
it 'does not match objects with raw value' do
170-
expect(Band.where(updated_at: Mongoid::RawValue(1578153600)).to_a).to eq []
171+
expect(Band.where(updated: Mongoid::RawValue(1578153600)).to_a).to eq []
171172
end
172-
173-
# TODO: this isn't working for some reason
174-
xit 'matches objects without raw value' do
175-
expect(Band.where(updated_at: 1578153600).to_a).to eq [band4, band5]
173+
174+
it 'matches objects without raw value' do
175+
expect(Band.where(updated: 1578153600).to_a).to eq [band4, band5]
176176
end
177177
end
178178
end
@@ -183,17 +183,17 @@
183183
it 'does not match objects with raw value' do
184184
expect(Band.where(likes: Mongoid::RawValue(1.0)).to_a).to eq [band2, band3]
185185
end
186-
186+
187187
it 'matches objects without raw value' do
188188
expect(Band.where(likes: 1.0).to_a).to eq [band2, band3]
189189
end
190190
end
191-
191+
192192
context 'Float field' do
193193
it 'does not match objects with raw value' do
194194
expect(Band.where(rating: Mongoid::RawValue(3.1)).to_a).to eq [band4, band5]
195195
end
196-
196+
197197
it 'matches objects without raw value' do
198198
expect(Band.where(rating: 3.1).to_a).to eq [band4, band5]
199199
end
@@ -213,7 +213,7 @@
213213
it 'matches objects with raw value' do
214214
expect(Band.where(name: Mongoid::RawValue(1.0)).to_a).to eq [band6, band7]
215215
end
216-
216+
217217
it 'matches objects without raw value' do
218218
expect(Band.where(name: 1.0).to_a).to eq []
219219
end
@@ -231,7 +231,7 @@
231231

232232
context 'Date field' do
233233
it 'does not match objects with raw value' do
234-
expect(Band.where(founded: Mongoid::RawValue(1577923200.0)).to_a).to eq []
234+
expect(Band.where(founded: Mongoid::RawValue(1577923200.0)).to_a).to eq [band7]
235235
end
236236

237237
it 'matches objects without raw value' do
@@ -241,12 +241,11 @@
241241

242242
context 'Time field' do
243243
it 'does not match objects with raw value' do
244-
expect(Band.where(updated_at: Mongoid::RawValue(1578153600.0)).to_a).to eq []
244+
expect(Band.where(updated: Mongoid::RawValue(1578153600.0)).to_a).to eq []
245245
end
246246

247-
# TODO: this isn't working for some reason
248-
xit 'matches objects without raw value' do
249-
expect(Band.where(updated_at: 1578153600.0).to_a).to eq [band4, band5]
247+
it 'matches objects without raw value' do
248+
expect(Band.where(updated: 1578153600.0).to_a).to eq [band4, band5]
250249
end
251250
end
252251
end
@@ -309,22 +308,21 @@
309308

310309
context 'Date field' do
311310
it 'does not match objects with raw value' do
312-
expect(Band.where(founded: Mongoid::RawValue(BigDecimal('1577923200'))).to_a).to eq []
311+
expect(Band.where(founded: Mongoid::RawValue(BigDecimal('1577923200'))).to_a).to eq [band7]
313312
end
314313

315-
xit 'matches objects without raw value' do
314+
it 'matches objects without raw value' do
316315
expect(Band.where(founded: BigDecimal('1577923200')).to_a).to eq [band3, band4]
317316
end
318317
end
319318

320319
context 'Time field' do
321320
it 'does not match objects with raw value' do
322-
expect(Band.where(updated_at: Mongoid::RawValue(BigDecimal('1578153600'))).to_a).to eq []
321+
expect(Band.where(updated: Mongoid::RawValue(BigDecimal('1578153600'))).to_a).to eq []
323322
end
324323

325-
# TODO: this isn't working for some reason
326-
xit 'matches objects without raw value' do
327-
expect(Band.where(updated_at: BigDecimal('1578153600')).to_a).to eq [band4, band5]
324+
it 'matches objects without raw value' do
325+
expect(Band.where(updated: BigDecimal('1578153600')).to_a).to eq [band4, band5]
328326
end
329327
end
330328
end
@@ -353,7 +351,7 @@
353351

354352
context 'BigDecimal field' do
355353
it 'raises a BSON error with raw value' do
356-
expect { Band.where(sales: Mongoid::RawValue(100..300)).to_a }.to eq raise_error BSON::Error::UnserializableClass
354+
expect { Band.where(sales: Mongoid::RawValue(100..300)).to_a }.to raise_error BSON::Error::UnserializableClass
357355
end
358356

359357
it 'matches objects without raw value' do
@@ -387,9 +385,8 @@
387385
expect { Band.where(founded: Mongoid::RawValue(1577923199..1577923201)).to_a }.to raise_error BSON::Error::UnserializableClass
388386
end
389387

390-
# TODO: this isn't working for some reason -- returns all bands
391-
xit 'matches objects without raw value' do
392-
expect(Band.where(founded: 1577923199..1577923201).to_a).to eq [band3, band4]
388+
it 'matches objects without raw value' do
389+
expect(Band.where(founded: 1577923199..1577923201).to_a).to eq [band1, band2, band3, band4]
393390
end
394391
end
395392

@@ -398,9 +395,8 @@
398395
expect { Band.where(founded: Mongoid::RawValue(1578153599..1578153600)).to_a }.to raise_error BSON::Error::UnserializableClass
399396
end
400397

401-
# TODO: this isn't working for some reason
402-
xit 'matches objects without raw value' do
403-
expect(Band.where(updated_at: 1578153599..1578153600).to_a).to eq [band4, band5]
398+
it 'matches objects without raw value' do
399+
expect(Band.where(updated: 1578153599..1578153600).to_a).to eq [band4, band5]
404400
end
405401
end
406402
end

0 commit comments

Comments
 (0)