|
203 | 203 | end
|
204 | 204 | end
|
205 | 205 |
|
206 |
| - describe ".__mongoize_fk__" do |
207 |
| - |
208 |
| - context "when the related model uses object ids" do |
209 |
| - |
210 |
| - let(:association) do |
211 |
| - Person.relations["preferences"] |
212 |
| - end |
213 |
| - |
214 |
| - context "when provided an object id" do |
215 |
| - |
216 |
| - let(:object_id) do |
217 |
| - BSON::ObjectId.new |
218 |
| - end |
219 |
| - |
220 |
| - let(:fk) do |
221 |
| - Array.__mongoize_fk__(association, object_id) |
222 |
| - end |
223 |
| - |
224 |
| - it "returns the object id as an array" do |
225 |
| - expect(fk).to eq([ object_id ]) |
226 |
| - end |
227 |
| - end |
228 |
| - |
229 |
| - context "when provided a object ids" do |
230 |
| - |
231 |
| - let(:object_id) do |
232 |
| - BSON::ObjectId.new |
233 |
| - end |
234 |
| - |
235 |
| - let(:fk) do |
236 |
| - Array.__mongoize_fk__(association, [ object_id ]) |
237 |
| - end |
238 |
| - |
239 |
| - it "returns the object ids" do |
240 |
| - expect(fk).to eq([ object_id ]) |
241 |
| - end |
242 |
| - end |
243 |
| - |
244 |
| - context "when provided a string" do |
245 |
| - |
246 |
| - context "when the string is a legal object id" do |
247 |
| - |
248 |
| - let(:object_id) do |
249 |
| - BSON::ObjectId.new |
250 |
| - end |
251 |
| - |
252 |
| - let(:fk) do |
253 |
| - Array.__mongoize_fk__(association, object_id.to_s) |
254 |
| - end |
255 |
| - |
256 |
| - it "returns the object id in an array" do |
257 |
| - expect(fk).to eq([ object_id ]) |
258 |
| - end |
259 |
| - end |
260 |
| - |
261 |
| - context "when the string is not a legal object id" do |
262 |
| - |
263 |
| - let(:string) do |
264 |
| - "blah" |
265 |
| - end |
266 |
| - |
267 |
| - let(:fk) do |
268 |
| - Array.__mongoize_fk__(association, string) |
269 |
| - end |
270 |
| - |
271 |
| - it "returns the string in an array" do |
272 |
| - expect(fk).to eq([ string ]) |
273 |
| - end |
274 |
| - end |
275 |
| - |
276 |
| - context "when the string is blank" do |
277 |
| - |
278 |
| - let(:fk) do |
279 |
| - Array.__mongoize_fk__(association, "") |
280 |
| - end |
281 |
| - |
282 |
| - it "returns an empty array" do |
283 |
| - expect(fk).to be_empty |
284 |
| - end |
285 |
| - end |
286 |
| - end |
287 |
| - |
288 |
| - context "when provided nil" do |
289 |
| - |
290 |
| - let(:fk) do |
291 |
| - Array.__mongoize_fk__(association, nil) |
292 |
| - end |
293 |
| - |
294 |
| - it "returns an empty array" do |
295 |
| - expect(fk).to be_empty |
296 |
| - end |
297 |
| - end |
298 |
| - |
299 |
| - context "when provided an array of strings" do |
300 |
| - |
301 |
| - context "when the strings are legal object ids" do |
302 |
| - |
303 |
| - let(:object_id) do |
304 |
| - BSON::ObjectId.new |
305 |
| - end |
306 |
| - |
307 |
| - let(:fk) do |
308 |
| - Array.__mongoize_fk__(association, [ object_id.to_s ]) |
309 |
| - end |
310 |
| - |
311 |
| - it "returns the object id in an array" do |
312 |
| - expect(fk).to eq([ object_id ]) |
313 |
| - end |
314 |
| - end |
315 |
| - |
316 |
| - context "when the strings are not legal object ids" do |
317 |
| - |
318 |
| - let(:string) do |
319 |
| - "blah" |
320 |
| - end |
321 |
| - |
322 |
| - let(:fk) do |
323 |
| - Array.__mongoize_fk__(association, [ string ]) |
324 |
| - end |
325 |
| - |
326 |
| - it "returns the string in an array" do |
327 |
| - expect(fk).to eq([ string ]) |
328 |
| - end |
329 |
| - end |
330 |
| - |
331 |
| - context "when the strings are blank" do |
332 |
| - |
333 |
| - let(:fk) do |
334 |
| - Array.__mongoize_fk__(association, [ "", "" ]) |
335 |
| - end |
336 |
| - |
337 |
| - it "returns an empty array" do |
338 |
| - expect(fk).to be_empty |
339 |
| - end |
340 |
| - end |
341 |
| - end |
342 |
| - |
343 |
| - context "when provided nils" do |
344 |
| - |
345 |
| - let(:fk) do |
346 |
| - Array.__mongoize_fk__(association, [ nil, nil, nil ]) |
347 |
| - end |
348 |
| - |
349 |
| - it "returns an empty array" do |
350 |
| - expect(fk).to be_empty |
351 |
| - end |
352 |
| - end |
353 |
| - end |
354 |
| - end |
355 |
| - |
356 | 206 | describe "#__mongoize_time__" do
|
357 | 207 |
|
358 | 208 | let(:array) do
|
|
0 commit comments