|
17 | 17 | let!(:band4) { Band.create!(name: '3', likes: 2, rating: 3.1, decibels: 50..120, founded: today + 1.days, updated_at: now_utc + 3.days) }
|
18 | 18 | let!(:band5) { Band.create!(name: '4', likes: 3, rating: 3.1, decibels: 60..150, founded: today + 2.days, updated_at: now_utc + 3.days, labels: labels) }
|
19 | 19 |
|
20 |
| - context 'Mongoid::RawValue<String> criteria vs Integer field' do |
21 |
| - it 'does not match objects' do |
22 |
| - expect(Band.where(likes: Mongoid::RawValue('1')).to_a).to eq [] |
23 |
| - end |
24 |
| - |
25 |
| - it 'matches objects without raw value' do |
26 |
| - expect(Band.where(likes: '1').to_a).to eq [band2, band3] |
27 |
| - end |
28 |
| - end |
29 |
| - |
30 |
| - context 'Mongoid::RawValue<String> criteria vs Float field' do |
31 |
| - it 'does not match objects' do |
32 |
| - expect(Band.where(rating: Mongoid::RawValue('3.1')).to_a).to eq [] |
33 |
| - end |
34 |
| - |
35 |
| - it 'matches objects without raw value' do |
36 |
| - expect(Band.where(rating: '3.1').to_a).to eq [band4, band5] |
37 |
| - end |
38 |
| - end |
39 |
| - |
40 |
| - context 'Mongoid::RawValue<String> criteria vs String field' do |
41 |
| - it 'matches objects' do |
42 |
| - expect(Band.where(name: Mongoid::RawValue('3')).to_a).to eq [band3, band4] |
43 |
| - end |
44 |
| - |
45 |
| - it 'matches objects without raw value' do |
46 |
| - expect(Band.where(name: '3').to_a).to eq [band3, band4] |
47 |
| - end |
48 |
| - end |
49 |
| - |
50 |
| - context 'Mongoid::RawValue<String> criteria vs Range field' do |
51 |
| - it 'does not match objects' do |
52 |
| - expect(Band.where(decibels: Mongoid::RawValue('90')).to_a).to eq [] |
53 |
| - end |
54 |
| - |
55 |
| - it 'does not match objects without raw value' do |
56 |
| - expect(Band.where(name: '90').to_a).to eq [] |
57 |
| - end |
58 |
| - end |
59 |
| - |
60 |
| - context 'Mongoid::RawValue<String> criteria vs Date field' do |
61 |
| - it 'does not match objects' do |
62 |
| - expect(Band.where(founded: Mongoid::RawValue('2020-01-02')).to_a).to eq [] |
63 |
| - end |
64 |
| - |
65 |
| - it 'matches objects without raw value' do |
66 |
| - expect(Band.where(founded: '2020-01-02').to_a).to eq [band3, band4] |
67 |
| - end |
68 |
| - end |
69 |
| - |
70 |
| - context 'Mongoid::RawValue<String> criteria vs Time field' do |
71 |
| - it 'does not match objects' do |
72 |
| - expect(Band.where(updated_at: Mongoid::RawValue('2020-01-04 16:00:00 UTC')).to_a).to eq [] |
73 |
| - end |
74 |
| - |
75 |
| - # TODO: this isn't working for some reason |
76 |
| - xit 'matches objects without raw value' do |
77 |
| - expect(Band.where(updated_at: '2020-01-04 16:00:00 UTC').to_a).to eq [band4, band5] |
| 20 | + context 'Mongoid::RawValue<String> criteria' do |
| 21 | + |
| 22 | + context 'Integer field' do |
| 23 | + it 'does not match objects' do |
| 24 | + expect(Band.where(likes: Mongoid::RawValue('1')).to_a).to eq [] |
| 25 | + end |
| 26 | + |
| 27 | + it 'matches objects without raw value' do |
| 28 | + expect(Band.where(likes: '1').to_a).to eq [band2, band3] |
| 29 | + end |
| 30 | + end |
| 31 | + |
| 32 | + context 'Float field' do |
| 33 | + it 'does not match objects' do |
| 34 | + expect(Band.where(rating: Mongoid::RawValue('3.1')).to_a).to eq [] |
| 35 | + end |
| 36 | + |
| 37 | + it 'matches objects without raw value' do |
| 38 | + expect(Band.where(rating: '3.1').to_a).to eq [band4, band5] |
| 39 | + end |
| 40 | + end |
| 41 | + |
| 42 | + context 'String field' do |
| 43 | + it 'matches objects' do |
| 44 | + expect(Band.where(name: Mongoid::RawValue('3')).to_a).to eq [band3, band4] |
| 45 | + end |
| 46 | + |
| 47 | + it 'matches objects without raw value' do |
| 48 | + expect(Band.where(name: '3').to_a).to eq [band3, band4] |
| 49 | + end |
| 50 | + end |
| 51 | + |
| 52 | + context 'Range field' do |
| 53 | + it 'does not match objects' do |
| 54 | + expect(Band.where(decibels: Mongoid::RawValue('90')).to_a).to eq [] |
| 55 | + end |
| 56 | + |
| 57 | + it 'does not match objects without raw value' do |
| 58 | + expect(Band.where(name: '90').to_a).to eq [] |
| 59 | + end |
| 60 | + end |
| 61 | + |
| 62 | + context 'Date field' do |
| 63 | + it 'does not match objects' do |
| 64 | + expect(Band.where(founded: Mongoid::RawValue('2020-01-02')).to_a).to eq [] |
| 65 | + end |
| 66 | + |
| 67 | + it 'matches objects without raw value' do |
| 68 | + expect(Band.where(founded: '2020-01-02').to_a).to eq [band3, band4] |
| 69 | + end |
| 70 | + end |
| 71 | + |
| 72 | + context 'Time field' do |
| 73 | + it 'does not match objects' do |
| 74 | + expect(Band.where(updated_at: Mongoid::RawValue('2020-01-04 16:00:00 UTC')).to_a).to eq [] |
| 75 | + end |
| 76 | + |
| 77 | + # TODO: this isn't working for some reason |
| 78 | + xit 'matches objects without raw value' do |
| 79 | + expect(Band.where(updated_at: '2020-01-04 16:00:00 UTC').to_a).to eq [band4, band5] |
| 80 | + end |
78 | 81 | end
|
79 | 82 | end
|
80 | 83 |
|
81 |
| - context 'Mongoid::RawValue<Integer> criteria vs Integer field' do |
82 |
| - it 'does not match objects' do |
83 |
| - expect(Band.where(likes: Mongoid::RawValue(1)).to_a).to eq [band2, band3] |
84 |
| - end |
85 |
| - |
86 |
| - it 'matches objects without raw value' do |
87 |
| - expect(Band.where(likes: 1).to_a).to eq [band2, band3] |
| 84 | + context 'Mongoid::RawValue<Integer>' do |
| 85 | + |
| 86 | + context 'Integer field' do |
| 87 | + it 'does not match objects' do |
| 88 | + expect(Band.where(likes: Mongoid::RawValue(1)).to_a).to eq [band2, band3] |
| 89 | + end |
| 90 | + |
| 91 | + it 'matches objects without raw value' do |
| 92 | + expect(Band.where(likes: 1).to_a).to eq [band2, band3] |
| 93 | + end |
| 94 | + end |
| 95 | + |
| 96 | + context 'Float field' do |
| 97 | + it 'does not match objects' do |
| 98 | + expect(Band.where(rating: Mongoid::RawValue(1)).to_a).to eq [band2] |
| 99 | + expect(Band.where(rating: Mongoid::RawValue(3)).to_a).to eq [] |
| 100 | + end |
| 101 | + |
| 102 | + it 'matches objects without raw value' do |
| 103 | + expect(Band.where(rating: 1).to_a).to eq [band2] |
| 104 | + expect(Band.where(rating: 3).to_a).to eq [] |
| 105 | + end |
| 106 | + end |
| 107 | + |
| 108 | + context 'String field' do |
| 109 | + it 'matches objects' do |
| 110 | + expect(Band.where(name: Mongoid::RawValue(3)).to_a).to eq [] |
| 111 | + end |
| 112 | + |
| 113 | + it 'matches objects without raw value' do |
| 114 | + expect(Band.where(name: 3).to_a).to eq [band3, band4] |
| 115 | + end |
| 116 | + end |
| 117 | + |
| 118 | + context 'Range field' do |
| 119 | + it 'does not match objects' do |
| 120 | + expect(Band.where(decibels: Mongoid::RawValue(90)).to_a).to eq [] |
| 121 | + end |
| 122 | + |
| 123 | + it 'does not match objects without raw value' do |
| 124 | + expect(Band.where(name: 90).to_a).to eq [] |
| 125 | + end |
| 126 | + end |
| 127 | + |
| 128 | + context 'Date field' do |
| 129 | + it 'does not match objects' do |
| 130 | + expect(Band.where(founded: Mongoid::RawValue(1577923200)).to_a).to eq [] |
| 131 | + end |
| 132 | + |
| 133 | + it 'matches objects without raw value' do |
| 134 | + expect(Band.where(founded: 1577923200).to_a).to eq [band3, band4] |
| 135 | + end |
| 136 | + end |
| 137 | + |
| 138 | + context 'Time field' do |
| 139 | + it 'does not match objects' do |
| 140 | + expect(Band.where(updated_at: Mongoid::RawValue(1578153600)).to_a).to eq [] |
| 141 | + end |
| 142 | + |
| 143 | + # TODO: this isn't working for some reason |
| 144 | + xit 'matches objects without raw value' do |
| 145 | + expect(Band.where(updated_at: 1578153600).to_a).to eq [band4, band5] |
| 146 | + end |
88 | 147 | end
|
89 | 148 | end
|
90 | 149 |
|
91 |
| - context 'Mongoid::RawValue<Integer> criteria vs Float field' do |
92 |
| - it 'does not match objects' do |
93 |
| - expect(Band.where(rating: Mongoid::RawValue(1)).to_a).to eq [band2] |
94 |
| - expect(Band.where(rating: Mongoid::RawValue(3)).to_a).to eq [] |
95 |
| - end |
96 |
| - |
97 |
| - it 'matches objects without raw value' do |
98 |
| - expect(Band.where(rating: 1).to_a).to eq [band2] |
99 |
| - expect(Band.where(rating: 3).to_a).to eq [] |
100 |
| - end |
101 |
| - end |
102 |
| - |
103 |
| - context 'Mongoid::RawValue<Integer> criteria vs String field' do |
104 |
| - it 'matches objects' do |
105 |
| - expect(Band.where(name: Mongoid::RawValue(3)).to_a).to eq [] |
106 |
| - end |
107 |
| - |
108 |
| - it 'matches objects without raw value' do |
109 |
| - expect(Band.where(name: 3).to_a).to eq [band3, band4] |
| 150 | + context 'Mongoid::RawValue<Float>' do |
| 151 | + |
| 152 | + context 'Integer field' do |
| 153 | + it 'does not match objects' do |
| 154 | + expect(Band.where(likes: Mongoid::RawValue(1.0)).to_a).to eq [band2, band3] |
| 155 | + end |
| 156 | + |
| 157 | + it 'matches objects without raw value' do |
| 158 | + expect(Band.where(likes: 1.0).to_a).to eq [band2, band3] |
| 159 | + end |
| 160 | + end |
| 161 | + |
| 162 | + context 'Float field' do |
| 163 | + it 'does not match objects' do |
| 164 | + expect(Band.where(rating: Mongoid::RawValue(3.1)).to_a).to eq [band4, band5] |
| 165 | + end |
| 166 | + |
| 167 | + it 'matches objects without raw value' do |
| 168 | + expect(Band.where(rating: 3.1).to_a).to eq [band4, band5] |
| 169 | + end |
| 170 | + end |
| 171 | + |
| 172 | + context 'String field' do |
| 173 | + it 'matches objects' do |
| 174 | + expect(Band.where(name: Mongoid::RawValue(3.0)).to_a).to eq [] |
| 175 | + end |
| 176 | + |
| 177 | + it 'matches objects without raw value' do |
| 178 | + expect(Band.where(name: 3.0).to_a).to eq [] |
| 179 | + end |
| 180 | + end |
| 181 | + |
| 182 | + context 'Range field' do |
| 183 | + it 'does not match objects' do |
| 184 | + expect(Band.where(decibels: Mongoid::RawValue(90.0)).to_a).to eq [] |
| 185 | + end |
| 186 | + |
| 187 | + it 'does not match objects without raw value' do |
| 188 | + expect(Band.where(name: 90.0).to_a).to eq [] |
| 189 | + end |
| 190 | + end |
| 191 | + |
| 192 | + context 'Date field' do |
| 193 | + it 'does not match objects' do |
| 194 | + expect(Band.where(founded: Mongoid::RawValue(1577923200.0)).to_a).to eq [] |
| 195 | + end |
| 196 | + |
| 197 | + it 'matches objects without raw value' do |
| 198 | + expect(Band.where(founded: 1577923200.0).to_a).to eq [band3, band4] |
| 199 | + end |
| 200 | + end |
| 201 | + |
| 202 | + context 'Time field' do |
| 203 | + it 'does not match objects' do |
| 204 | + expect(Band.where(updated_at: Mongoid::RawValue(1578153600.0)).to_a).to eq [] |
| 205 | + end |
| 206 | + |
| 207 | + # TODO: this isn't working for some reason |
| 208 | + xit 'matches objects without raw value' do |
| 209 | + expect(Band.where(updated_at: 1578153600.0).to_a).to eq [band4, band5] |
| 210 | + end |
110 | 211 | end
|
111 | 212 | end
|
112 | 213 | end
|
0 commit comments