mongoid 7.0.13 → 9.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1421) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -41
  3. data/LICENSE +1 -1
  4. data/README.md +29 -25
  5. data/Rakefile +150 -40
  6. data/lib/config/locales/en.yml +364 -108
  7. data/lib/mongoid/association/accessors.rb +205 -107
  8. data/lib/mongoid/association/bindable.rb +102 -56
  9. data/lib/mongoid/association/builders.rb +24 -26
  10. data/lib/mongoid/association/constrainable.rb +8 -11
  11. data/lib/mongoid/association/depending.rb +65 -59
  12. data/lib/mongoid/association/eager.rb +203 -0
  13. data/lib/mongoid/association/eager_load/discriminated_inclusion.rb +88 -0
  14. data/lib/mongoid/association/eager_load/embedded_distributor.rb +151 -0
  15. data/lib/mongoid/association/eager_load/inclusion.rb +173 -0
  16. data/lib/mongoid/association/eager_load/inclusion_tree.rb +96 -0
  17. data/lib/mongoid/association/eager_load/lookup_pipeline.rb +121 -0
  18. data/lib/mongoid/association/eager_load/polymorphic_preloader.rb +61 -0
  19. data/lib/mongoid/association/eager_load/polymorphic_targets.rb +151 -0
  20. data/lib/mongoid/association/eager_loadable.rb +135 -15
  21. data/lib/mongoid/association/embedded/batchable.rb +87 -75
  22. data/lib/mongoid/association/embedded/cyclic.rb +16 -25
  23. data/lib/mongoid/association/embedded/eager.rb +18 -0
  24. data/lib/mongoid/association/embedded/embedded_in/binding.rb +30 -14
  25. data/lib/mongoid/association/embedded/embedded_in/buildable.rb +10 -7
  26. data/lib/mongoid/association/embedded/embedded_in/proxy.rb +39 -32
  27. data/lib/mongoid/association/embedded/embedded_in.rb +37 -46
  28. data/lib/mongoid/association/embedded/embeds_many/binding.rb +7 -11
  29. data/lib/mongoid/association/embedded/embeds_many/buildable.rb +11 -7
  30. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +309 -243
  31. data/lib/mongoid/association/embedded/embeds_many.rb +32 -56
  32. data/lib/mongoid/association/embedded/embeds_one/binding.rb +6 -11
  33. data/lib/mongoid/association/embedded/embeds_one/buildable.rb +25 -11
  34. data/lib/mongoid/association/embedded/embeds_one/proxy.rb +145 -53
  35. data/lib/mongoid/association/embedded/embeds_one.rb +30 -50
  36. data/lib/mongoid/association/embedded.rb +3 -0
  37. data/lib/mongoid/association/macros.rb +97 -56
  38. data/lib/mongoid/association/many.rb +99 -36
  39. data/lib/mongoid/association/marshalable.rb +5 -7
  40. data/lib/mongoid/association/nested/many.rb +86 -47
  41. data/lib/mongoid/association/nested/nested_buildable.rb +58 -21
  42. data/lib/mongoid/association/nested/one.rb +81 -36
  43. data/lib/mongoid/association/nested.rb +4 -5
  44. data/lib/mongoid/association/one.rb +5 -14
  45. data/lib/mongoid/association/options.rb +48 -53
  46. data/lib/mongoid/association/proxy.rb +65 -54
  47. data/lib/mongoid/association/referenced/auto_save.rb +59 -20
  48. data/lib/mongoid/association/referenced/belongs_to/binding.rb +21 -22
  49. data/lib/mongoid/association/referenced/belongs_to/buildable.rb +32 -11
  50. data/lib/mongoid/association/referenced/belongs_to/eager.rb +47 -6
  51. data/lib/mongoid/association/referenced/belongs_to/proxy.rb +35 -42
  52. data/lib/mongoid/association/referenced/belongs_to.rb +77 -77
  53. data/lib/mongoid/association/referenced/counter_cache.rb +24 -35
  54. data/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb +26 -15
  55. data/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb +12 -7
  56. data/lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb +3 -4
  57. data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +202 -133
  58. data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +81 -83
  59. data/lib/mongoid/association/referenced/has_many/binding.rb +3 -7
  60. data/lib/mongoid/association/referenced/has_many/buildable.rb +15 -8
  61. data/lib/mongoid/association/referenced/has_many/eager.rb +3 -4
  62. data/lib/mongoid/association/referenced/has_many/enumerable.rb +601 -456
  63. data/lib/mongoid/association/referenced/has_many/proxy.rb +344 -216
  64. data/lib/mongoid/association/referenced/has_many.rb +58 -74
  65. data/lib/mongoid/association/referenced/has_many_through/eager.rb +99 -0
  66. data/lib/mongoid/association/referenced/has_many_through/proxy.rb +68 -0
  67. data/lib/mongoid/association/referenced/has_many_through.rb +201 -0
  68. data/lib/mongoid/association/referenced/has_one/binding.rb +4 -10
  69. data/lib/mongoid/association/referenced/has_one/buildable.rb +29 -17
  70. data/lib/mongoid/association/referenced/has_one/eager.rb +4 -6
  71. data/lib/mongoid/association/referenced/has_one/proxy.rb +51 -47
  72. data/lib/mongoid/association/referenced/has_one.rb +45 -55
  73. data/lib/mongoid/association/referenced/has_one_through/eager.rb +65 -0
  74. data/lib/mongoid/association/referenced/has_one_through/proxy.rb +30 -0
  75. data/lib/mongoid/association/referenced/has_one_through.rb +167 -0
  76. data/lib/mongoid/association/referenced/syncable.rb +44 -62
  77. data/lib/mongoid/association/referenced/with_polymorphic_criteria.rb +41 -0
  78. data/lib/mongoid/association/referenced.rb +4 -0
  79. data/lib/mongoid/association/reflections.rb +11 -12
  80. data/lib/mongoid/association/relatable.rb +173 -146
  81. data/lib/mongoid/association.rb +35 -40
  82. data/lib/mongoid/atomic/modifiers.rb +91 -74
  83. data/lib/mongoid/atomic/paths/embedded/many.rb +25 -11
  84. data/lib/mongoid/atomic/paths/embedded/one.rb +6 -10
  85. data/lib/mongoid/atomic/paths/embedded.rb +5 -8
  86. data/lib/mongoid/atomic/paths/root.rb +5 -10
  87. data/lib/mongoid/atomic/paths.rb +4 -3
  88. data/lib/mongoid/atomic.rb +41 -89
  89. data/lib/mongoid/atomic_update_preparer.rb +89 -0
  90. data/lib/mongoid/attributes/dynamic.rb +12 -27
  91. data/lib/mongoid/attributes/embedded.rb +34 -0
  92. data/lib/mongoid/attributes/nested.rb +22 -25
  93. data/lib/mongoid/attributes/processing.rb +51 -34
  94. data/lib/mongoid/attributes/projector.rb +107 -0
  95. data/lib/mongoid/attributes/readonly.rb +15 -17
  96. data/lib/mongoid/attributes.rb +119 -126
  97. data/lib/mongoid/cacheable.rb +30 -14
  98. data/lib/mongoid/changeable.rb +196 -99
  99. data/lib/mongoid/clients/factory.rb +73 -17
  100. data/lib/mongoid/clients/options.rb +140 -19
  101. data/lib/mongoid/clients/sessions.rb +239 -87
  102. data/lib/mongoid/clients/storage_options.rb +42 -17
  103. data/lib/mongoid/clients/validators/storage.rb +6 -25
  104. data/lib/mongoid/clients/validators.rb +3 -2
  105. data/lib/mongoid/clients.rb +44 -22
  106. data/lib/mongoid/collection_configurable.rb +63 -0
  107. data/lib/mongoid/composable.rb +40 -39
  108. data/lib/mongoid/config/defaults.rb +46 -0
  109. data/lib/mongoid/config/encryption.rb +228 -0
  110. data/lib/mongoid/config/environment.rb +26 -13
  111. data/lib/mongoid/config/introspection.rb +150 -0
  112. data/lib/mongoid/config/options.rb +37 -26
  113. data/lib/mongoid/config/validators/async_query_executor.rb +31 -0
  114. data/lib/mongoid/config/validators/client.rb +20 -37
  115. data/lib/mongoid/config/validators/option.rb +5 -7
  116. data/lib/mongoid/config/validators.rb +5 -3
  117. data/lib/mongoid/config.rb +418 -60
  118. data/lib/mongoid/contextual/aggregable/memory.rb +45 -28
  119. data/lib/mongoid/contextual/aggregable/mongo.rb +49 -47
  120. data/lib/mongoid/contextual/aggregable/none.rb +64 -0
  121. data/lib/mongoid/contextual/aggregable.rb +16 -0
  122. data/lib/mongoid/contextual/atomic.rb +126 -45
  123. data/lib/mongoid/contextual/command.rb +3 -6
  124. data/lib/mongoid/contextual/map_reduce.rb +23 -49
  125. data/lib/mongoid/contextual/memory.rb +448 -121
  126. data/lib/mongoid/contextual/mongo/documents_loader.rb +177 -0
  127. data/lib/mongoid/contextual/mongo.rb +707 -351
  128. data/lib/mongoid/contextual/none.rb +249 -33
  129. data/lib/mongoid/contextual/queryable.rb +6 -6
  130. data/lib/mongoid/contextual.rb +40 -15
  131. data/lib/mongoid/copyable.rb +45 -21
  132. data/lib/mongoid/criteria/findable.rb +65 -27
  133. data/lib/mongoid/criteria/includable.rb +97 -45
  134. data/lib/mongoid/criteria/inspectable.rb +6 -6
  135. data/lib/mongoid/criteria/marshalable.rb +15 -10
  136. data/lib/mongoid/criteria/modifiable.rb +8 -28
  137. data/lib/mongoid/criteria/options.rb +2 -5
  138. data/lib/mongoid/criteria/permission.rb +40 -37
  139. data/lib/mongoid/criteria/queryable/aggregable.rb +13 -24
  140. data/lib/mongoid/criteria/queryable/expandable.rb +64 -0
  141. data/lib/mongoid/criteria/queryable/extensions/array.rb +14 -50
  142. data/lib/mongoid/criteria/queryable/extensions/big_decimal.rb +29 -13
  143. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +6 -9
  144. data/lib/mongoid/criteria/queryable/extensions/date.rb +13 -16
  145. data/lib/mongoid/criteria/queryable/extensions/date_time.rb +14 -18
  146. data/lib/mongoid/criteria/queryable/extensions/hash.rb +5 -44
  147. data/lib/mongoid/criteria/queryable/extensions/nil_class.rb +23 -24
  148. data/lib/mongoid/criteria/queryable/extensions/numeric.rb +31 -29
  149. data/lib/mongoid/criteria/queryable/extensions/object.rb +15 -37
  150. data/lib/mongoid/criteria/queryable/extensions/range.rb +52 -22
  151. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +22 -25
  152. data/lib/mongoid/criteria/queryable/extensions/set.rb +8 -10
  153. data/lib/mongoid/criteria/queryable/extensions/string.rb +24 -41
  154. data/lib/mongoid/criteria/queryable/extensions/symbol.rb +10 -28
  155. data/lib/mongoid/criteria/queryable/extensions/time.rb +11 -14
  156. data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -20
  157. data/lib/mongoid/criteria/queryable/extensions.rb +19 -24
  158. data/lib/mongoid/criteria/queryable/key.rb +49 -30
  159. data/lib/mongoid/criteria/queryable/macroable.rb +3 -6
  160. data/lib/mongoid/criteria/queryable/mergeable.rb +203 -46
  161. data/lib/mongoid/criteria/queryable/optional.rb +32 -81
  162. data/lib/mongoid/criteria/queryable/options.rb +24 -29
  163. data/lib/mongoid/criteria/queryable/pipeline.rb +11 -23
  164. data/lib/mongoid/criteria/queryable/selectable.rb +558 -242
  165. data/lib/mongoid/criteria/queryable/selector.rb +134 -43
  166. data/lib/mongoid/criteria/queryable/smash.rb +41 -21
  167. data/lib/mongoid/criteria/queryable/storable.rb +219 -0
  168. data/lib/mongoid/criteria/queryable.rb +41 -27
  169. data/lib/mongoid/criteria/scopable.rb +37 -30
  170. data/lib/mongoid/criteria/translator.rb +43 -0
  171. data/lib/mongoid/criteria.rb +257 -152
  172. data/lib/mongoid/deprecable.rb +78 -0
  173. data/lib/mongoid/deprecation.rb +25 -0
  174. data/lib/mongoid/document.rb +277 -171
  175. data/lib/mongoid/encryptable.rb +98 -0
  176. data/lib/mongoid/equality.rb +29 -31
  177. data/lib/mongoid/errors/ambiguous_relationship.rb +6 -9
  178. data/lib/mongoid/errors/attribute_not_loaded.rb +31 -0
  179. data/lib/mongoid/errors/callback.rb +3 -6
  180. data/lib/mongoid/errors/config_redactor.rb +43 -0
  181. data/lib/mongoid/errors/create_collection_failure.rb +31 -0
  182. data/lib/mongoid/errors/criteria_argument_required.rb +16 -0
  183. data/lib/mongoid/errors/delete_restriction.rb +11 -16
  184. data/lib/mongoid/errors/document_not_destroyed.rb +5 -10
  185. data/lib/mongoid/errors/document_not_found.rb +37 -27
  186. data/lib/mongoid/errors/drop_collection_failure.rb +25 -0
  187. data/lib/mongoid/errors/empty_config_file.rb +23 -0
  188. data/lib/mongoid/errors/immutable_attribute.rb +24 -0
  189. data/lib/mongoid/errors/in_memory_collation_not_supported.rb +3 -6
  190. data/lib/mongoid/errors/in_memory_regexp_timeout.rb +26 -0
  191. data/lib/mongoid/errors/invalid_around_callback.rb +16 -0
  192. data/lib/mongoid/errors/invalid_async_query_executor.rb +23 -0
  193. data/lib/mongoid/errors/invalid_auto_encryption_configuration.rb +30 -0
  194. data/lib/mongoid/errors/invalid_collection.rb +3 -3
  195. data/lib/mongoid/errors/invalid_config_file.rb +23 -0
  196. data/lib/mongoid/errors/invalid_config_option.rb +5 -8
  197. data/lib/mongoid/errors/invalid_dependent_strategy.rb +9 -13
  198. data/lib/mongoid/errors/invalid_discriminator_key_target.rb +23 -0
  199. data/lib/mongoid/errors/invalid_dot_dollar_assignment.rb +21 -0
  200. data/lib/mongoid/errors/invalid_elem_match_operator.rb +29 -0
  201. data/lib/mongoid/errors/invalid_estimated_count_criteria.rb +24 -0
  202. data/lib/mongoid/errors/invalid_estimated_count_scoping.rb +24 -0
  203. data/lib/mongoid/errors/invalid_expression_operator.rb +24 -0
  204. data/lib/mongoid/errors/invalid_field.rb +10 -11
  205. data/lib/mongoid/errors/invalid_field_operator.rb +29 -0
  206. data/lib/mongoid/errors/invalid_field_option.rb +4 -7
  207. data/lib/mongoid/errors/invalid_field_type.rb +24 -0
  208. data/lib/mongoid/errors/invalid_find.rb +3 -6
  209. data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +20 -0
  210. data/lib/mongoid/errors/invalid_includes.rb +5 -8
  211. data/lib/mongoid/errors/invalid_index.rb +3 -6
  212. data/lib/mongoid/errors/invalid_options.rb +5 -8
  213. data/lib/mongoid/errors/invalid_path.rb +3 -6
  214. data/lib/mongoid/errors/invalid_persistence_option.rb +6 -11
  215. data/lib/mongoid/errors/invalid_query.rb +36 -0
  216. data/lib/mongoid/errors/invalid_relation.rb +15 -22
  217. data/lib/mongoid/errors/invalid_relation_option.rb +8 -11
  218. data/lib/mongoid/errors/invalid_scope.rb +3 -6
  219. data/lib/mongoid/errors/invalid_session_nesting.rb +14 -0
  220. data/lib/mongoid/errors/invalid_set_polymorphic_relation.rb +8 -9
  221. data/lib/mongoid/errors/invalid_storage_options.rb +4 -7
  222. data/lib/mongoid/errors/invalid_time.rb +3 -6
  223. data/lib/mongoid/errors/invalid_transaction_nesting.rb +14 -0
  224. data/lib/mongoid/errors/inverse_not_found.rb +4 -7
  225. data/lib/mongoid/errors/mixed_client_configuration.rb +4 -7
  226. data/lib/mongoid/errors/mixed_relations.rb +3 -5
  227. data/lib/mongoid/errors/mongoid_error.rb +13 -23
  228. data/lib/mongoid/errors/nested_attributes_metadata_not_found.rb +4 -7
  229. data/lib/mongoid/errors/no_client_config.rb +5 -8
  230. data/lib/mongoid/errors/no_client_database.rb +5 -8
  231. data/lib/mongoid/errors/no_client_hosts.rb +5 -8
  232. data/lib/mongoid/errors/no_clients_config.rb +3 -6
  233. data/lib/mongoid/errors/no_default_client.rb +4 -7
  234. data/lib/mongoid/errors/no_encryption_schema.rb +28 -0
  235. data/lib/mongoid/errors/no_environment.rb +3 -6
  236. data/lib/mongoid/errors/no_map_reduce_output.rb +3 -6
  237. data/lib/mongoid/errors/no_metadata.rb +3 -6
  238. data/lib/mongoid/errors/no_parent.rb +3 -6
  239. data/lib/mongoid/errors/readonly_association.rb +29 -0
  240. data/lib/mongoid/errors/readonly_attribute.rb +4 -7
  241. data/lib/mongoid/errors/readonly_document.rb +4 -9
  242. data/lib/mongoid/errors/rollback.rb +13 -0
  243. data/lib/mongoid/errors/scope_overwrite.rb +4 -4
  244. data/lib/mongoid/errors/sessions_not_supported.rb +14 -0
  245. data/lib/mongoid/errors/too_many_nested_attribute_records.rb +4 -3
  246. data/lib/mongoid/errors/transaction_error.rb +22 -0
  247. data/lib/mongoid/errors/transactions_not_supported.rb +14 -0
  248. data/lib/mongoid/errors/unknown_attribute.rb +4 -7
  249. data/lib/mongoid/errors/unknown_model.rb +3 -6
  250. data/lib/mongoid/errors/unrecognized_model_alias.rb +53 -0
  251. data/lib/mongoid/errors/unrecognized_resolver.rb +27 -0
  252. data/lib/mongoid/errors/unregistered_class.rb +47 -0
  253. data/lib/mongoid/errors/unsaved_document.rb +4 -4
  254. data/lib/mongoid/errors/unsupported_isolation_level.rb +22 -0
  255. data/lib/mongoid/errors/unsupported_javascript.rb +3 -6
  256. data/lib/mongoid/errors/validations.rb +5 -5
  257. data/lib/mongoid/errors.rb +82 -51
  258. data/lib/mongoid/evolvable.rb +4 -7
  259. data/lib/mongoid/extensions/array.rb +32 -55
  260. data/lib/mongoid/extensions/big_decimal.rb +45 -24
  261. data/lib/mongoid/extensions/binary.rb +42 -0
  262. data/lib/mongoid/extensions/boolean.rb +12 -8
  263. data/lib/mongoid/extensions/bson_document.rb +28 -0
  264. data/lib/mongoid/extensions/date.rb +38 -30
  265. data/lib/mongoid/extensions/date_time.rb +8 -22
  266. data/lib/mongoid/extensions/decimal128.rb +4 -8
  267. data/lib/mongoid/extensions/false_class.rb +11 -13
  268. data/lib/mongoid/extensions/float.rb +15 -19
  269. data/lib/mongoid/extensions/hash.rb +31 -116
  270. data/lib/mongoid/extensions/integer.rb +17 -21
  271. data/lib/mongoid/extensions/module.rb +6 -7
  272. data/lib/mongoid/extensions/nil_class.rb +6 -7
  273. data/lib/mongoid/extensions/object.rb +42 -84
  274. data/lib/mongoid/extensions/object_id.rb +5 -11
  275. data/lib/mongoid/extensions/range.rb +49 -25
  276. data/lib/mongoid/extensions/raw_value.rb +31 -0
  277. data/lib/mongoid/extensions/regexp.rb +16 -10
  278. data/lib/mongoid/extensions/set.rb +27 -15
  279. data/lib/mongoid/extensions/string.rb +40 -67
  280. data/lib/mongoid/extensions/symbol.rb +11 -26
  281. data/lib/mongoid/extensions/time.rb +49 -47
  282. data/lib/mongoid/extensions/time_with_zone.rb +30 -12
  283. data/lib/mongoid/extensions/true_class.rb +11 -13
  284. data/lib/mongoid/extensions/vector.rb +64 -0
  285. data/lib/mongoid/extensions.rb +28 -41
  286. data/lib/mongoid/factory.rb +205 -28
  287. data/lib/mongoid/field_readable.rb +69 -0
  288. data/lib/mongoid/fields/encrypted.rb +47 -0
  289. data/lib/mongoid/fields/foreign_key.rb +48 -35
  290. data/lib/mongoid/fields/localized.rb +33 -21
  291. data/lib/mongoid/fields/standard.rb +31 -48
  292. data/lib/mongoid/fields/validators/macro.rb +48 -45
  293. data/lib/mongoid/fields/validators.rb +3 -2
  294. data/lib/mongoid/fields.rb +499 -117
  295. data/lib/mongoid/findable.rb +174 -64
  296. data/lib/mongoid/identifiable.rb +28 -0
  297. data/lib/mongoid/indexable/specification.rb +76 -39
  298. data/lib/mongoid/indexable/validators/options.rb +36 -43
  299. data/lib/mongoid/indexable.rb +57 -58
  300. data/lib/mongoid/inspectable.rb +37 -15
  301. data/lib/mongoid/interceptable.rb +235 -66
  302. data/lib/mongoid/loadable.rb +146 -0
  303. data/lib/mongoid/loggable.rb +12 -18
  304. data/lib/mongoid/matchable.rb +7 -154
  305. data/lib/mongoid/matcher/all.rb +34 -0
  306. data/lib/mongoid/matcher/and.rb +32 -0
  307. data/lib/mongoid/matcher/bits.rb +65 -0
  308. data/lib/mongoid/matcher/bits_all_clear.rb +39 -0
  309. data/lib/mongoid/matcher/bits_all_set.rb +39 -0
  310. data/lib/mongoid/matcher/bits_any_clear.rb +39 -0
  311. data/lib/mongoid/matcher/bits_any_set.rb +39 -0
  312. data/lib/mongoid/matcher/elem_match.rb +49 -0
  313. data/lib/mongoid/matcher/elem_match_expression.rb +29 -0
  314. data/lib/mongoid/matcher/eq.rb +23 -0
  315. data/lib/mongoid/matcher/eq_impl.rb +79 -0
  316. data/lib/mongoid/matcher/eq_impl_with_regexp.rb +33 -0
  317. data/lib/mongoid/matcher/exists.rb +27 -0
  318. data/lib/mongoid/matcher/expression.rb +43 -0
  319. data/lib/mongoid/matcher/expression_operator.rb +31 -0
  320. data/lib/mongoid/matcher/field_expression.rb +74 -0
  321. data/lib/mongoid/matcher/field_operator.rb +76 -0
  322. data/lib/mongoid/matcher/gt.rb +29 -0
  323. data/lib/mongoid/matcher/gte.rb +29 -0
  324. data/lib/mongoid/matcher/in.rb +37 -0
  325. data/lib/mongoid/matcher/lt.rb +29 -0
  326. data/lib/mongoid/matcher/lte.rb +29 -0
  327. data/lib/mongoid/matcher/mod.rb +29 -0
  328. data/lib/mongoid/matcher/ne.rb +28 -0
  329. data/lib/mongoid/matcher/nin.rb +23 -0
  330. data/lib/mongoid/matcher/nor.rb +34 -0
  331. data/lib/mongoid/matcher/not.rb +42 -0
  332. data/lib/mongoid/matcher/or.rb +32 -0
  333. data/lib/mongoid/matcher/regex.rb +61 -0
  334. data/lib/mongoid/matcher/regexp_budget.rb +372 -0
  335. data/lib/mongoid/matcher/size.rb +39 -0
  336. data/lib/mongoid/matcher/type.rb +119 -0
  337. data/lib/mongoid/matcher.rb +141 -0
  338. data/lib/mongoid/model_resolver.rb +155 -0
  339. data/lib/mongoid/persistable/creatable.rb +50 -36
  340. data/lib/mongoid/persistable/deletable.rb +18 -30
  341. data/lib/mongoid/persistable/destroyable.rb +38 -14
  342. data/lib/mongoid/persistable/incrementable.rb +8 -10
  343. data/lib/mongoid/persistable/logical.rb +7 -10
  344. data/lib/mongoid/persistable/maxable.rb +35 -0
  345. data/lib/mongoid/persistable/minable.rb +35 -0
  346. data/lib/mongoid/persistable/multipliable.rb +34 -0
  347. data/lib/mongoid/persistable/poppable.rb +5 -9
  348. data/lib/mongoid/persistable/pullable.rb +6 -12
  349. data/lib/mongoid/persistable/pushable.rb +8 -14
  350. data/lib/mongoid/persistable/renamable.rb +11 -10
  351. data/lib/mongoid/persistable/savable.rb +16 -11
  352. data/lib/mongoid/persistable/settable.rb +7 -18
  353. data/lib/mongoid/persistable/unsettable.rb +11 -12
  354. data/lib/mongoid/persistable/updatable.rb +113 -35
  355. data/lib/mongoid/persistable/upsertable.rb +37 -12
  356. data/lib/mongoid/persistable.rb +169 -60
  357. data/lib/mongoid/persistence_context.rb +189 -75
  358. data/lib/mongoid/pluckable.rb +130 -0
  359. data/lib/mongoid/positional.rb +7 -15
  360. data/lib/mongoid/railtie.rb +36 -32
  361. data/lib/mongoid/railties/bson_object_id_serializer.rb +46 -0
  362. data/lib/mongoid/railties/console_sandbox.rb +40 -0
  363. data/lib/mongoid/railties/controller_runtime.rb +34 -20
  364. data/lib/mongoid/railties/database.rake +53 -29
  365. data/lib/mongoid/reloadable.rb +56 -45
  366. data/lib/mongoid/scopable.rb +50 -79
  367. data/lib/mongoid/search_indexable.rb +538 -0
  368. data/lib/mongoid/selectable.rb +8 -19
  369. data/lib/mongoid/serializable.rb +46 -40
  370. data/lib/mongoid/shardable.rb +102 -23
  371. data/lib/mongoid/stateful.rb +67 -26
  372. data/lib/mongoid/stringified_symbol.rb +61 -0
  373. data/lib/mongoid/tasks/database.rake +46 -15
  374. data/lib/mongoid/tasks/database.rb +204 -31
  375. data/lib/mongoid/tasks/encryption.rake +59 -0
  376. data/lib/mongoid/tasks/encryption.rb +103 -0
  377. data/lib/mongoid/threaded/lifecycle.rb +13 -34
  378. data/lib/mongoid/threaded.rb +353 -108
  379. data/lib/mongoid/timestamps/created/short.rb +4 -3
  380. data/lib/mongoid/timestamps/created.rb +15 -7
  381. data/lib/mongoid/timestamps/short.rb +2 -1
  382. data/lib/mongoid/timestamps/timeless.rb +127 -29
  383. data/lib/mongoid/timestamps/updated/short.rb +4 -3
  384. data/lib/mongoid/timestamps/updated.rb +6 -9
  385. data/lib/mongoid/timestamps.rb +7 -7
  386. data/lib/mongoid/touchable.rb +176 -40
  387. data/lib/mongoid/traversable.rb +309 -106
  388. data/lib/mongoid/utils.rb +52 -0
  389. data/lib/mongoid/validatable/associated.rb +115 -22
  390. data/lib/mongoid/validatable/format.rb +2 -2
  391. data/lib/mongoid/validatable/length.rb +2 -2
  392. data/lib/mongoid/validatable/localizable.rb +3 -6
  393. data/lib/mongoid/validatable/macros.rb +25 -14
  394. data/lib/mongoid/validatable/numericality.rb +40 -0
  395. data/lib/mongoid/validatable/presence.rb +15 -21
  396. data/lib/mongoid/validatable/queryable.rb +9 -4
  397. data/lib/mongoid/validatable/uniqueness.rb +40 -53
  398. data/lib/mongoid/validatable.rb +41 -52
  399. data/lib/mongoid/version.rb +6 -2
  400. data/lib/mongoid/warnings.rb +40 -0
  401. data/lib/mongoid.rb +105 -44
  402. data/lib/rails/generators/mongoid/config/config_generator.rb +18 -5
  403. data/lib/rails/generators/mongoid/config/templates/mongoid.rb +24 -0
  404. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +51 -56
  405. data/lib/rails/generators/mongoid/model/model_generator.rb +10 -8
  406. data/lib/rails/generators/mongoid_generator.rb +17 -7
  407. data/lib/rails/mongoid.rb +4 -32
  408. data/spec/README.md +19 -4
  409. data/spec/config/mongoid.yml +17 -1
  410. data/spec/config/mongoid_with_schema_map_uuid.yml +27 -0
  411. data/spec/integration/active_job_spec.rb +35 -0
  412. data/spec/integration/app_spec.rb +327 -144
  413. data/spec/integration/associations/belongs_to_spec.rb +165 -0
  414. data/spec/integration/associations/embedded_dirty_spec.rb +57 -0
  415. data/spec/integration/associations/embedded_spec.rb +241 -67
  416. data/spec/integration/associations/embeds_many_spec.rb +347 -0
  417. data/spec/integration/associations/embeds_one_spec.rb +62 -0
  418. data/spec/integration/associations/foreign_key_spec.rb +107 -0
  419. data/spec/integration/associations/foreign_key_spec_models.rb +64 -0
  420. data/spec/integration/associations/has_and_belongs_to_many_spec.rb +161 -0
  421. data/spec/integration/associations/has_many_spec.rb +184 -0
  422. data/spec/integration/associations/has_one_spec.rb +322 -0
  423. data/spec/integration/associations/nested_attributes_assignment_spec.rb +113 -0
  424. data/spec/integration/associations/reverse_population_spec.rb +34 -0
  425. data/spec/integration/associations/reverse_population_spec_models.rb +36 -0
  426. data/spec/integration/associations/scope_option_spec.rb +100 -0
  427. data/spec/integration/atomic/modifiers_spec.rb +137 -0
  428. data/spec/integration/bson_regexp_raw_spec.rb +19 -0
  429. data/spec/integration/caching_spec.rb +68 -0
  430. data/spec/integration/callbacks_models.rb +149 -3
  431. data/spec/integration/callbacks_spec.rb +422 -34
  432. data/spec/integration/contextual/empty_spec.rb +141 -0
  433. data/spec/integration/criteria/alias_query_spec.rb +91 -0
  434. data/spec/integration/criteria/date_field_spec.rb +1 -2
  435. data/spec/integration/criteria/default_scope_spec.rb +78 -0
  436. data/spec/integration/criteria/logical_spec.rb +105 -0
  437. data/spec/integration/criteria/range_spec.rb +349 -0
  438. data/spec/integration/criteria/raw_value_spec.rb +538 -0
  439. data/spec/integration/criteria/time_with_zone_spec.rb +135 -15
  440. data/spec/integration/discriminator_key_spec.rb +392 -0
  441. data/spec/integration/discriminator_value_spec.rb +204 -0
  442. data/spec/integration/document_spec.rb +32 -3
  443. data/spec/integration/dots_and_dollars_spec.rb +273 -0
  444. data/spec/integration/encryption_spec.rb +248 -0
  445. data/spec/integration/i18n_fallbacks_spec.rb +47 -0
  446. data/spec/integration/isolation_state_spec.rb +241 -0
  447. data/spec/integration/matcher_examples_spec.rb +743 -0
  448. data/spec/integration/matcher_operator_data/all.yml +140 -0
  449. data/spec/integration/matcher_operator_data/and.yml +93 -0
  450. data/spec/integration/matcher_operator_data/bits_all_clear.yml +144 -0
  451. data/spec/integration/matcher_operator_data/bits_all_set.yml +144 -0
  452. data/spec/integration/matcher_operator_data/bits_any_clear.yml +144 -0
  453. data/spec/integration/matcher_operator_data/bits_any_set.yml +144 -0
  454. data/spec/integration/matcher_operator_data/comment.yml +22 -0
  455. data/spec/integration/matcher_operator_data/elem_match.yml +409 -0
  456. data/spec/integration/matcher_operator_data/elem_match_expr.yml +213 -0
  457. data/spec/integration/matcher_operator_data/eq.yml +191 -0
  458. data/spec/integration/matcher_operator_data/exists.yml +213 -0
  459. data/spec/integration/matcher_operator_data/generic_op.yml +17 -0
  460. data/spec/integration/matcher_operator_data/gt.yml +132 -0
  461. data/spec/integration/matcher_operator_data/gt_types.yml +63 -0
  462. data/spec/integration/matcher_operator_data/gte.yml +132 -0
  463. data/spec/integration/matcher_operator_data/gte_types.yml +15 -0
  464. data/spec/integration/matcher_operator_data/implicit.yml +331 -0
  465. data/spec/integration/matcher_operator_data/implicit_traversal.yml +112 -0
  466. data/spec/integration/matcher_operator_data/in.yml +210 -0
  467. data/spec/integration/matcher_operator_data/invalid_op.yml +59 -0
  468. data/spec/integration/matcher_operator_data/invalid_syntax.yml +39 -0
  469. data/spec/integration/matcher_operator_data/lt.yml +132 -0
  470. data/spec/integration/matcher_operator_data/lt_types.yml +15 -0
  471. data/spec/integration/matcher_operator_data/lte.yml +132 -0
  472. data/spec/integration/matcher_operator_data/lte_types.yml +15 -0
  473. data/spec/integration/matcher_operator_data/mod.yml +55 -0
  474. data/spec/integration/matcher_operator_data/multiple.yml +29 -0
  475. data/spec/integration/matcher_operator_data/ne.yml +150 -0
  476. data/spec/integration/matcher_operator_data/ne_types.yml +15 -0
  477. data/spec/integration/matcher_operator_data/nin.yml +114 -0
  478. data/spec/integration/matcher_operator_data/nor.yml +126 -0
  479. data/spec/integration/matcher_operator_data/not.yml +196 -0
  480. data/spec/integration/matcher_operator_data/or.yml +137 -0
  481. data/spec/integration/matcher_operator_data/regex.yml +195 -0
  482. data/spec/integration/matcher_operator_data/regex_options.yml +72 -0
  483. data/spec/integration/matcher_operator_data/size.yml +171 -0
  484. data/spec/integration/matcher_operator_data/type.yml +64 -0
  485. data/spec/integration/matcher_operator_data/type_array.yml +15 -0
  486. data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
  487. data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
  488. data/spec/integration/matcher_operator_data/type_code.yml +26 -0
  489. data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
  490. data/spec/integration/matcher_operator_data/type_date.yml +39 -0
  491. data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
  492. data/spec/integration/matcher_operator_data/type_decimal.yml +37 -0
  493. data/spec/integration/matcher_operator_data/type_double.yml +15 -0
  494. data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
  495. data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
  496. data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
  497. data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
  498. data/spec/integration/matcher_operator_data/type_null.yml +23 -0
  499. data/spec/integration/matcher_operator_data/type_object.yml +23 -0
  500. data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
  501. data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
  502. data/spec/integration/matcher_operator_data/type_string.yml +15 -0
  503. data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
  504. data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
  505. data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
  506. data/spec/integration/matcher_operator_spec.rb +113 -0
  507. data/spec/integration/matcher_regexp_timeout_spec.rb +215 -0
  508. data/spec/integration/matcher_spec.rb +237 -0
  509. data/spec/integration/persistence/collection_options_spec.rb +34 -0
  510. data/spec/integration/persistence/range_field_spec.rb +373 -0
  511. data/spec/integration/query_operator_guard_spec.rb +89 -0
  512. data/spec/integration/server_query_spec.rb +148 -0
  513. data/spec/integration/shardable_spec.rb +148 -0
  514. data/spec/integration/stringified_symbol_field_spec.rb +189 -0
  515. data/spec/lite_spec_helper.rb +56 -19
  516. data/spec/mongoid/association/accessors_spec.rb +375 -273
  517. data/spec/mongoid/association/auto_save_spec.rb +215 -106
  518. data/spec/mongoid/association/builders_spec.rb +124 -74
  519. data/spec/mongoid/association/constrainable_spec.rb +11 -21
  520. data/spec/mongoid/association/counter_cache_spec.rb +101 -131
  521. data/spec/mongoid/association/depending_spec.rb +454 -402
  522. data/spec/mongoid/association/eager_loadable_spec.rb +47 -0
  523. data/spec/mongoid/association/eager_spec.rb +471 -60
  524. data/spec/mongoid/association/embedded/cyclic_spec.rb +40 -49
  525. data/spec/mongoid/association/embedded/dirty_spec.rb +19 -21
  526. data/spec/mongoid/association/embedded/embedded_in/binding_spec.rb +39 -53
  527. data/spec/mongoid/association/embedded/embedded_in/buildable_spec.rb +58 -8
  528. data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +208 -158
  529. data/spec/mongoid/association/embedded/embedded_in_spec.rb +46 -134
  530. data/spec/mongoid/association/embedded/embeds_many/binding_spec.rb +11 -13
  531. data/spec/mongoid/association/embedded/embeds_many/buildable_spec.rb +137 -35
  532. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +1716 -1327
  533. data/spec/mongoid/association/embedded/embeds_many_models.rb +191 -2
  534. data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +68 -0
  535. data/spec/mongoid/association/embedded/embeds_many_spec.rb +77 -119
  536. data/spec/mongoid/association/embedded/embeds_one/binding_spec.rb +17 -22
  537. data/spec/mongoid/association/embedded/embeds_one/buildable_spec.rb +44 -24
  538. data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +234 -287
  539. data/spec/mongoid/association/embedded/embeds_one_dnl_models.rb +2 -0
  540. data/spec/mongoid/association/embedded/embeds_one_models.rb +27 -1
  541. data/spec/mongoid/association/embedded/embeds_one_query_spec.rb +28 -0
  542. data/spec/mongoid/association/embedded/embeds_one_spec.rb +50 -134
  543. data/spec/mongoid/association/fallback_spec.rb +425 -0
  544. data/spec/mongoid/association/macros_spec.rb +250 -308
  545. data/spec/mongoid/association/nested/many_spec.rb +53 -72
  546. data/spec/mongoid/association/nested/one_spec.rb +68 -85
  547. data/spec/mongoid/association/options_spec.rb +189 -309
  548. data/spec/mongoid/association/polymorphic_spec.rb +36 -51
  549. data/spec/mongoid/association/referenced/belongs_to/binding_spec.rb +58 -75
  550. data/spec/mongoid/association/referenced/belongs_to/buildable_spec.rb +131 -40
  551. data/spec/mongoid/association/referenced/belongs_to/eager_spec.rb +280 -52
  552. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +345 -370
  553. data/spec/mongoid/association/referenced/belongs_to_models.rb +13 -0
  554. data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +57 -0
  555. data/spec/mongoid/association/referenced/belongs_to_spec.rb +171 -329
  556. data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +45 -56
  557. data/spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb +66 -29
  558. data/spec/mongoid/association/referenced/has_and_belongs_to_many/eager_spec.rb +75 -36
  559. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_persistence_spec.rb +28 -8
  560. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +1151 -1283
  561. data/spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb +69 -2
  562. data/spec/mongoid/association/referenced/has_and_belongs_to_many_query_spec.rb +39 -0
  563. data/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb +176 -166
  564. data/spec/mongoid/association/referenced/has_many/binding_spec.rb +32 -43
  565. data/spec/mongoid/association/referenced/has_many/buildable_spec.rb +161 -24
  566. data/spec/mongoid/association/referenced/has_many/eager_spec.rb +169 -67
  567. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1021 -689
  568. data/spec/mongoid/association/referenced/has_many/proxy_query_spec.rb +1 -1
  569. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +1743 -1955
  570. data/spec/mongoid/association/referenced/has_many_models.rb +85 -1
  571. data/spec/mongoid/association/referenced/has_many_query_spec.rb +37 -0
  572. data/spec/mongoid/association/referenced/has_many_spec.rb +83 -178
  573. data/spec/mongoid/association/referenced/has_many_through/eager_spec.rb +58 -0
  574. data/spec/mongoid/association/referenced/has_many_through/proxy_spec.rb +62 -0
  575. data/spec/mongoid/association/referenced/has_many_through_spec.rb +399 -0
  576. data/spec/mongoid/association/referenced/has_one/binding_spec.rb +28 -37
  577. data/spec/mongoid/association/referenced/has_one/buildable_spec.rb +74 -28
  578. data/spec/mongoid/association/referenced/has_one/eager_spec.rb +60 -42
  579. data/spec/mongoid/association/referenced/has_one/proxy_spec.rb +380 -333
  580. data/spec/mongoid/association/referenced/has_one_models.rb +73 -0
  581. data/spec/mongoid/association/referenced/has_one_query_spec.rb +37 -0
  582. data/spec/mongoid/association/referenced/has_one_spec.rb +61 -185
  583. data/spec/mongoid/association/referenced/has_one_through/eager_spec.rb +58 -0
  584. data/spec/mongoid/association/referenced/has_one_through/proxy_spec.rb +49 -0
  585. data/spec/mongoid/association/referenced/has_one_through_spec.rb +211 -0
  586. data/spec/mongoid/association/reflections_spec.rb +16 -23
  587. data/spec/mongoid/association/syncable_spec.rb +132 -138
  588. data/spec/mongoid/association_spec.rb +59 -65
  589. data/spec/mongoid/atomic/modifiers_spec.rb +217 -180
  590. data/spec/mongoid/atomic/paths/embedded/many_spec.rb +41 -51
  591. data/spec/mongoid/atomic/paths/embedded/one_spec.rb +37 -48
  592. data/spec/mongoid/atomic/paths/root_spec.rb +11 -14
  593. data/spec/mongoid/atomic/paths_spec.rb +133 -128
  594. data/spec/mongoid/atomic_spec.rb +187 -154
  595. data/spec/mongoid/atomic_update_preparer_spec.rb +83 -0
  596. data/spec/mongoid/attributes/dynamic_spec.rb +5 -6
  597. data/spec/mongoid/attributes/embedded_spec.rb +118 -0
  598. data/spec/mongoid/attributes/nested_spec.rb +1604 -1737
  599. data/spec/mongoid/attributes/nested_spec_models.rb +48 -0
  600. data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
  601. data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
  602. data/spec/mongoid/attributes/projector_spec.rb +37 -0
  603. data/spec/mongoid/attributes/readonly_spec.rb +106 -108
  604. data/spec/mongoid/attributes_spec.rb +1217 -715
  605. data/spec/mongoid/cacheable_spec.rb +78 -45
  606. data/spec/mongoid/changeable_spec.rb +914 -638
  607. data/spec/mongoid/clients/factory_spec.rb +314 -137
  608. data/spec/mongoid/clients/options_spec.rb +205 -76
  609. data/spec/mongoid/clients/sessions_spec.rb +73 -116
  610. data/spec/mongoid/clients/transactions_spec.rb +1128 -186
  611. data/spec/mongoid/clients/transactions_spec_models.rb +251 -0
  612. data/spec/mongoid/clients_spec.rb +433 -312
  613. data/spec/mongoid/collection_configurable_spec.rb +156 -0
  614. data/spec/mongoid/composable_spec.rb +4 -8
  615. data/spec/mongoid/config/defaults_spec.rb +125 -0
  616. data/spec/mongoid/config/encryption_spec.rb +377 -0
  617. data/spec/mongoid/config/environment_spec.rb +129 -49
  618. data/spec/mongoid/config/introspection_spec.rb +119 -0
  619. data/spec/mongoid/config/options_spec.rb +36 -23
  620. data/spec/mongoid/config_spec.rb +497 -148
  621. data/spec/mongoid/contextual/aggregable/memory_spec.rb +507 -161
  622. data/spec/mongoid/contextual/aggregable/memory_table.yml +88 -0
  623. data/spec/mongoid/contextual/aggregable/memory_table_spec.rb +60 -0
  624. data/spec/mongoid/contextual/aggregable/mongo_spec.rb +242 -158
  625. data/spec/mongoid/contextual/aggregable/none_spec.rb +47 -0
  626. data/spec/mongoid/contextual/atomic_spec.rb +510 -229
  627. data/spec/mongoid/contextual/map_reduce_spec.rb +114 -153
  628. data/spec/mongoid/contextual/memory_spec.rb +1947 -563
  629. data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +193 -0
  630. data/spec/mongoid/contextual/mongo_spec.rb +3317 -1268
  631. data/spec/mongoid/contextual/none_spec.rb +98 -89
  632. data/spec/mongoid/contextual/short_circuit_spec.rb +139 -0
  633. data/spec/mongoid/copyable_spec.rb +769 -191
  634. data/spec/mongoid/copyable_spec_models.rb +30 -0
  635. data/spec/mongoid/criteria/findable_spec.rb +565 -506
  636. data/spec/mongoid/criteria/includable_spec.rb +2417 -0
  637. data/spec/mongoid/criteria/includable_spec_models.rb +64 -0
  638. data/spec/mongoid/criteria/inspectable_spec.rb +13 -13
  639. data/spec/mongoid/criteria/marshalable_spec.rb +29 -12
  640. data/spec/mongoid/criteria/modifiable_spec.rb +388 -530
  641. data/spec/mongoid/criteria/options_spec.rb +4 -6
  642. data/spec/mongoid/criteria/queryable/aggregable_spec.rb +114 -140
  643. data/spec/mongoid/criteria/queryable/expandable_spec.rb +59 -0
  644. data/spec/mongoid/criteria/queryable/extensions/array_spec.rb +132 -198
  645. data/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb +199 -25
  646. data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +86 -116
  647. data/spec/mongoid/criteria/queryable/extensions/date_spec.rb +69 -67
  648. data/spec/mongoid/criteria/queryable/extensions/date_time_spec.rb +121 -113
  649. data/spec/mongoid/criteria/queryable/extensions/float_spec.rb +96 -32
  650. data/spec/mongoid/criteria/queryable/extensions/hash_spec.rb +105 -152
  651. data/spec/mongoid/criteria/queryable/extensions/integer_spec.rb +97 -33
  652. data/spec/mongoid/criteria/queryable/extensions/nil_class_spec.rb +27 -37
  653. data/spec/mongoid/criteria/queryable/extensions/numeric_spec.rb +79 -15
  654. data/spec/mongoid/criteria/queryable/extensions/object_spec.rb +34 -53
  655. data/spec/mongoid/criteria/queryable/extensions/range_spec.rb +259 -191
  656. data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +18 -34
  657. data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +16 -33
  658. data/spec/mongoid/criteria/queryable/extensions/set_spec.rb +14 -18
  659. data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +91 -189
  660. data/spec/mongoid/criteria/queryable/extensions/symbol_spec.rb +34 -100
  661. data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +99 -103
  662. data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +78 -85
  663. data/spec/mongoid/criteria/queryable/key_spec.rb +34 -35
  664. data/spec/mongoid/criteria/queryable/mergeable_spec.rb +150 -21
  665. data/spec/mongoid/criteria/queryable/optional_spec.rb +375 -954
  666. data/spec/mongoid/criteria/queryable/options_spec.rb +175 -123
  667. data/spec/mongoid/criteria/queryable/pipeline_spec.rb +67 -86
  668. data/spec/mongoid/criteria/queryable/queryable_spec.rb +43 -52
  669. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +2101 -414
  670. data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +35 -0
  671. data/spec/mongoid/criteria/queryable/selectable_spec.rb +1283 -3140
  672. data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +754 -0
  673. data/spec/mongoid/criteria/queryable/selector_spec.rb +404 -317
  674. data/spec/mongoid/criteria/queryable/smash_spec.rb +8 -10
  675. data/spec/mongoid/criteria/queryable/storable_spec.rb +249 -0
  676. data/spec/mongoid/criteria/queryable_mql_spec.rb +92 -0
  677. data/spec/mongoid/criteria/scopable_spec.rb +212 -118
  678. data/spec/mongoid/criteria/translator_spec.rb +132 -0
  679. data/spec/mongoid/criteria_projection_spec.rb +389 -0
  680. data/spec/mongoid/criteria_spec.rb +1942 -2301
  681. data/spec/mongoid/document_fields_spec.rb +187 -14
  682. data/spec/mongoid/document_persistence_context_spec.rb +80 -6
  683. data/spec/mongoid/document_query_spec.rb +87 -0
  684. data/spec/mongoid/document_spec.rb +394 -538
  685. data/spec/mongoid/encryptable_spec.rb +61 -0
  686. data/spec/mongoid/equality_spec.rb +77 -103
  687. data/spec/mongoid/errors/ambiguous_relationship_spec.rb +10 -10
  688. data/spec/mongoid/errors/attribute_not_loaded_spec.rb +29 -0
  689. data/spec/mongoid/errors/callback_spec.rb +10 -10
  690. data/spec/mongoid/errors/config_redactor_spec.rb +112 -0
  691. data/spec/mongoid/errors/delete_restriction_spec.rb +9 -9
  692. data/spec/mongoid/errors/document_not_destroyed_spec.rb +9 -9
  693. data/spec/mongoid/errors/document_not_found_spec.rb +108 -32
  694. data/spec/mongoid/errors/invalid_collection_spec.rb +11 -12
  695. data/spec/mongoid/errors/invalid_config_file_spec.rb +29 -0
  696. data/spec/mongoid/errors/invalid_config_option_spec.rb +10 -10
  697. data/spec/mongoid/errors/invalid_field_option_spec.rb +9 -9
  698. data/spec/mongoid/errors/invalid_field_spec.rb +13 -11
  699. data/spec/mongoid/errors/invalid_field_type_spec.rb +53 -0
  700. data/spec/mongoid/errors/invalid_find_spec.rb +10 -10
  701. data/spec/mongoid/errors/invalid_includes_spec.rb +11 -12
  702. data/spec/mongoid/errors/invalid_index_spec.rb +10 -10
  703. data/spec/mongoid/errors/invalid_options_spec.rb +10 -10
  704. data/spec/mongoid/errors/invalid_path_spec.rb +9 -9
  705. data/spec/mongoid/errors/invalid_relation_spec.rb +17 -15
  706. data/spec/mongoid/errors/invalid_scope_spec.rb +10 -10
  707. data/spec/mongoid/errors/invalid_set_polymorphic_relation_spec.rb +5 -5
  708. data/spec/mongoid/errors/invalid_storage_options_spec.rb +10 -10
  709. data/spec/mongoid/errors/invalid_time_spec.rb +10 -10
  710. data/spec/mongoid/errors/inverse_not_found_spec.rb +11 -11
  711. data/spec/mongoid/errors/mixed_client_configuration_spec.rb +42 -11
  712. data/spec/mongoid/errors/mixed_relations_spec.rb +10 -10
  713. data/spec/mongoid/errors/mongoid_error_spec.rb +23 -23
  714. data/spec/mongoid/errors/nested_attributes_metadata_not_found_spec.rb +10 -10
  715. data/spec/mongoid/errors/no_client_config_spec.rb +11 -11
  716. data/spec/mongoid/errors/no_client_database_spec.rb +40 -11
  717. data/spec/mongoid/errors/no_client_hosts_spec.rb +37 -11
  718. data/spec/mongoid/errors/no_clients_config_spec.rb +9 -9
  719. data/spec/mongoid/errors/no_environment_spec.rb +10 -10
  720. data/spec/mongoid/errors/no_map_reduce_output_spec.rb +10 -10
  721. data/spec/mongoid/errors/no_metadata_spec.rb +9 -9
  722. data/spec/mongoid/errors/no_parent_spec.rb +10 -10
  723. data/spec/mongoid/errors/readonly_association_spec.rb +34 -0
  724. data/spec/mongoid/errors/readonly_attribute_spec.rb +9 -9
  725. data/spec/mongoid/errors/readonly_document_spec.rb +9 -9
  726. data/spec/mongoid/errors/scope_overwrite_spec.rb +11 -11
  727. data/spec/mongoid/errors/too_many_nested_attribute_records_spec.rb +11 -11
  728. data/spec/mongoid/errors/unknown_attribute_spec.rb +9 -9
  729. data/spec/mongoid/errors/unsaved_document_spec.rb +10 -10
  730. data/spec/mongoid/errors/unsupported_javascript_spec.rb +11 -11
  731. data/spec/mongoid/errors/validations_spec.rb +13 -13
  732. data/spec/mongoid/extensions/array_spec.rb +92 -377
  733. data/spec/mongoid/extensions/big_decimal_spec.rb +640 -217
  734. data/spec/mongoid/extensions/binary_spec.rb +50 -23
  735. data/spec/mongoid/extensions/boolean_spec.rb +73 -107
  736. data/spec/mongoid/extensions/date_class_mongoize_spec.rb +329 -0
  737. data/spec/mongoid/extensions/date_spec.rb +62 -173
  738. data/spec/mongoid/extensions/date_time_spec.rb +42 -95
  739. data/spec/mongoid/extensions/decimal128_spec.rb +14 -17
  740. data/spec/mongoid/extensions/false_class_spec.rb +13 -24
  741. data/spec/mongoid/extensions/float_spec.rb +66 -100
  742. data/spec/mongoid/extensions/hash_spec.rb +79 -165
  743. data/spec/mongoid/extensions/integer_spec.rb +63 -91
  744. data/spec/mongoid/extensions/module_spec.rb +15 -17
  745. data/spec/mongoid/extensions/nil_class_spec.rb +4 -4
  746. data/spec/mongoid/extensions/object_id_spec.rb +161 -246
  747. data/spec/mongoid/extensions/object_spec.rb +36 -238
  748. data/spec/mongoid/extensions/range_spec.rb +259 -69
  749. data/spec/mongoid/extensions/raw_value_spec.rb +65 -0
  750. data/spec/mongoid/extensions/regexp_spec.rb +56 -41
  751. data/spec/mongoid/extensions/set_spec.rb +110 -14
  752. data/spec/mongoid/extensions/string_spec.rb +139 -237
  753. data/spec/mongoid/extensions/stringified_symbol_spec.rb +71 -0
  754. data/spec/mongoid/extensions/symbol_spec.rb +19 -62
  755. data/spec/mongoid/extensions/time_spec.rb +394 -192
  756. data/spec/mongoid/extensions/time_with_zone_spec.rb +111 -176
  757. data/spec/mongoid/extensions/true_class_spec.rb +13 -24
  758. data/spec/mongoid/extensions/vector_spec.rb +175 -0
  759. data/spec/mongoid/factory_spec.rb +378 -80
  760. data/spec/mongoid/fields/foreign_key_spec.rb +387 -267
  761. data/spec/mongoid/fields/localized_spec.rb +197 -196
  762. data/spec/mongoid/fields/standard_spec.rb +45 -58
  763. data/spec/mongoid/fields_spec.rb +1448 -525
  764. data/spec/mongoid/findable_spec.rb +659 -230
  765. data/spec/mongoid/indexable/specification_spec.rb +145 -40
  766. data/spec/mongoid/indexable_spec.rb +551 -188
  767. data/spec/mongoid/inspectable_spec.rb +126 -18
  768. data/spec/mongoid/interceptable_spec.rb +1431 -573
  769. data/spec/mongoid/interceptable_spec_models.rb +244 -0
  770. data/spec/mongoid/loadable_spec.rb +86 -0
  771. data/spec/mongoid/loading_spec.rb +114 -0
  772. data/spec/mongoid/loggable_spec.rb +5 -5
  773. data/spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml +104 -0
  774. data/spec/mongoid/matcher/extract_attribute_data/traversal.yml +239 -0
  775. data/spec/mongoid/matcher/extract_attribute_spec.rb +33 -0
  776. data/spec/mongoid/matcher/regexp_budget_spec.rb +570 -0
  777. data/spec/mongoid/model_resolver_spec.rb +167 -0
  778. data/spec/mongoid/mongoizable_spec.rb +277 -0
  779. data/spec/mongoid/monkey_patches_spec.rb +215 -0
  780. data/spec/mongoid/persistable/creatable_spec.rb +256 -209
  781. data/spec/mongoid/persistable/deletable_spec.rb +369 -80
  782. data/spec/mongoid/persistable/destroyable_spec.rb +439 -80
  783. data/spec/mongoid/persistable/incrementable_spec.rb +112 -77
  784. data/spec/mongoid/persistable/logical_spec.rb +92 -51
  785. data/spec/mongoid/persistable/maxable_spec.rb +148 -0
  786. data/spec/mongoid/persistable/minable_spec.rb +148 -0
  787. data/spec/mongoid/persistable/multipliable_spec.rb +212 -0
  788. data/spec/mongoid/persistable/poppable_spec.rb +87 -47
  789. data/spec/mongoid/persistable/pullable_spec.rb +161 -82
  790. data/spec/mongoid/persistable/pushable_spec.rb +188 -110
  791. data/spec/mongoid/persistable/renamable_spec.rb +91 -51
  792. data/spec/mongoid/persistable/savable_spec.rb +373 -155
  793. data/spec/mongoid/persistable/settable_spec.rb +164 -134
  794. data/spec/mongoid/persistable/unsettable_spec.rb +94 -58
  795. data/spec/mongoid/persistable/updatable_spec.rb +235 -267
  796. data/spec/mongoid/persistable/upsertable_spec.rb +150 -38
  797. data/spec/mongoid/persistable_spec.rb +198 -128
  798. data/spec/mongoid/persistence_context_spec.rb +133 -137
  799. data/spec/mongoid/positional_spec.rb +69 -78
  800. data/spec/mongoid/railties/bson_object_id_serializer_spec.rb +27 -0
  801. data/spec/mongoid/railties/console_sandbox_spec.rb +43 -0
  802. data/spec/mongoid/relations/proxy_spec.rb +8 -6
  803. data/spec/mongoid/reloadable_spec.rb +552 -123
  804. data/spec/mongoid/scopable_spec.rb +522 -455
  805. data/spec/mongoid/search_indexable_spec.rb +838 -0
  806. data/spec/mongoid/selectable_spec.rb +41 -53
  807. data/spec/mongoid/serializable_spec.rb +394 -319
  808. data/spec/mongoid/shardable_models.rb +76 -0
  809. data/spec/mongoid/shardable_spec.rb +245 -41
  810. data/spec/mongoid/stateful_spec.rb +170 -45
  811. data/spec/mongoid/tasks/database_rake_spec.rb +284 -133
  812. data/spec/mongoid/tasks/database_spec.rb +245 -51
  813. data/spec/mongoid/tasks/encryption_spec.rb +189 -0
  814. data/spec/mongoid/threaded_spec.rb +118 -85
  815. data/spec/mongoid/timestamps/created/short_spec.rb +15 -16
  816. data/spec/mongoid/timestamps/created_spec.rb +36 -14
  817. data/spec/mongoid/timestamps/timeless_spec.rb +230 -47
  818. data/spec/mongoid/timestamps/updated/short_spec.rb +26 -30
  819. data/spec/mongoid/timestamps/updated_spec.rb +23 -27
  820. data/spec/mongoid/timestamps_spec.rb +408 -34
  821. data/spec/mongoid/timestamps_spec_models.rb +67 -0
  822. data/spec/mongoid/touchable_spec.rb +1235 -136
  823. data/spec/mongoid/touchable_spec_models.rb +178 -0
  824. data/spec/mongoid/traversable_spec.rb +1188 -79
  825. data/spec/mongoid/validatable/associated_spec.rb +86 -89
  826. data/spec/mongoid/validatable/format_spec.rb +26 -33
  827. data/spec/mongoid/validatable/length_spec.rb +64 -85
  828. data/spec/mongoid/validatable/numericality_spec.rb +124 -14
  829. data/spec/mongoid/validatable/presence_spec.rb +168 -215
  830. data/spec/mongoid/validatable/uniqueness_spec.rb +702 -826
  831. data/spec/mongoid/validatable_spec.rb +76 -105
  832. data/spec/mongoid/warnings_spec.rb +32 -0
  833. data/spec/mongoid_spec.rb +67 -30
  834. data/spec/rails/controller_extension/controller_runtime_spec.rb +59 -60
  835. data/spec/rails/mongoid_spec.rb +38 -139
  836. data/spec/shared/CANDIDATE.md +28 -0
  837. data/spec/shared/bin/s3-copy +45 -0
  838. data/spec/shared/bin/s3-upload +69 -0
  839. data/spec/shared/lib/mrss/cluster_config.rb +16 -41
  840. data/spec/shared/lib/mrss/constraints.rb +44 -59
  841. data/spec/shared/lib/mrss/docker_runner.rb +42 -20
  842. data/spec/shared/lib/mrss/eg_config_utils.rb +20 -0
  843. data/spec/shared/lib/mrss/event_subscriber.rb +210 -0
  844. data/spec/shared/lib/mrss/lite_constraints.rb +48 -1
  845. data/spec/shared/lib/mrss/release/candidate.rb +287 -0
  846. data/spec/shared/lib/mrss/release/product_data.rb +144 -0
  847. data/spec/shared/lib/mrss/server_version_registry.rb +18 -24
  848. data/spec/shared/lib/mrss/session_registry.rb +69 -0
  849. data/spec/shared/lib/mrss/session_registry_legacy.rb +60 -0
  850. data/spec/shared/lib/mrss/spec_organizer.rb +48 -2
  851. data/spec/shared/lib/mrss/utils.rb +28 -6
  852. data/spec/shared/lib/tasks/candidate.rake +64 -0
  853. data/spec/shared/share/Dockerfile.erb +114 -96
  854. data/spec/shared/share/haproxy-1.conf +16 -0
  855. data/spec/shared/share/haproxy-2.conf +17 -0
  856. data/spec/shared/shlib/config.sh +27 -0
  857. data/spec/shared/shlib/distro.sh +12 -1
  858. data/spec/shared/shlib/server.sh +148 -65
  859. data/spec/shared/shlib/set_env.sh +56 -80
  860. data/spec/spec_helper.rb +104 -72
  861. data/spec/support/authorization.rb +2 -0
  862. data/spec/support/client_registry.rb +9 -0
  863. data/spec/support/constraints.rb +37 -22
  864. data/spec/support/crypt/models.rb +206 -0
  865. data/spec/support/crypt.rb +77 -0
  866. data/spec/support/expectations.rb +38 -17
  867. data/spec/support/feature_sandbox.rb +69 -0
  868. data/spec/support/helpers.rb +11 -0
  869. data/spec/support/immutable_ids.rb +118 -0
  870. data/spec/support/macros.rb +106 -1
  871. data/spec/support/models/account.rb +38 -0
  872. data/spec/support/models/acolyte.rb +20 -0
  873. data/spec/support/models/actor.rb +21 -0
  874. data/spec/support/models/actress.rb +4 -0
  875. data/spec/support/models/address.rb +88 -0
  876. data/spec/support/models/address_component.rb +8 -0
  877. data/spec/support/models/address_number.rb +9 -0
  878. data/spec/support/models/agency.rb +8 -0
  879. data/spec/support/models/agent.rb +19 -0
  880. data/spec/support/models/album.rb +20 -0
  881. data/spec/support/models/alert.rb +10 -0
  882. data/spec/support/models/animal.rb +28 -0
  883. data/spec/support/models/answer.rb +9 -0
  884. data/spec/support/models/appointment.rb +10 -0
  885. data/spec/support/models/armrest.rb +9 -0
  886. data/spec/support/models/article.rb +14 -0
  887. data/spec/support/models/artist.rb +95 -0
  888. data/spec/support/models/artwork.rb +7 -0
  889. data/spec/support/models/audible_sound.rb +3 -0
  890. data/spec/support/models/audio.rb +8 -0
  891. data/spec/support/models/augmentation.rb +25 -0
  892. data/spec/support/models/author.rb +9 -0
  893. data/spec/support/models/baby.rb +7 -0
  894. data/spec/support/models/band.rb +46 -0
  895. data/spec/support/models/bar.rb +13 -0
  896. data/spec/support/models/basic.rb +8 -0
  897. data/spec/support/models/bed.rb +3 -0
  898. data/spec/support/models/big_palette.rb +4 -0
  899. data/spec/support/models/birthday.rb +14 -0
  900. data/spec/support/models/bolt.rb +7 -0
  901. data/spec/support/models/bomb.rb +7 -0
  902. data/spec/support/models/book.rb +20 -0
  903. data/spec/support/models/breed.rb +7 -0
  904. data/spec/support/models/browser.rb +8 -0
  905. data/spec/support/models/building.rb +10 -0
  906. data/spec/support/models/building_address.rb +10 -0
  907. data/spec/support/models/bus.rb +10 -0
  908. data/spec/support/models/business.rb +8 -0
  909. data/spec/support/models/callback_test.rb +12 -0
  910. data/spec/support/models/canvas.rb +27 -0
  911. data/spec/support/models/car.rb +3 -0
  912. data/spec/support/models/cat.rb +9 -0
  913. data/spec/support/models/catalog.rb +24 -0
  914. data/spec/support/models/category.rb +11 -0
  915. data/spec/support/models/child.rb +7 -0
  916. data/spec/support/models/child_doc.rb +24 -0
  917. data/spec/support/models/church.rb +9 -0
  918. data/spec/support/models/circle.rb +5 -0
  919. data/spec/support/models/circuit.rb +7 -0
  920. data/spec/support/models/circus.rb +12 -0
  921. data/spec/support/models/code.rb +17 -0
  922. data/spec/support/models/coding/pull_request.rb +11 -0
  923. data/spec/support/models/coding.rb +3 -0
  924. data/spec/support/models/comment.rb +18 -0
  925. data/spec/support/models/company.rb +9 -0
  926. data/spec/support/models/consumption_period.rb +9 -0
  927. data/spec/support/models/contextable_item.rb +8 -0
  928. data/spec/support/models/contractor.rb +8 -0
  929. data/spec/support/models/cookie.rb +8 -0
  930. data/spec/support/models/country_code.rb +12 -0
  931. data/spec/support/models/courier_job.rb +7 -0
  932. data/spec/support/models/cover.rb +10 -0
  933. data/spec/support/models/crate.rb +12 -0
  934. data/spec/support/models/customer.rb +10 -0
  935. data/spec/support/models/customer_address.rb +11 -0
  936. data/spec/support/models/deed.rb +8 -0
  937. data/spec/support/models/definition.rb +12 -0
  938. data/spec/support/models/delegating_patient.rb +15 -0
  939. data/spec/support/models/description.rb +13 -0
  940. data/spec/support/models/dictionary.rb +19 -0
  941. data/spec/support/models/division.rb +13 -0
  942. data/spec/support/models/doctor.rb +14 -0
  943. data/spec/support/models/dog.rb +10 -0
  944. data/spec/support/models/dokument.rb +9 -0
  945. data/spec/support/models/draft.rb +11 -0
  946. data/spec/support/models/dragon.rb +7 -0
  947. data/spec/support/models/driver.rb +10 -0
  948. data/spec/support/models/drug.rb +9 -0
  949. data/spec/support/models/dungeon.rb +7 -0
  950. data/spec/support/models/edit.rb +8 -0
  951. data/spec/support/models/email.rb +9 -0
  952. data/spec/support/models/employer.rb +7 -0
  953. data/spec/support/models/entry.rb +9 -0
  954. data/spec/support/models/eraser.rb +3 -0
  955. data/spec/support/models/even.rb +10 -0
  956. data/spec/support/models/event.rb +24 -0
  957. data/spec/support/models/exhibition.rb +7 -0
  958. data/spec/support/models/exhibitor.rb +9 -0
  959. data/spec/support/models/explosion.rb +7 -0
  960. data/spec/support/models/eye.rb +11 -0
  961. data/spec/support/models/eye_bowl.rb +11 -0
  962. data/spec/support/models/face.rb +10 -0
  963. data/spec/support/models/fanatic.rb +9 -0
  964. data/spec/support/models/favorite.rb +15 -0
  965. data/spec/support/models/filesystem.rb +8 -0
  966. data/spec/support/models/fire_hydrant.rb +9 -0
  967. data/spec/support/models/firefox.rb +6 -0
  968. data/spec/support/models/fish.rb +9 -0
  969. data/spec/support/models/folder.rb +8 -0
  970. data/spec/support/models/folder_item.rb +10 -0
  971. data/spec/support/models/fruits.rb +41 -0
  972. data/spec/support/models/game.rb +21 -0
  973. data/spec/support/models/ghost.rb +9 -0
  974. data/spec/support/models/guitar.rb +4 -0
  975. data/spec/support/models/hole.rb +12 -0
  976. data/spec/support/models/home.rb +7 -0
  977. data/spec/support/models/house.rb +9 -0
  978. data/spec/support/models/html_writer.rb +5 -0
  979. data/spec/support/models/id_key.rb +9 -0
  980. data/spec/support/models/idnodef.rb +7 -0
  981. data/spec/support/models/image.rb +24 -0
  982. data/spec/support/models/implant.rb +27 -0
  983. data/spec/support/models/instrument.rb +8 -0
  984. data/spec/support/models/item.rb +11 -0
  985. data/spec/support/models/jar.rb +9 -0
  986. data/spec/support/models/kaleidoscope.rb +9 -0
  987. data/spec/support/models/kangaroo.rb +7 -0
  988. data/spec/support/models/label.rb +53 -0
  989. data/spec/support/models/language.rb +8 -0
  990. data/spec/support/models/lat_lng.rb +23 -0
  991. data/spec/support/models/league.rb +14 -0
  992. data/spec/support/models/learner.rb +4 -0
  993. data/spec/support/models/line_item.rb +9 -0
  994. data/spec/support/models/location.rb +11 -0
  995. data/spec/support/models/login.rb +10 -0
  996. data/spec/support/models/manufacturer.rb +9 -0
  997. data/spec/support/models/meat.rb +7 -0
  998. data/spec/support/models/membership.rb +8 -0
  999. data/spec/support/models/message.rb +13 -0
  1000. data/spec/support/models/minim.rb +6 -0
  1001. data/spec/support/models/mixed_drink.rb +7 -0
  1002. data/spec/support/models/modifier_models.rb +25 -0
  1003. data/spec/support/models/mop.rb +24 -0
  1004. data/spec/support/models/movie.rb +16 -0
  1005. data/spec/support/models/my_hash.rb +4 -0
  1006. data/spec/support/models/name.rb +36 -0
  1007. data/spec/support/models/name_only.rb +8 -0
  1008. data/spec/support/models/node.rb +8 -0
  1009. data/spec/support/models/note.rb +20 -0
  1010. data/spec/support/models/nut.rb +7 -0
  1011. data/spec/support/models/odd.rb +10 -0
  1012. data/spec/support/models/order.rb +13 -0
  1013. data/spec/support/models/ordered_post.rb +14 -0
  1014. data/spec/support/models/ordered_preference.rb +9 -0
  1015. data/spec/support/models/oscar.rb +17 -0
  1016. data/spec/support/models/other_owner_object.rb +4 -0
  1017. data/spec/support/models/override.rb +11 -0
  1018. data/spec/support/models/ownable.rb +9 -0
  1019. data/spec/support/models/owner.rb +11 -0
  1020. data/spec/support/models/pack.rb +5 -0
  1021. data/spec/support/models/page.rb +19 -0
  1022. data/spec/support/models/page_question.rb +7 -0
  1023. data/spec/support/models/palette.rb +10 -0
  1024. data/spec/support/models/parent.rb +8 -0
  1025. data/spec/support/models/parent_doc.rb +9 -0
  1026. data/spec/support/models/passport.rb +23 -0
  1027. data/spec/support/models/patient.rb +12 -0
  1028. data/spec/support/models/pdf_writer.rb +5 -0
  1029. data/spec/support/models/pencil.rb +3 -0
  1030. data/spec/support/models/person.rb +237 -0
  1031. data/spec/support/models/pet.rb +26 -0
  1032. data/spec/support/models/pet_owner.rb +9 -0
  1033. data/spec/support/models/phone.rb +13 -0
  1034. data/spec/support/models/piano.rb +4 -0
  1035. data/spec/support/models/pizza.rb +10 -0
  1036. data/spec/support/models/player.rb +40 -0
  1037. data/spec/support/models/post.rb +53 -0
  1038. data/spec/support/models/post_genre.rb +9 -0
  1039. data/spec/support/models/powerup.rb +25 -0
  1040. data/spec/support/models/preference.rb +12 -0
  1041. data/spec/support/models/princess.rb +13 -0
  1042. data/spec/support/models/product.rb +23 -0
  1043. data/spec/support/models/profile.rb +19 -0
  1044. data/spec/support/models/pronunciation.rb +8 -0
  1045. data/spec/support/models/pub.rb +9 -0
  1046. data/spec/support/models/publication/encyclopedia.rb +11 -0
  1047. data/spec/support/models/publication/review.rb +13 -0
  1048. data/spec/support/models/publication.rb +4 -0
  1049. data/spec/support/models/purchase.rb +7 -0
  1050. data/spec/support/models/purchased_item.rb +11 -0
  1051. data/spec/support/models/purse.rb +9 -0
  1052. data/spec/support/models/question.rb +11 -0
  1053. data/spec/support/models/quiz.rb +10 -0
  1054. data/spec/support/models/rating.rb +11 -0
  1055. data/spec/support/models/record.rb +54 -0
  1056. data/spec/support/models/registry.rb +8 -0
  1057. data/spec/support/models/role.rb +10 -0
  1058. data/spec/support/models/root_category.rb +7 -0
  1059. data/spec/support/models/sandbox/app/models/app_models_message.rb +3 -0
  1060. data/spec/support/models/sandbox/lib/models/lib_models_message.rb +3 -0
  1061. data/spec/support/models/sandbox/sandbox_message.rb +3 -0
  1062. data/spec/support/models/sandbox/sandbox_user.rb +3 -0
  1063. data/spec/support/models/sandbox/subdir/sandbox_comment.rb +3 -0
  1064. data/spec/support/models/sandwich.rb +12 -0
  1065. data/spec/support/models/scheduler.rb +9 -0
  1066. data/spec/support/models/school.rb +14 -0
  1067. data/spec/support/models/scribe.rb +8 -0
  1068. data/spec/support/models/sealer.rb +7 -0
  1069. data/spec/support/models/seat.rb +24 -0
  1070. data/spec/support/models/seo.rb +12 -0
  1071. data/spec/support/models/series.rb +8 -0
  1072. data/spec/support/models/server.rb +16 -0
  1073. data/spec/support/models/service.rb +25 -0
  1074. data/spec/support/models/shape.rb +15 -0
  1075. data/spec/support/models/shelf.rb +8 -0
  1076. data/spec/support/models/shield.rb +19 -0
  1077. data/spec/support/models/shipment_address.rb +5 -0
  1078. data/spec/support/models/shipping_container.rb +8 -0
  1079. data/spec/support/models/shipping_pack.rb +5 -0
  1080. data/spec/support/models/shirt.rb +11 -0
  1081. data/spec/support/models/shop.rb +9 -0
  1082. data/spec/support/models/short_agent.rb +6 -0
  1083. data/spec/support/models/short_quiz.rb +8 -0
  1084. data/spec/support/models/simple.rb +8 -0
  1085. data/spec/support/models/slave.rb +9 -0
  1086. data/spec/support/models/song.rb +10 -0
  1087. data/spec/support/models/sound.rb +8 -0
  1088. data/spec/support/models/spacer.rb +7 -0
  1089. data/spec/support/models/square.rb +6 -0
  1090. data/spec/support/models/staff.rb +9 -0
  1091. data/spec/support/models/store_as_dup_test1.rb +8 -0
  1092. data/spec/support/models/store_as_dup_test2.rb +8 -0
  1093. data/spec/support/models/store_as_dup_test3.rb +8 -0
  1094. data/spec/support/models/store_as_dup_test4.rb +8 -0
  1095. data/spec/support/models/strategy.rb +5 -0
  1096. data/spec/support/models/student.rb +14 -0
  1097. data/spec/support/models/sub_item.rb +5 -0
  1098. data/spec/support/models/subscription.rb +8 -0
  1099. data/spec/support/models/survey.rb +8 -0
  1100. data/spec/support/models/symptom.rb +9 -0
  1101. data/spec/support/models/system_role.rb +7 -0
  1102. data/spec/support/models/tag.rb +11 -0
  1103. data/spec/support/models/target.rb +8 -0
  1104. data/spec/support/models/template.rb +8 -0
  1105. data/spec/support/models/thing.rb +12 -0
  1106. data/spec/support/models/threadlocker.rb +7 -0
  1107. data/spec/support/models/title.rb +5 -0
  1108. data/spec/support/models/tool.rb +11 -0
  1109. data/spec/support/models/topping.rb +8 -0
  1110. data/spec/support/models/toy.rb +9 -0
  1111. data/spec/support/models/track.rb +41 -0
  1112. data/spec/support/models/translation.rb +8 -0
  1113. data/spec/support/models/tree.rb +11 -0
  1114. data/spec/support/models/truck.rb +7 -0
  1115. data/spec/support/models/user.rb +23 -0
  1116. data/spec/support/models/user_account.rb +13 -0
  1117. data/spec/support/models/validation_callback.rb +13 -0
  1118. data/spec/support/models/vehicle.rb +18 -0
  1119. data/spec/support/models/version.rb +8 -0
  1120. data/spec/support/models/vertex.rb +8 -0
  1121. data/spec/support/models/vet_visit.rb +8 -0
  1122. data/spec/support/models/video.rb +16 -0
  1123. data/spec/support/models/video_game.rb +3 -0
  1124. data/spec/support/models/washer.rb +7 -0
  1125. data/spec/support/models/weapon.rb +25 -0
  1126. data/spec/support/models/wiki_page.rb +17 -0
  1127. data/spec/support/models/word.rb +18 -0
  1128. data/spec/support/models/word_origin.rb +13 -0
  1129. data/spec/support/models/writer.rb +14 -0
  1130. data/spec/support/rails_mock.rb +27 -0
  1131. data/spec/support/schema_maps/schema_map_aws.json +17 -0
  1132. data/spec/support/schema_maps/schema_map_aws_key_alt_names.json +12 -0
  1133. data/spec/support/schema_maps/schema_map_azure.json +17 -0
  1134. data/spec/support/schema_maps/schema_map_azure_key_alt_names.json +12 -0
  1135. data/spec/support/schema_maps/schema_map_gcp.json +17 -0
  1136. data/spec/support/schema_maps/schema_map_gcp_key_alt_names.json +12 -0
  1137. data/spec/support/schema_maps/schema_map_kmip.json +17 -0
  1138. data/spec/support/schema_maps/schema_map_kmip_key_alt_names.json +12 -0
  1139. data/spec/support/schema_maps/schema_map_local.json +18 -0
  1140. data/spec/support/schema_maps/schema_map_local_key_alt_names.json +12 -0
  1141. data/spec/support/shared/time.rb +34 -0
  1142. data/spec/support/sinatra_mock.rb +9 -0
  1143. data/spec/support/spec_config.rb +45 -14
  1144. metadata +1341 -780
  1145. checksums.yaml.gz.sig +0 -0
  1146. data/lib/mongoid/association/referenced/eager.rb +0 -162
  1147. data/lib/mongoid/association/referenced/has_one/nested_builder.rb +0 -126
  1148. data/lib/mongoid/contextual/geo_near.rb +0 -267
  1149. data/lib/mongoid/criteria/queryable/forwardable.rb +0 -65
  1150. data/lib/mongoid/errors/eager_load.rb +0 -22
  1151. data/lib/mongoid/errors/invalid_session_use.rb +0 -24
  1152. data/lib/mongoid/errors/invalid_storage_parent.rb +0 -26
  1153. data/lib/mongoid/errors/invalid_value.rb +0 -16
  1154. data/lib/mongoid/matchable/all.rb +0 -28
  1155. data/lib/mongoid/matchable/and.rb +0 -30
  1156. data/lib/mongoid/matchable/default.rb +0 -119
  1157. data/lib/mongoid/matchable/elem_match.rb +0 -34
  1158. data/lib/mongoid/matchable/eq.rb +0 -22
  1159. data/lib/mongoid/matchable/exists.rb +0 -23
  1160. data/lib/mongoid/matchable/gt.rb +0 -23
  1161. data/lib/mongoid/matchable/gte.rb +0 -23
  1162. data/lib/mongoid/matchable/in.rb +0 -24
  1163. data/lib/mongoid/matchable/lt.rb +0 -23
  1164. data/lib/mongoid/matchable/lte.rb +0 -23
  1165. data/lib/mongoid/matchable/ne.rb +0 -21
  1166. data/lib/mongoid/matchable/nin.rb +0 -22
  1167. data/lib/mongoid/matchable/nor.rb +0 -37
  1168. data/lib/mongoid/matchable/or.rb +0 -33
  1169. data/lib/mongoid/matchable/regexp.rb +0 -27
  1170. data/lib/mongoid/matchable/size.rb +0 -21
  1171. data/lib/mongoid/query_cache.rb +0 -331
  1172. data/lib/support/ruby_version.rb +0 -26
  1173. data/spec/app/models/account.rb +0 -36
  1174. data/spec/app/models/acolyte.rb +0 -17
  1175. data/spec/app/models/actor.rb +0 -18
  1176. data/spec/app/models/actress.rb +0 -2
  1177. data/spec/app/models/address.rb +0 -79
  1178. data/spec/app/models/address_component.rb +0 -5
  1179. data/spec/app/models/address_number.rb +0 -6
  1180. data/spec/app/models/agency.rb +0 -5
  1181. data/spec/app/models/agent.rb +0 -16
  1182. data/spec/app/models/album.rb +0 -18
  1183. data/spec/app/models/alert.rb +0 -7
  1184. data/spec/app/models/animal.rb +0 -26
  1185. data/spec/app/models/answer.rb +0 -6
  1186. data/spec/app/models/appointment.rb +0 -7
  1187. data/spec/app/models/article.rb +0 -12
  1188. data/spec/app/models/artist.rb +0 -87
  1189. data/spec/app/models/artwork.rb +0 -4
  1190. data/spec/app/models/audio.rb +0 -5
  1191. data/spec/app/models/augmentation.rb +0 -11
  1192. data/spec/app/models/author.rb +0 -6
  1193. data/spec/app/models/baby.rb +0 -4
  1194. data/spec/app/models/band.rb +0 -31
  1195. data/spec/app/models/bar.rb +0 -10
  1196. data/spec/app/models/basic.rb +0 -6
  1197. data/spec/app/models/bed.rb +0 -1
  1198. data/spec/app/models/big_palette.rb +0 -2
  1199. data/spec/app/models/birthday.rb +0 -13
  1200. data/spec/app/models/bomb.rb +0 -4
  1201. data/spec/app/models/book.rb +0 -16
  1202. data/spec/app/models/breed.rb +0 -4
  1203. data/spec/app/models/browser.rb +0 -6
  1204. data/spec/app/models/building.rb +0 -6
  1205. data/spec/app/models/building_address.rb +0 -7
  1206. data/spec/app/models/bus.rb +0 -7
  1207. data/spec/app/models/business.rb +0 -5
  1208. data/spec/app/models/callback_test.rb +0 -9
  1209. data/spec/app/models/canvas.rb +0 -25
  1210. data/spec/app/models/car.rb +0 -1
  1211. data/spec/app/models/cat.rb +0 -8
  1212. data/spec/app/models/category.rb +0 -8
  1213. data/spec/app/models/child.rb +0 -4
  1214. data/spec/app/models/child_doc.rb +0 -22
  1215. data/spec/app/models/church.rb +0 -6
  1216. data/spec/app/models/circle.rb +0 -3
  1217. data/spec/app/models/circuit.rb +0 -4
  1218. data/spec/app/models/circus.rb +0 -7
  1219. data/spec/app/models/code.rb +0 -11
  1220. data/spec/app/models/comment.rb +0 -16
  1221. data/spec/app/models/company.rb +0 -5
  1222. data/spec/app/models/consumption_period.rb +0 -7
  1223. data/spec/app/models/contextable_item.rb +0 -5
  1224. data/spec/app/models/contractor.rb +0 -5
  1225. data/spec/app/models/cookie.rb +0 -6
  1226. data/spec/app/models/country_code.rb +0 -8
  1227. data/spec/app/models/courier_job.rb +0 -4
  1228. data/spec/app/models/customer.rb +0 -11
  1229. data/spec/app/models/customer_address.rb +0 -12
  1230. data/spec/app/models/definition.rb +0 -9
  1231. data/spec/app/models/delegating_patient.rb +0 -16
  1232. data/spec/app/models/description.rb +0 -11
  1233. data/spec/app/models/dictionary.rb +0 -10
  1234. data/spec/app/models/division.rb +0 -10
  1235. data/spec/app/models/doctor.rb +0 -12
  1236. data/spec/app/models/dog.rb +0 -7
  1237. data/spec/app/models/dokument.rb +0 -6
  1238. data/spec/app/models/draft.rb +0 -9
  1239. data/spec/app/models/dragon.rb +0 -4
  1240. data/spec/app/models/driver.rb +0 -7
  1241. data/spec/app/models/drug.rb +0 -6
  1242. data/spec/app/models/dungeon.rb +0 -4
  1243. data/spec/app/models/edit.rb +0 -5
  1244. data/spec/app/models/email.rb +0 -6
  1245. data/spec/app/models/employer.rb +0 -5
  1246. data/spec/app/models/entry.rb +0 -6
  1247. data/spec/app/models/eraser.rb +0 -1
  1248. data/spec/app/models/even.rb +0 -7
  1249. data/spec/app/models/event.rb +0 -22
  1250. data/spec/app/models/exhibition.rb +0 -4
  1251. data/spec/app/models/exhibitor.rb +0 -6
  1252. data/spec/app/models/explosion.rb +0 -4
  1253. data/spec/app/models/eye.rb +0 -9
  1254. data/spec/app/models/eye_bowl.rb +0 -9
  1255. data/spec/app/models/face.rb +0 -8
  1256. data/spec/app/models/favorite.rb +0 -6
  1257. data/spec/app/models/filesystem.rb +0 -5
  1258. data/spec/app/models/fire_hydrant.rb +0 -6
  1259. data/spec/app/models/firefox.rb +0 -4
  1260. data/spec/app/models/fish.rb +0 -7
  1261. data/spec/app/models/folder.rb +0 -7
  1262. data/spec/app/models/folder_item.rb +0 -9
  1263. data/spec/app/models/fruits.rb +0 -34
  1264. data/spec/app/models/game.rb +0 -19
  1265. data/spec/app/models/ghost.rb +0 -7
  1266. data/spec/app/models/home.rb +0 -4
  1267. data/spec/app/models/house.rb +0 -6
  1268. data/spec/app/models/html_writer.rb +0 -3
  1269. data/spec/app/models/id_key.rb +0 -6
  1270. data/spec/app/models/image.rb +0 -22
  1271. data/spec/app/models/implant.rb +0 -16
  1272. data/spec/app/models/item.rb +0 -8
  1273. data/spec/app/models/jar.rb +0 -7
  1274. data/spec/app/models/kaleidoscope.rb +0 -6
  1275. data/spec/app/models/kangaroo.rb +0 -4
  1276. data/spec/app/models/label.rb +0 -47
  1277. data/spec/app/models/language.rb +0 -5
  1278. data/spec/app/models/lat_lng.rb +0 -15
  1279. data/spec/app/models/league.rb +0 -11
  1280. data/spec/app/models/learner.rb +0 -2
  1281. data/spec/app/models/line_item.rb +0 -6
  1282. data/spec/app/models/location.rb +0 -8
  1283. data/spec/app/models/login.rb +0 -8
  1284. data/spec/app/models/manufacturer.rb +0 -7
  1285. data/spec/app/models/meat.rb +0 -4
  1286. data/spec/app/models/membership.rb +0 -4
  1287. data/spec/app/models/message.rb +0 -11
  1288. data/spec/app/models/minim.rb +0 -7
  1289. data/spec/app/models/mixed_drink.rb +0 -4
  1290. data/spec/app/models/movie.rb +0 -13
  1291. data/spec/app/models/my_hash.rb +0 -2
  1292. data/spec/app/models/name.rb +0 -24
  1293. data/spec/app/models/node.rb +0 -5
  1294. data/spec/app/models/note.rb +0 -17
  1295. data/spec/app/models/odd.rb +0 -7
  1296. data/spec/app/models/ordered_post.rb +0 -11
  1297. data/spec/app/models/ordered_preference.rb +0 -6
  1298. data/spec/app/models/oscar.rb +0 -14
  1299. data/spec/app/models/other_owner_object.rb +0 -2
  1300. data/spec/app/models/override.rb +0 -16
  1301. data/spec/app/models/ownable.rb +0 -6
  1302. data/spec/app/models/owner.rb +0 -6
  1303. data/spec/app/models/pack.rb +0 -3
  1304. data/spec/app/models/page.rb +0 -16
  1305. data/spec/app/models/page_question.rb +0 -4
  1306. data/spec/app/models/palette.rb +0 -7
  1307. data/spec/app/models/parent.rb +0 -5
  1308. data/spec/app/models/parent_doc.rb +0 -6
  1309. data/spec/app/models/passport.rb +0 -5
  1310. data/spec/app/models/patient.rb +0 -9
  1311. data/spec/app/models/pdf_writer.rb +0 -3
  1312. data/spec/app/models/pencil.rb +0 -1
  1313. data/spec/app/models/person.rb +0 -210
  1314. data/spec/app/models/pet.rb +0 -23
  1315. data/spec/app/models/pet_owner.rb +0 -6
  1316. data/spec/app/models/phone.rb +0 -9
  1317. data/spec/app/models/pizza.rb +0 -7
  1318. data/spec/app/models/player.rb +0 -35
  1319. data/spec/app/models/post.rb +0 -50
  1320. data/spec/app/models/post_genre.rb +0 -6
  1321. data/spec/app/models/powerup.rb +0 -11
  1322. data/spec/app/models/preference.rb +0 -9
  1323. data/spec/app/models/princess.rb +0 -10
  1324. data/spec/app/models/product.rb +0 -17
  1325. data/spec/app/models/profile.rb +0 -5
  1326. data/spec/app/models/pronunciation.rb +0 -5
  1327. data/spec/app/models/pub.rb +0 -6
  1328. data/spec/app/models/purchase.rb +0 -4
  1329. data/spec/app/models/question.rb +0 -8
  1330. data/spec/app/models/quiz.rb +0 -7
  1331. data/spec/app/models/rating.rb +0 -8
  1332. data/spec/app/models/record.rb +0 -52
  1333. data/spec/app/models/registry.rb +0 -4
  1334. data/spec/app/models/role.rb +0 -7
  1335. data/spec/app/models/root_category.rb +0 -4
  1336. data/spec/app/models/sandwich.rb +0 -9
  1337. data/spec/app/models/scheduler.rb +0 -7
  1338. data/spec/app/models/seo.rb +0 -7
  1339. data/spec/app/models/series.rb +0 -4
  1340. data/spec/app/models/server.rb +0 -13
  1341. data/spec/app/models/service.rb +0 -22
  1342. data/spec/app/models/shape.rb +0 -12
  1343. data/spec/app/models/shelf.rb +0 -5
  1344. data/spec/app/models/shipment_address.rb +0 -3
  1345. data/spec/app/models/shipping_container.rb +0 -5
  1346. data/spec/app/models/shipping_pack.rb +0 -3
  1347. data/spec/app/models/shop.rb +0 -6
  1348. data/spec/app/models/short_agent.rb +0 -4
  1349. data/spec/app/models/short_quiz.rb +0 -5
  1350. data/spec/app/models/simple.rb +0 -5
  1351. data/spec/app/models/slave.rb +0 -6
  1352. data/spec/app/models/song.rb +0 -8
  1353. data/spec/app/models/sound.rb +0 -5
  1354. data/spec/app/models/square.rb +0 -4
  1355. data/spec/app/models/staff.rb +0 -7
  1356. data/spec/app/models/store_as_dup_test1.rb +0 -5
  1357. data/spec/app/models/store_as_dup_test2.rb +0 -5
  1358. data/spec/app/models/store_as_dup_test3.rb +0 -7
  1359. data/spec/app/models/store_as_dup_test4.rb +0 -7
  1360. data/spec/app/models/strategy.rb +0 -3
  1361. data/spec/app/models/sub_item.rb +0 -3
  1362. data/spec/app/models/subscription.rb +0 -5
  1363. data/spec/app/models/survey.rb +0 -5
  1364. data/spec/app/models/symptom.rb +0 -6
  1365. data/spec/app/models/tag.rb +0 -8
  1366. data/spec/app/models/target.rb +0 -5
  1367. data/spec/app/models/template.rb +0 -5
  1368. data/spec/app/models/thing.rb +0 -9
  1369. data/spec/app/models/title.rb +0 -3
  1370. data/spec/app/models/tool.rb +0 -8
  1371. data/spec/app/models/topping.rb +0 -5
  1372. data/spec/app/models/track.rb +0 -38
  1373. data/spec/app/models/translation.rb +0 -5
  1374. data/spec/app/models/tree.rb +0 -9
  1375. data/spec/app/models/truck.rb +0 -3
  1376. data/spec/app/models/user.rb +0 -21
  1377. data/spec/app/models/user_account.rb +0 -10
  1378. data/spec/app/models/validation_callback.rb +0 -10
  1379. data/spec/app/models/vehicle.rb +0 -11
  1380. data/spec/app/models/version.rb +0 -5
  1381. data/spec/app/models/vertex.rb +0 -6
  1382. data/spec/app/models/vet_visit.rb +0 -5
  1383. data/spec/app/models/video.rb +0 -13
  1384. data/spec/app/models/video_game.rb +0 -1
  1385. data/spec/app/models/weapon.rb +0 -11
  1386. data/spec/app/models/wiki_page.rb +0 -14
  1387. data/spec/app/models/word.rb +0 -15
  1388. data/spec/app/models/word_origin.rb +0 -11
  1389. data/spec/app/models/writer.rb +0 -11
  1390. data/spec/integration/matchable_spec.rb +0 -680
  1391. data/spec/mongoid/contextual/geo_near_spec.rb +0 -469
  1392. data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +0 -58
  1393. data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +0 -58
  1394. data/spec/mongoid/criteria/queryable/forwardable_spec.rb +0 -87
  1395. data/spec/mongoid/errors/eager_load_spec.rb +0 -29
  1396. data/spec/mongoid/extensions_spec.rb +0 -29
  1397. data/spec/mongoid/matchable/all_spec.rb +0 -31
  1398. data/spec/mongoid/matchable/and_spec.rb +0 -187
  1399. data/spec/mongoid/matchable/default_spec.rb +0 -137
  1400. data/spec/mongoid/matchable/elem_match_spec.rb +0 -106
  1401. data/spec/mongoid/matchable/eq_spec.rb +0 -48
  1402. data/spec/mongoid/matchable/exists_spec.rb +0 -57
  1403. data/spec/mongoid/matchable/gt_spec.rb +0 -86
  1404. data/spec/mongoid/matchable/gte_spec.rb +0 -84
  1405. data/spec/mongoid/matchable/in_spec.rb +0 -49
  1406. data/spec/mongoid/matchable/lt_spec.rb +0 -85
  1407. data/spec/mongoid/matchable/lte_spec.rb +0 -85
  1408. data/spec/mongoid/matchable/ne_spec.rb +0 -46
  1409. data/spec/mongoid/matchable/nin_spec.rb +0 -48
  1410. data/spec/mongoid/matchable/nor_spec.rb +0 -209
  1411. data/spec/mongoid/matchable/or_spec.rb +0 -131
  1412. data/spec/mongoid/matchable/regexp_spec.rb +0 -59
  1413. data/spec/mongoid/matchable/size_spec.rb +0 -25
  1414. data/spec/mongoid/matchable_spec.rb +0 -853
  1415. data/spec/mongoid/query_cache_spec.rb +0 -618
  1416. data/spec/support/cluster_config.rb +0 -158
  1417. data/spec/support/session_registry.rb +0 -50
  1418. data.tar.gz.sig +0 -0
  1419. metadata.gz.sig +0 -1
  1420. /data/spec/{app → support}/models/array_field.rb +0 -0
  1421. /data/spec/{app → support}/models/updatable.rb +0 -0
@@ -1,1462 +1,909 @@
1
- require "spec_helper"
1
+ # frozen_string_literal: true
2
2
 
3
- describe Mongoid::Criteria::Queryable::Optional do
3
+ require 'spec_helper'
4
4
 
5
+ describe Mongoid::Criteria::Queryable::Optional do
5
6
  let(:query) do
6
7
  Mongoid::Query.new
7
8
  end
8
9
 
9
- shared_examples_for "a cloning option" do
10
-
11
- it "returns a cloned query" do
12
- expect(selection).to_not equal(query)
10
+ shared_examples_for 'a cloning option' do
11
+ it 'returns a cloned query' do
12
+ expect(selection).not_to equal(query)
13
13
  end
14
14
  end
15
15
 
16
- [ :asc, :ascending ].each do |method|
17
-
16
+ %i[asc ascending].each do |method|
18
17
  describe "##{method}" do
19
-
20
- context "when using the official mongodb driver syntax" do
21
-
22
- context "when the query is aggregating" do
23
-
18
+ context 'when using the official mongodb driver syntax' do
19
+ context 'when the query is aggregating' do
24
20
  let(:selection) do
25
21
  query.project(name: 1).send(method, :field_one, :field_two)
26
22
  end
27
23
 
28
- it "adds the sorting criteria" do
24
+ it 'adds the sorting criteria' do
29
25
  expect(selection.options).to eq(
30
- { sort: { "field_one" => 1, "field_two" => 1 }}
26
+ { sort: { 'field_one' => 1, 'field_two' => 1 } }
31
27
  )
32
28
  end
33
29
 
34
- it "adds the sort to the aggregation" do
30
+ it 'adds the sort to the aggregation' do
35
31
  expect(selection.pipeline).to include(
36
- { "$sort" => { "field_one" => 1, "field_two" => 1 }}
37
- )
38
- end
39
-
40
- it "does not add multiple entries to the pipeline" do
41
- expect(selection.pipeline).to_not include(
42
- { "$sort" => { "field_one" => 1 }}
43
- )
44
- end
45
-
46
- it_behaves_like "a cloning option"
47
- end
48
-
49
- context "when provided symbols" do
50
-
51
- let(:selection) do
52
- query.send(method, :field_one, :field_two)
53
- end
54
-
55
- it "adds the sorting criteria" do
56
- expect(selection.options).to eq(
57
- { sort: { "field_one" => 1, "field_two" => 1 }}
32
+ { '$sort' => { 'field_one' => 1, 'field_two' => 1 } }
58
33
  )
59
34
  end
60
35
 
61
- it_behaves_like "a cloning option"
62
- end
63
-
64
- context "when provided an array of symbols" do
65
-
66
- let(:selection) do
67
- query.send(method, [ :field_one, :field_two ])
68
- end
69
-
70
- it "adds the sorting criteria" do
71
- expect(selection.options).to eq(
72
- { sort: { "field_one" => 1, "field_two" => 1 }}
36
+ it 'does not add multiple entries to the pipeline' do
37
+ expect(selection.pipeline).not_to include(
38
+ { '$sort' => { 'field_one' => 1 } }
73
39
  )
74
40
  end
75
41
 
76
- it_behaves_like "a cloning option"
77
- end
78
-
79
- context "when provided strings" do
80
-
81
- let(:selection) do
82
- query.send(method, "field_one", "field_two")
83
- end
84
-
85
- it "adds the sorting criteria" do
86
- expect(selection.options).to eq(
87
- { sort: { "field_one" => 1, "field_two" => 1 }}
88
- )
89
- end
90
-
91
- it_behaves_like "a cloning option"
92
- end
93
-
94
- context "when provided an array of strings" do
95
-
96
- let(:selection) do
97
- query.send(method, [ "field_one", "field_two" ])
98
- end
99
-
100
- it "adds the sorting criteria" do
101
- expect(selection.options).to eq(
102
- { sort: { "field_one" => 1, "field_two" => 1 }}
103
- )
104
- end
105
-
106
- it_behaves_like "a cloning option"
107
- end
108
-
109
- context "when provided no options" do
110
-
111
- let(:selection) do
112
- query.send(method)
113
- end
114
-
115
- it "does not add any sorting criteria" do
116
- expect(selection.options).to be_empty
117
- end
118
-
119
- it "returns the query" do
120
- expect(selection).to eq(query)
121
- end
122
-
123
- it_behaves_like "a cloning option"
124
- end
125
-
126
- context "when provided nil" do
127
-
128
- let(:selection) do
129
- query.send(method, nil)
130
- end
131
-
132
- it "does not add any sorting criteria" do
133
- expect(selection.options).to be_empty
134
- end
135
-
136
- it "returns the query" do
137
- expect(selection).to eq(query)
138
- end
139
-
140
- it_behaves_like "a cloning option"
141
- end
142
- end
143
-
144
- context "when using the mongo-1.x driver syntax" do
145
-
146
- let(:query) do
147
- Mongoid::Query.new({}, {}, :mongo1x)
42
+ it_behaves_like 'a cloning option'
148
43
  end
149
44
 
150
- context "when provided symbols" do
151
-
45
+ context 'when provided symbols' do
152
46
  let(:selection) do
153
47
  query.send(method, :field_one, :field_two)
154
48
  end
155
49
 
156
- it "adds the sorting criteria" do
50
+ it 'adds the sorting criteria' do
157
51
  expect(selection.options).to eq(
158
- { sort: [[ :field_one, 1 ], [ :field_two, 1 ]]}
52
+ { sort: { 'field_one' => 1, 'field_two' => 1 } }
159
53
  )
160
54
  end
161
55
 
162
- it_behaves_like "a cloning option"
56
+ it_behaves_like 'a cloning option'
163
57
  end
164
58
 
165
- context "when provided an array of symbols" do
166
-
59
+ context 'when provided an array of symbols' do
167
60
  let(:selection) do
168
- query.send(method, [ :field_one, :field_two ])
61
+ query.send(method, %i[field_one field_two])
169
62
  end
170
63
 
171
- it "adds the sorting criteria" do
64
+ it 'adds the sorting criteria' do
172
65
  expect(selection.options).to eq(
173
- { sort: [[ :field_one, 1 ], [ :field_two, 1 ]]}
66
+ { sort: { 'field_one' => 1, 'field_two' => 1 } }
174
67
  )
175
68
  end
176
69
 
177
- it_behaves_like "a cloning option"
70
+ it_behaves_like 'a cloning option'
178
71
  end
179
72
 
180
- context "when provided strings" do
181
-
73
+ context 'when provided strings' do
182
74
  let(:selection) do
183
- query.send(method, "field_one", "field_two")
75
+ query.send(method, 'field_one', 'field_two')
184
76
  end
185
77
 
186
- it "adds the sorting criteria" do
78
+ it 'adds the sorting criteria' do
187
79
  expect(selection.options).to eq(
188
- { sort: [[ "field_one", 1 ], [ "field_two", 1 ]]}
80
+ { sort: { 'field_one' => 1, 'field_two' => 1 } }
189
81
  )
190
82
  end
191
83
 
192
- it_behaves_like "a cloning option"
84
+ it_behaves_like 'a cloning option'
193
85
  end
194
86
 
195
- context "when provided an array of strings" do
196
-
87
+ context 'when provided an array of strings' do
197
88
  let(:selection) do
198
- query.send(method, [ "field_one", "field_two" ])
89
+ query.send(method, %w[field_one field_two])
199
90
  end
200
91
 
201
- it "adds the sorting criteria" do
92
+ it 'adds the sorting criteria' do
202
93
  expect(selection.options).to eq(
203
- { sort: [[ "field_one", 1 ], [ "field_two", 1 ]]}
94
+ { sort: { 'field_one' => 1, 'field_two' => 1 } }
204
95
  )
205
96
  end
206
97
 
207
- it_behaves_like "a cloning option"
98
+ it_behaves_like 'a cloning option'
208
99
  end
209
100
 
210
- context "when provided no options" do
211
-
101
+ context 'when provided no options' do
212
102
  let(:selection) do
213
103
  query.send(method)
214
104
  end
215
105
 
216
- it "does not add any sorting criteria" do
106
+ it 'does not add any sorting criteria' do
217
107
  expect(selection.options).to be_empty
218
108
  end
219
109
 
220
- it "returns the query" do
110
+ it 'returns the query' do
221
111
  expect(selection).to eq(query)
222
112
  end
223
113
 
224
- it_behaves_like "a cloning option"
114
+ it_behaves_like 'a cloning option'
225
115
  end
226
116
 
227
- context "when provided nil" do
228
-
117
+ context 'when provided nil' do
229
118
  let(:selection) do
230
119
  query.send(method, nil)
231
120
  end
232
121
 
233
- it "does not add any sorting criteria" do
122
+ it 'does not add any sorting criteria' do
234
123
  expect(selection.options).to be_empty
235
124
  end
236
125
 
237
- it "returns the query" do
126
+ it 'returns the query' do
238
127
  expect(selection).to eq(query)
239
128
  end
240
129
 
241
- it_behaves_like "a cloning option"
130
+ it_behaves_like 'a cloning option'
242
131
  end
243
132
  end
244
133
  end
245
134
  end
246
135
 
247
- describe "#batch_size" do
248
-
249
- context "when provided no options" do
250
-
136
+ describe '#batch_size' do
137
+ context 'when provided no options' do
251
138
  let(:selection) do
252
139
  query.batch_size
253
140
  end
254
141
 
255
- it "does not add any options" do
142
+ it 'does not add any options' do
256
143
  expect(selection.options).to eq({})
257
144
  end
258
145
 
259
- it_behaves_like "a cloning option"
146
+ it_behaves_like 'a cloning option'
260
147
  end
261
148
 
262
- context "when provided nil" do
263
-
149
+ context 'when provided nil' do
264
150
  let(:selection) do
265
151
  query.batch_size(nil)
266
152
  end
267
153
 
268
- it "does not add any options" do
154
+ it 'does not add any options' do
269
155
  expect(selection.options).to eq({})
270
156
  end
271
157
 
272
- it_behaves_like "a cloning option"
158
+ it_behaves_like 'a cloning option'
273
159
  end
274
160
 
275
- context "when provided arguments" do
276
-
161
+ context 'when provided arguments' do
277
162
  let(:selection) do
278
163
  query.batch_size(500)
279
164
  end
280
165
 
281
- it "adds the field options" do
166
+ it 'adds the field options' do
282
167
  expect(selection.options).to eq({ batch_size: 500 })
283
168
  end
284
169
 
285
- it_behaves_like "a cloning option"
170
+ it_behaves_like 'a cloning option'
286
171
  end
287
172
  end
288
173
 
289
- [ :desc, :descending ].each do |method|
290
-
174
+ %i[desc descending].each do |method|
291
175
  describe "##{method}" do
292
-
293
- context "when using the official mongodb driver syntax" do
294
-
295
- context "when the query is aggregating" do
296
-
176
+ context 'when using the official mongodb driver syntax' do
177
+ context 'when the query is aggregating' do
297
178
  let(:selection) do
298
179
  query.project(name: 1).send(method, :field_one, :field_two)
299
180
  end
300
181
 
301
- it "adds the sorting criteria" do
182
+ it 'adds the sorting criteria' do
302
183
  expect(selection.options).to eq(
303
- { sort: { "field_one" => -1, "field_two" => -1 }}
184
+ { sort: { 'field_one' => -1, 'field_two' => -1 } }
304
185
  )
305
186
  end
306
187
 
307
- it "adds the sort to the aggregation" do
188
+ it 'adds the sort to the aggregation' do
308
189
  expect(selection.pipeline).to include(
309
- { "$sort" => { "field_one" => -1, "field_two" => -1 }}
310
- )
311
- end
312
-
313
- it "does not add multiple entries to the pipeline" do
314
- expect(selection.pipeline).to_not include(
315
- { "$sort" => { "field_one" => -1 }}
316
- )
317
- end
318
-
319
- it_behaves_like "a cloning option"
320
- end
321
-
322
- context "when provided symbols" do
323
-
324
- let(:selection) do
325
- query.send(method, :field_one, :field_two)
326
- end
327
-
328
- it "adds the sorting criteria" do
329
- expect(selection.options).to eq(
330
- { sort: { "field_one" => -1, "field_two" => -1 }}
331
- )
332
- end
333
-
334
- it_behaves_like "a cloning option"
335
- end
336
-
337
- context "when provided an array of symbols" do
338
-
339
- let(:selection) do
340
- query.send(method, [ :field_one, :field_two ])
341
- end
342
-
343
- it "adds the sorting criteria" do
344
- expect(selection.options).to eq(
345
- { sort: { "field_one" => -1, "field_two" => -1 }}
346
- )
347
- end
348
-
349
- it_behaves_like "a cloning option"
350
- end
351
-
352
- context "when provided strings" do
353
-
354
- let(:selection) do
355
- query.send(method, "field_one", "field_two")
356
- end
357
-
358
- it "adds the sorting criteria" do
359
- expect(selection.options).to eq(
360
- { sort: { "field_one" => -1, "field_two" => -1 }}
190
+ { '$sort' => { 'field_one' => -1, 'field_two' => -1 } }
361
191
  )
362
192
  end
363
193
 
364
- it_behaves_like "a cloning option"
365
- end
366
-
367
- context "when provided an array of strings" do
368
-
369
- let(:selection) do
370
- query.send(method, [ "field_one", "field_two" ])
371
- end
372
-
373
- it "adds the sorting criteria" do
374
- expect(selection.options).to eq(
375
- { sort: { "field_one" => -1, "field_two" => -1 }}
194
+ it 'does not add multiple entries to the pipeline' do
195
+ expect(selection.pipeline).not_to include(
196
+ { '$sort' => { 'field_one' => -1 } }
376
197
  )
377
198
  end
378
199
 
379
- it_behaves_like "a cloning option"
200
+ it_behaves_like 'a cloning option'
380
201
  end
381
202
 
382
- context "when provided no options" do
383
-
384
- let(:selection) do
385
- query.send(method)
386
- end
387
-
388
- it "does not add any sorting criteria" do
389
- expect(selection.options).to be_empty
390
- end
391
-
392
- it "returns the query" do
393
- expect(selection).to eq(query)
394
- end
395
-
396
- it_behaves_like "a cloning option"
397
- end
398
-
399
- context "when provided nil" do
400
-
401
- let(:selection) do
402
- query.send(method, nil)
403
- end
404
-
405
- it "does not add any sorting criteria" do
406
- expect(selection.options).to be_empty
407
- end
408
-
409
- it "returns the query" do
410
- expect(selection).to eq(query)
411
- end
412
-
413
- it_behaves_like "a cloning option"
414
- end
415
- end
416
-
417
- context "when using the mongo-1.x driver syntax" do
418
-
419
- let(:query) do
420
- Mongoid::Query.new({}, {}, :mongo1x)
421
- end
422
-
423
- context "when provided symbols" do
424
-
203
+ context 'when provided symbols' do
425
204
  let(:selection) do
426
205
  query.send(method, :field_one, :field_two)
427
206
  end
428
207
 
429
- it "adds the sorting criteria" do
208
+ it 'adds the sorting criteria' do
430
209
  expect(selection.options).to eq(
431
- { sort: [[ :field_one, -1 ], [ :field_two, -1 ]]}
210
+ { sort: { 'field_one' => -1, 'field_two' => -1 } }
432
211
  )
433
212
  end
434
213
 
435
- it_behaves_like "a cloning option"
214
+ it_behaves_like 'a cloning option'
436
215
  end
437
216
 
438
- context "when provided an array of symbols" do
439
-
217
+ context 'when provided an array of symbols' do
440
218
  let(:selection) do
441
- query.send(method, [ :field_one, :field_two ])
219
+ query.send(method, %i[field_one field_two])
442
220
  end
443
221
 
444
- it "adds the sorting criteria" do
222
+ it 'adds the sorting criteria' do
445
223
  expect(selection.options).to eq(
446
- { sort: [[ :field_one, -1 ], [ :field_two, -1 ]]}
224
+ { sort: { 'field_one' => -1, 'field_two' => -1 } }
447
225
  )
448
226
  end
449
227
 
450
- it_behaves_like "a cloning option"
228
+ it_behaves_like 'a cloning option'
451
229
  end
452
230
 
453
- context "when provided strings" do
454
-
231
+ context 'when provided strings' do
455
232
  let(:selection) do
456
- query.send(method, "field_one", "field_two")
233
+ query.send(method, 'field_one', 'field_two')
457
234
  end
458
235
 
459
- it "adds the sorting criteria" do
236
+ it 'adds the sorting criteria' do
460
237
  expect(selection.options).to eq(
461
- { sort: [[ "field_one", -1 ], [ "field_two", -1 ]]}
238
+ { sort: { 'field_one' => -1, 'field_two' => -1 } }
462
239
  )
463
240
  end
464
241
 
465
- it_behaves_like "a cloning option"
242
+ it_behaves_like 'a cloning option'
466
243
  end
467
244
 
468
- context "when provided an array of strings" do
469
-
245
+ context 'when provided an array of strings' do
470
246
  let(:selection) do
471
- query.send(method, [ "field_one", "field_two" ])
247
+ query.send(method, %w[field_one field_two])
472
248
  end
473
249
 
474
- it "adds the sorting criteria" do
250
+ it 'adds the sorting criteria' do
475
251
  expect(selection.options).to eq(
476
- { sort: [[ "field_one", -1 ], [ "field_two", -1 ]]}
252
+ { sort: { 'field_one' => -1, 'field_two' => -1 } }
477
253
  )
478
254
  end
479
255
 
480
- it_behaves_like "a cloning option"
256
+ it_behaves_like 'a cloning option'
481
257
  end
482
258
 
483
- context "when provided no options" do
484
-
259
+ context 'when provided no options' do
485
260
  let(:selection) do
486
261
  query.send(method)
487
262
  end
488
263
 
489
- it "does not add any sorting criteria" do
264
+ it 'does not add any sorting criteria' do
490
265
  expect(selection.options).to be_empty
491
266
  end
492
267
 
493
- it "returns the query" do
268
+ it 'returns the query' do
494
269
  expect(selection).to eq(query)
495
270
  end
496
271
 
497
- it_behaves_like "a cloning option"
272
+ it_behaves_like 'a cloning option'
498
273
  end
499
274
 
500
- context "when provided nil" do
501
-
275
+ context 'when provided nil' do
502
276
  let(:selection) do
503
277
  query.send(method, nil)
504
278
  end
505
279
 
506
- it "does not add any sorting criteria" do
280
+ it 'does not add any sorting criteria' do
507
281
  expect(selection.options).to be_empty
508
282
  end
509
283
 
510
- it "returns the query" do
284
+ it 'returns the query' do
511
285
  expect(selection).to eq(query)
512
286
  end
513
287
 
514
- it_behaves_like "a cloning option"
288
+ it_behaves_like 'a cloning option'
515
289
  end
516
290
  end
517
291
  end
518
292
  end
519
293
 
520
- describe "#hint" do
521
-
522
- context "when provided no options" do
523
-
294
+ describe '#hint' do
295
+ context 'when provided no options' do
524
296
  let(:selection) do
525
297
  query.hint
526
298
  end
527
299
 
528
- it "does not add any options" do
300
+ it 'does not add any options' do
529
301
  expect(selection.options).to eq({})
530
302
  end
531
303
 
532
- it "returns the query" do
304
+ it 'returns the query' do
533
305
  expect(selection).to eq(query)
534
306
  end
535
307
 
536
- it_behaves_like "a cloning option"
308
+ it_behaves_like 'a cloning option'
537
309
  end
538
310
 
539
- context "when provided nil" do
540
-
311
+ context 'when provided nil' do
541
312
  let(:selection) do
542
313
  query.hint(nil)
543
314
  end
544
315
 
545
- it "does not add any options" do
316
+ it 'does not add any options' do
546
317
  expect(selection.options).to eq({})
547
318
  end
548
319
 
549
- it "returns the query" do
320
+ it 'returns the query' do
550
321
  expect(selection).to eq(query)
551
322
  end
552
323
 
553
- it_behaves_like "a cloning option"
324
+ it_behaves_like 'a cloning option'
554
325
  end
555
326
 
556
- context "when provided arguments" do
557
-
558
- context "when the argument is a hash" do
559
-
327
+ context 'when provided arguments' do
328
+ context 'when the argument is a hash' do
560
329
  let(:selection) do
561
- query.hint("$natural" => 1)
330
+ query.hint('$natural' => 1)
562
331
  end
563
332
 
564
- it "adds the field options" do
565
- expect(selection.options).to eq({ hint: { "$natural" => 1 }})
333
+ it 'adds the field options' do
334
+ expect(selection.options).to eq({ hint: { '$natural' => 1 } })
566
335
  end
567
336
 
568
- it_behaves_like "a cloning option"
337
+ it_behaves_like 'a cloning option'
569
338
  end
570
339
  end
571
340
  end
572
341
 
573
- describe "#limit" do
574
-
575
- context "when provided no options" do
576
-
342
+ describe '#limit' do
343
+ context 'when provided no options' do
577
344
  let(:selection) do
578
345
  query.limit
579
346
  end
580
347
 
581
- it "does not add any options" do
348
+ it 'does not add any options' do
582
349
  expect(selection.options).to eq({})
583
350
  end
584
351
 
585
- it "returns the query" do
352
+ it 'returns the query' do
586
353
  expect(selection).to eq(query)
587
354
  end
588
355
 
589
- it_behaves_like "a cloning option"
356
+ it_behaves_like 'a cloning option'
590
357
  end
591
358
 
592
- context "when provided nil" do
593
-
359
+ context 'when provided nil' do
594
360
  let(:selection) do
595
361
  query.limit(nil)
596
362
  end
597
363
 
598
- it "does not add any options" do
364
+ it 'does not add any options' do
599
365
  expect(selection.options).to eq({})
600
366
  end
601
367
 
602
- it "returns the query" do
368
+ it 'returns the query' do
603
369
  expect(selection).to eq(query)
604
370
  end
605
371
 
606
- it_behaves_like "a cloning option"
372
+ it_behaves_like 'a cloning option'
607
373
  end
608
374
 
609
- context "when the query is aggregating" do
610
-
375
+ context 'when the query is aggregating' do
611
376
  let(:selection) do
612
377
  query.project(name: 1).limit(10)
613
378
  end
614
379
 
615
- it "adds the field options" do
380
+ it 'adds the field options' do
616
381
  expect(selection.options).to eq({ limit: 10 })
617
382
  end
618
383
 
619
- it "adds the limit to the aggregation" do
620
- expect(selection.pipeline).to include({ "$limit" => 10 })
384
+ it 'adds the limit to the aggregation' do
385
+ expect(selection.pipeline).to include({ '$limit' => 10 })
621
386
  end
622
387
 
623
- it_behaves_like "a cloning option"
388
+ it_behaves_like 'a cloning option'
624
389
  end
625
390
 
626
- context "when provided arguments" do
627
-
628
- context "when the argument is an integer" do
629
-
391
+ context 'when provided arguments' do
392
+ context 'when the argument is an integer' do
630
393
  let(:selection) do
631
394
  query.limit(10)
632
395
  end
633
396
 
634
- it "adds the field options" do
397
+ it 'adds the field options' do
635
398
  expect(selection.options).to eq({ limit: 10 })
636
399
  end
637
400
 
638
- it_behaves_like "a cloning option"
401
+ it_behaves_like 'a cloning option'
639
402
  end
640
403
 
641
- context "when the argument is a float" do
642
-
404
+ context 'when the argument is a float' do
643
405
  let(:selection) do
644
406
  query.limit(10.25)
645
407
  end
646
408
 
647
- it "adds the field options as an integer" do
409
+ it 'adds the field options as an integer' do
648
410
  expect(selection.options).to eq({ limit: 10 })
649
411
  end
650
412
 
651
- it_behaves_like "a cloning option"
413
+ it_behaves_like 'a cloning option'
652
414
  end
653
415
 
654
- context "when the argument is a string" do
655
-
416
+ context 'when the argument is a string' do
656
417
  let(:selection) do
657
- query.limit("10")
418
+ query.limit('10')
658
419
  end
659
420
 
660
- it "adds the field options as an integer" do
421
+ it 'adds the field options as an integer' do
661
422
  expect(selection.options).to eq({ limit: 10 })
662
423
  end
663
424
 
664
- it_behaves_like "a cloning option"
425
+ it_behaves_like 'a cloning option'
665
426
  end
666
427
  end
667
428
  end
668
429
 
669
- describe "#max_scan" do
670
-
671
- context "when provided no options" do
672
-
430
+ describe '#max_scan' do
431
+ context 'when provided no options' do
673
432
  let(:selection) do
674
433
  query.max_scan
675
434
  end
676
435
 
677
- it "does not add any options" do
436
+ it 'does not add any options' do
678
437
  expect(selection.options).to eq({})
679
438
  end
680
439
 
681
- it "returns the query" do
440
+ it 'returns the query' do
682
441
  expect(selection).to eq(query)
683
442
  end
684
443
 
685
- it_behaves_like "a cloning option"
444
+ it_behaves_like 'a cloning option'
686
445
  end
687
446
 
688
- context "when provided nil" do
689
-
447
+ context 'when provided nil' do
690
448
  let(:selection) do
691
449
  query.max_scan(nil)
692
450
  end
693
451
 
694
- it "does not add any options" do
452
+ it 'does not add any options' do
695
453
  expect(selection.options).to eq({})
696
454
  end
697
455
 
698
- it "returns the query" do
456
+ it 'returns the query' do
699
457
  expect(selection).to eq(query)
700
458
  end
701
459
 
702
- it_behaves_like "a cloning option"
460
+ it_behaves_like 'a cloning option'
703
461
  end
704
462
 
705
- context "when provided arguments" do
706
-
463
+ context 'when provided arguments' do
707
464
  let(:selection) do
708
465
  query.max_scan(500)
709
466
  end
710
467
 
711
- it "adds the field options" do
468
+ it 'adds the field options' do
712
469
  expect(selection.options).to eq({ max_scan: 500 })
713
470
  end
714
471
 
715
- it_behaves_like "a cloning option"
472
+ it_behaves_like 'a cloning option'
716
473
  end
717
474
  end
718
475
 
719
- describe "#max_time_ms" do
720
-
721
- context "when provided no options" do
722
-
476
+ describe '#max_time_ms' do
477
+ context 'when provided no options' do
723
478
  let(:selection) do
724
479
  query.max_time_ms
725
480
  end
726
481
 
727
- it "does not add any options" do
482
+ it 'does not add any options' do
728
483
  expect(selection.options).to eq({})
729
484
  end
730
485
 
731
- it "returns the query" do
486
+ it 'returns the query' do
732
487
  expect(selection).to eq(query)
733
488
  end
734
489
 
735
- it_behaves_like "a cloning option"
490
+ it_behaves_like 'a cloning option'
736
491
  end
737
492
 
738
- context "when provided nil" do
739
-
493
+ context 'when provided nil' do
740
494
  let(:selection) do
741
495
  query.max_time_ms(nil)
742
496
  end
743
497
 
744
- it "does not add any options" do
498
+ it 'does not add any options' do
745
499
  expect(selection.options).to eq({})
746
500
  end
747
501
 
748
- it "returns the query" do
502
+ it 'returns the query' do
749
503
  expect(selection).to eq(query)
750
504
  end
751
505
 
752
- it_behaves_like "a cloning option"
506
+ it_behaves_like 'a cloning option'
753
507
  end
754
508
 
755
- context "when provided arguments" do
756
-
509
+ context 'when provided arguments' do
757
510
  let(:selection) do
758
511
  query.max_time_ms(500)
759
512
  end
760
513
 
761
- it "adds the field options" do
514
+ it 'adds the field options' do
762
515
  expect(selection.options).to eq({ max_time_ms: 500 })
763
516
  end
764
517
 
765
- it_behaves_like "a cloning option"
518
+ it_behaves_like 'a cloning option'
766
519
  end
767
520
  end
768
521
 
769
- describe "#no_timeout" do
770
-
522
+ describe '#no_timeout' do
771
523
  let(:selection) do
772
524
  query.no_timeout
773
525
  end
774
526
 
775
- it "adds the timeout option" do
527
+ it 'adds the timeout option' do
776
528
  expect(selection.options).to eq({ timeout: false })
777
529
  end
778
530
 
779
- it_behaves_like "a cloning option"
531
+ it_behaves_like 'a cloning option'
780
532
  end
781
533
 
782
- describe "#only" do
783
-
784
- context "when provided no options" do
785
-
534
+ describe '#only' do
535
+ context 'when provided no options' do
786
536
  let(:selection) do
787
537
  query.only
788
538
  end
789
539
 
790
- it "does not add any options" do
540
+ it 'does not add any options' do
791
541
  expect(selection.options).to eq({})
792
542
  end
793
543
 
794
- it "returns the query" do
544
+ it 'returns the query' do
795
545
  expect(selection).to eq(query)
796
546
  end
797
547
 
798
- it_behaves_like "a cloning option"
548
+ it_behaves_like 'a cloning option'
799
549
  end
800
550
 
801
- context "when provided nil" do
802
-
551
+ context 'when provided nil' do
803
552
  let(:selection) do
804
553
  query.only(nil)
805
554
  end
806
555
 
807
- it "does not add any options" do
556
+ it 'does not add any options' do
808
557
  expect(selection.options).to eq({})
809
558
  end
810
559
 
811
- it "returns the query" do
560
+ it 'returns the query' do
812
561
  expect(selection).to eq(query)
813
562
  end
814
563
 
815
- it_behaves_like "a cloning option"
564
+ it_behaves_like 'a cloning option'
816
565
  end
817
566
 
818
- context "when provided fields" do
819
-
820
- context "as several arguments" do
821
-
567
+ context 'when provided fields' do
568
+ context 'as several arguments' do
822
569
  let(:selection) do
823
570
  query.only(:first, :second)
824
571
  end
825
572
 
826
- it "adds the field options" do
573
+ it 'adds the field options' do
827
574
  expect(selection.options).to eq(
828
- { fields: { "first" => 1, "second" => 1 }}
575
+ { fields: { 'first' => 1, 'second' => 1 } }
829
576
  )
830
577
  end
831
578
 
832
- it_behaves_like "a cloning option"
579
+ it_behaves_like 'a cloning option'
833
580
  end
834
581
 
835
- context "as one argument - array" do
836
-
582
+ context 'as one argument - array' do
837
583
  let(:selection) do
838
- query.only([:first, :second])
584
+ query.only(%i[first second])
839
585
  end
840
586
 
841
- it "adds the field options" do
587
+ it 'adds the field options' do
842
588
  expect(selection.options).to eq(
843
- { fields: { "first" => 1, "second" => 1 }}
589
+ { fields: { 'first' => 1, 'second' => 1 } }
844
590
  )
845
591
  end
846
592
 
847
- it_behaves_like "a cloning option"
593
+ it_behaves_like 'a cloning option'
848
594
  end
849
595
  end
850
596
 
851
- context "when #without was called first" do
852
-
597
+ context 'when #without was called first' do
853
598
  let(:selection) do
854
599
  query.without(:id).only(:first)
855
600
  end
856
601
 
857
- it "adds both fields to option" do
602
+ it 'adds both fields to option' do
858
603
  expect(selection.options).to eq(
859
- { fields: { "id" => 0, "first" => 1 } }
604
+ { fields: { 'id' => 0, 'first' => 1 } }
860
605
  )
861
606
  end
862
607
  end
863
608
  end
864
609
 
865
- [ :order, :order_by ].each do |method|
866
-
610
+ %i[order order_by].each do |method|
867
611
  describe "##{method}" do
868
-
869
- context "when using the official mongodb driver syntax" do
870
-
871
- context "when provided a hash" do
872
-
873
- context "when the query is aggregating" do
874
-
612
+ context 'when using the official mongodb driver syntax' do
613
+ context 'when provided a hash' do
614
+ context 'when the query is aggregating' do
875
615
  let(:selection) do
876
616
  query.project(name: 1).send("#{method}", field_one: 1, field_two: -1)
877
617
  end
878
618
 
879
- it "adds the sorting criteria" do
619
+ it 'adds the sorting criteria' do
880
620
  expect(selection.options).to eq(
881
- { sort: { "field_one" => 1, "field_two" => -1 }}
621
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
882
622
  )
883
623
  end
884
624
 
885
- it "adds the sort to the aggregation" do
625
+ it 'adds the sort to the aggregation' do
886
626
  expect(selection.pipeline).to include(
887
- { "$sort" => { "field_one" => 1, "field_two" => -1 }}
627
+ { '$sort' => { 'field_one' => 1, 'field_two' => -1 } }
888
628
  )
889
629
  end
890
630
 
891
- it "does not add multiple entries to the pipeline" do
892
- expect(selection.pipeline).to_not include(
893
- { "$sort" => { "field_one" => 1 }}
631
+ it 'does not add multiple entries to the pipeline' do
632
+ expect(selection.pipeline).not_to include(
633
+ { '$sort' => { 'field_one' => 1 } }
894
634
  )
895
635
  end
896
636
 
897
- it_behaves_like "a cloning option"
637
+ it_behaves_like 'a cloning option'
898
638
  end
899
639
 
900
- context "when the hash has integer values" do
901
-
640
+ context 'when the hash has integer values' do
902
641
  let(:selection) do
903
642
  query.send("#{method}", field_one: 1, field_two: -1)
904
643
  end
905
644
 
906
- it "adds the sorting criteria" do
645
+ it 'adds the sorting criteria' do
907
646
  expect(selection.options).to eq(
908
- { sort: { "field_one" => 1, "field_two" => -1 }}
647
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
909
648
  )
910
649
  end
911
650
 
912
- it_behaves_like "a cloning option"
651
+ it_behaves_like 'a cloning option'
913
652
  end
914
653
 
915
- context "when the hash has symbol values" do
916
-
654
+ context 'when the hash has symbol values' do
917
655
  let(:selection) do
918
656
  query.send("#{method}", field_one: :asc, field_two: :desc)
919
657
  end
920
658
 
921
- it "adds the sorting criteria" do
659
+ it 'adds the sorting criteria' do
922
660
  expect(selection.options).to eq(
923
- { sort: { "field_one" => 1, "field_two" => -1 }}
661
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
924
662
  )
925
663
  end
926
664
 
927
- it_behaves_like "a cloning option"
665
+ it_behaves_like 'a cloning option'
928
666
  end
929
667
 
930
- context "when the hash has string values" do
931
-
668
+ context 'when the hash has string values' do
932
669
  let(:selection) do
933
- query.send("#{method}", field_one: "asc", field_two: "desc")
670
+ query.send("#{method}", field_one: 'asc', field_two: 'desc')
934
671
  end
935
672
 
936
- it "adds the sorting criteria" do
673
+ it 'adds the sorting criteria' do
937
674
  expect(selection.options).to eq(
938
- { sort: { "field_one" => 1, "field_two" => -1 }}
675
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
939
676
  )
940
677
  end
941
678
 
942
- it_behaves_like "a cloning option"
679
+ it_behaves_like 'a cloning option'
943
680
  end
944
- end
945
-
946
- context "when provided an array" do
947
-
948
- context "when the array is multi-dimensional" do
949
-
950
- context "when the arrays have integer values" do
951
-
952
- let(:selection) do
953
- query.send("#{method}", [[ :field_one, 1 ],[ :field_two, -1 ]])
954
- end
955
-
956
- it "adds the sorting criteria" do
957
- expect(selection.options).to eq(
958
- { sort: { "field_one" => 1, "field_two" => -1 }}
959
- )
960
- end
961
-
962
- it_behaves_like "a cloning option"
963
- end
964
-
965
- context "when the arrays have symbol values" do
966
-
967
- let(:selection) do
968
- query.send("#{method}", [[ :field_one, :asc ],[ :field_two, :desc ]])
969
- end
970
-
971
- it "adds the sorting criteria" do
972
- expect(selection.options).to eq(
973
- { sort: { "field_one" => 1, "field_two" => -1 }}
974
- )
975
- end
976
-
977
- it_behaves_like "a cloning option"
978
- end
979
-
980
- context "when the arrays have string values" do
981
-
982
- let(:selection) do
983
- query.send("#{method}", [[ :field_one, "asc" ],[ :field_two, "desc" ]])
984
- end
985
-
986
- it "adds the sorting criteria" do
987
- expect(selection.options).to eq(
988
- { sort: { "field_one" => 1, "field_two" => -1 }}
989
- )
990
- end
991
-
992
- it_behaves_like "a cloning option"
993
- end
994
- end
995
-
996
- context "when the array is selectable keys" do
997
681
 
682
+ context 'when the hash has hash values' do
998
683
  let(:selection) do
999
- query.send("#{method}", [ :field_one.asc, :field_two.desc ])
684
+ query.send("#{method}", score: { '$meta' => 'textScore' })
1000
685
  end
1001
686
 
1002
- it "adds the sorting criteria" do
687
+ it 'adds the sorting criteria' do
1003
688
  expect(selection.options).to eq(
1004
- { sort: { "field_one" => 1, "field_two" => -1 }}
689
+ { sort: { 'score' => { '$meta' => 'textScore' } } }
1005
690
  )
1006
691
  end
1007
692
 
1008
- it_behaves_like "a cloning option"
693
+ it_behaves_like 'a cloning option'
1009
694
  end
1010
695
  end
1011
696
 
1012
- context "when provided values" do
1013
-
1014
- context "when the values are arrays" do
1015
-
1016
- context "when the values have integer directions" do
1017
-
697
+ context 'when provided an array' do
698
+ context 'when the array is multi-dimensional' do
699
+ context 'when the arrays have integer values' do
1018
700
  let(:selection) do
1019
- query.send("#{method}", [ :field_one, 1 ],[ :field_two, -1 ])
701
+ query.send("#{method}", [ [ :field_one, 1 ], [ :field_two, -1 ] ])
1020
702
  end
1021
703
 
1022
- it "adds the sorting criteria" do
704
+ it 'adds the sorting criteria' do
1023
705
  expect(selection.options).to eq(
1024
- { sort: { "field_one" => 1, "field_two" => -1 }}
706
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1025
707
  )
1026
708
  end
1027
709
 
1028
- it_behaves_like "a cloning option"
710
+ it_behaves_like 'a cloning option'
1029
711
  end
1030
712
 
1031
- context "when the values have symbol directions" do
1032
-
713
+ context 'when the arrays have symbol values' do
1033
714
  let(:selection) do
1034
- query.send("#{method}", [ :field_one, :asc ],[ :field_two, :desc ])
715
+ query.send("#{method}", [ %i[field_one asc], %i[field_two desc] ])
1035
716
  end
1036
717
 
1037
- it "adds the sorting criteria" do
718
+ it 'adds the sorting criteria' do
1038
719
  expect(selection.options).to eq(
1039
- { sort: { "field_one" => 1, "field_two" => -1 }}
720
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1040
721
  )
1041
722
  end
1042
723
 
1043
- it_behaves_like "a cloning option"
724
+ it_behaves_like 'a cloning option'
1044
725
  end
1045
726
 
1046
- context "when the values have string directions" do
1047
-
727
+ context 'when the arrays have string values' do
1048
728
  let(:selection) do
1049
- query.send("#{method}", [ :field_one, "asc" ],[ :field_two, "desc" ])
729
+ query.send("#{method}", [ [ :field_one, 'asc' ], [ :field_two, 'desc' ] ])
1050
730
  end
1051
731
 
1052
- it "adds the sorting criteria" do
732
+ it 'adds the sorting criteria' do
1053
733
  expect(selection.options).to eq(
1054
- { sort: { "field_one" => 1, "field_two" => -1 }}
734
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1055
735
  )
1056
736
  end
1057
737
 
1058
- it_behaves_like "a cloning option"
738
+ it_behaves_like 'a cloning option'
1059
739
  end
1060
740
  end
1061
741
 
1062
- context "when the values are selectable keys" do
1063
-
1064
- let(:selection) do
1065
- query.send("#{method}", :field_one.asc, :field_two.desc)
1066
- end
1067
-
1068
- it "adds the sorting criteria" do
1069
- expect(selection.options).to eq(
1070
- { sort: { "field_one" => 1, "field_two" => -1 }}
1071
- )
1072
- end
1073
-
1074
- it_behaves_like "a cloning option"
1075
- end
1076
- end
1077
-
1078
- context "when provided a string" do
1079
-
1080
- context "when the direction is lowercase" do
1081
-
1082
- context "when abbreviated" do
1083
-
1084
- let(:selection) do
1085
- query.send("#{method}", "field_one asc, field_two desc")
1086
- end
1087
-
1088
- it "adds the sorting criteria" do
1089
- expect(selection.options).to eq(
1090
- { sort: { "field_one" => 1, "field_two" => -1 }}
1091
- )
1092
- end
1093
-
1094
- it_behaves_like "a cloning option"
1095
- end
1096
-
1097
- context "when spelled out" do
1098
-
1099
- let(:selection) do
1100
- query.send("#{method}", "field_one ascending, field_two descending")
1101
- end
1102
-
1103
- it "adds the sorting criteria" do
1104
- expect(selection.options).to eq(
1105
- { sort: { "field_one" => 1, "field_two" => -1 }}
1106
- )
1107
- end
1108
-
1109
- it_behaves_like "a cloning option"
1110
- end
1111
- end
1112
-
1113
- context "when the direction is uppercase" do
1114
-
1115
- context "when abbreviated" do
1116
-
1117
- let(:selection) do
1118
- query.send("#{method}", "field_one ASC, field_two DESC")
1119
- end
1120
-
1121
- it "adds the sorting criteria" do
1122
- expect(selection.options).to eq(
1123
- { sort: { "field_one" => 1, "field_two" => -1 }}
1124
- )
1125
- end
1126
-
1127
- it_behaves_like "a cloning option"
1128
- end
1129
-
1130
- context "when spelled out" do
1131
-
1132
- let(:selection) do
1133
- query.send("#{method}", "field_one ASCENDING, field_two DESCENDING")
1134
- end
1135
-
1136
- it "adds the sorting criteria" do
1137
- expect(selection.options).to eq(
1138
- { sort: { "field_one" => 1, "field_two" => -1 }}
1139
- )
1140
- end
1141
-
1142
- it_behaves_like "a cloning option"
1143
- end
1144
- end
1145
- end
1146
-
1147
- context "when provided no options" do
1148
-
1149
- let(:selection) do
1150
- query.order_by
1151
- end
1152
-
1153
- it "returns the query" do
1154
- expect(selection).to eq(query)
1155
- end
1156
-
1157
- it_behaves_like "a cloning option"
1158
- end
1159
-
1160
- context "when provided nil" do
1161
-
1162
- let(:selection) do
1163
- query.send("#{method}", nil)
1164
- end
1165
-
1166
- it "returns the query" do
1167
- expect(selection).to eq(query)
1168
- end
1169
-
1170
- it_behaves_like "a cloning option"
1171
- end
1172
- end
1173
-
1174
- context "when using the mongo-1.x driver syntax" do
1175
-
1176
- let(:query) do
1177
- Mongoid::Query.new({}, {}, :mongo1x)
1178
- end
1179
-
1180
- context "when provided a hash" do
1181
-
1182
- context "when the hash has integer values" do
1183
-
1184
- let(:selection) do
1185
- query.send("#{method}", field_one: 1, field_two: -1)
1186
- end
1187
-
1188
- it "adds the sorting criteria" do
1189
- expect(selection.options).to eq(
1190
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
1191
- )
1192
- end
1193
-
1194
- it_behaves_like "a cloning option"
1195
- end
1196
-
1197
- context "when the hash has symbol values" do
1198
-
1199
- let(:selection) do
1200
- query.send("#{method}", field_one: :asc, field_two: :desc)
1201
- end
1202
-
1203
- it "adds the sorting criteria" do
1204
- expect(selection.options).to eq(
1205
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
1206
- )
1207
- end
1208
-
1209
- it_behaves_like "a cloning option"
1210
- end
1211
-
1212
- context "when the hash has string values" do
1213
-
1214
- let(:selection) do
1215
- query.send("#{method}", field_one: "asc", field_two: "desc")
1216
- end
1217
-
1218
- it "adds the sorting criteria" do
1219
- expect(selection.options).to eq(
1220
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
1221
- )
1222
- end
1223
-
1224
- it_behaves_like "a cloning option"
1225
- end
1226
- end
1227
-
1228
- context "when provided an array" do
1229
-
1230
- context "when the array is multi-dimensional" do
1231
-
1232
- context "when the arrays have integer values" do
1233
-
1234
- let(:selection) do
1235
- query.send("#{method}", [[ :field_one, 1 ],[ :field_two, -1 ]])
1236
- end
1237
-
1238
- it "adds the sorting criteria" do
1239
- expect(selection.options).to eq(
1240
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
1241
- )
1242
- end
1243
-
1244
- it_behaves_like "a cloning option"
1245
- end
1246
-
1247
- context "when the arrays have symbol values" do
1248
-
1249
- let(:selection) do
1250
- query.send("#{method}", [[ :field_one, :asc ],[ :field_two, :desc ]])
1251
- end
1252
-
1253
- it "adds the sorting criteria" do
1254
- expect(selection.options).to eq(
1255
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
1256
- )
1257
- end
1258
-
1259
- it_behaves_like "a cloning option"
1260
- end
1261
-
1262
- context "when the arrays have string values" do
1263
-
1264
- let(:selection) do
1265
- query.send("#{method}", [[ :field_one, "asc" ],[ :field_two, "desc" ]])
1266
- end
1267
-
1268
- it "adds the sorting criteria" do
1269
- expect(selection.options).to eq(
1270
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
1271
- )
1272
- end
1273
-
1274
- it_behaves_like "a cloning option"
1275
- end
1276
- end
1277
-
1278
- context "when the array is selectable keys" do
1279
-
742
+ context 'when the array is selectable keys' do
1280
743
  let(:selection) do
1281
744
  query.send("#{method}", [ :field_one.asc, :field_two.desc ])
1282
745
  end
1283
746
 
1284
- it "adds the sorting criteria" do
747
+ it 'adds the sorting criteria' do
1285
748
  expect(selection.options).to eq(
1286
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
749
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1287
750
  )
1288
751
  end
1289
752
 
1290
- it_behaves_like "a cloning option"
753
+ it_behaves_like 'a cloning option'
1291
754
  end
1292
755
  end
1293
756
 
1294
- context "when provided values" do
1295
-
1296
- context "when the values are arrays" do
1297
-
1298
- context "when the values have integer directions" do
1299
-
757
+ context 'when provided values' do
758
+ context 'when the values are arrays' do
759
+ context 'when the values have integer directions' do
1300
760
  let(:selection) do
1301
- query.send("#{method}", [ :field_one, 1 ],[ :field_two, -1 ])
761
+ query.send("#{method}", [ :field_one, 1 ], [ :field_two, -1 ])
1302
762
  end
1303
763
 
1304
- it "adds the sorting criteria" do
764
+ it 'adds the sorting criteria' do
1305
765
  expect(selection.options).to eq(
1306
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
766
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1307
767
  )
1308
768
  end
1309
769
 
1310
- it_behaves_like "a cloning option"
770
+ it_behaves_like 'a cloning option'
1311
771
  end
1312
772
 
1313
- context "when the values have symbol directions" do
1314
-
773
+ context 'when the values have symbol directions' do
1315
774
  let(:selection) do
1316
- query.send("#{method}", [ :field_one, :asc ],[ :field_two, :desc ])
775
+ query.send("#{method}", %i[field_one asc], %i[field_two desc])
1317
776
  end
1318
777
 
1319
- it "adds the sorting criteria" do
778
+ it 'adds the sorting criteria' do
1320
779
  expect(selection.options).to eq(
1321
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
780
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1322
781
  )
1323
782
  end
1324
783
 
1325
- it_behaves_like "a cloning option"
784
+ it_behaves_like 'a cloning option'
1326
785
  end
1327
786
 
1328
- context "when the values have string directions" do
1329
-
787
+ context 'when the values have string directions' do
1330
788
  let(:selection) do
1331
- query.send("#{method}", [ :field_one, "asc" ],[ :field_two, "desc" ])
789
+ query.send("#{method}", [ :field_one, 'asc' ], [ :field_two, 'desc' ])
1332
790
  end
1333
791
 
1334
- it "adds the sorting criteria" do
792
+ it 'adds the sorting criteria' do
1335
793
  expect(selection.options).to eq(
1336
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
794
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1337
795
  )
1338
796
  end
1339
797
 
1340
- it_behaves_like "a cloning option"
798
+ it_behaves_like 'a cloning option'
1341
799
  end
1342
800
  end
1343
801
 
1344
- context "when the values are selectable keys" do
1345
-
802
+ context 'when the values are selectable keys' do
1346
803
  let(:selection) do
1347
804
  query.send("#{method}", :field_one.asc, :field_two.desc)
1348
805
  end
1349
806
 
1350
- it "adds the sorting criteria" do
807
+ it 'adds the sorting criteria' do
1351
808
  expect(selection.options).to eq(
1352
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
809
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1353
810
  )
1354
811
  end
1355
812
 
1356
- it_behaves_like "a cloning option"
813
+ it_behaves_like 'a cloning option'
1357
814
  end
1358
815
  end
1359
816
 
1360
- context "when provided a string" do
1361
-
1362
- context "when the direction is lowercase" do
1363
-
1364
- context "when abbreviated" do
1365
-
817
+ context 'when provided a string' do
818
+ context 'when the direction is lowercase' do
819
+ context 'when abbreviated' do
1366
820
  let(:selection) do
1367
- query.send("#{method}", "field_one asc, field_two desc")
821
+ query.send("#{method}", 'field_one asc, field_two desc')
1368
822
  end
1369
823
 
1370
- it "adds the sorting criteria" do
824
+ it 'adds the sorting criteria' do
1371
825
  expect(selection.options).to eq(
1372
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
826
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1373
827
  )
1374
828
  end
1375
829
 
1376
- it_behaves_like "a cloning option"
830
+ it_behaves_like 'a cloning option'
1377
831
  end
1378
832
 
1379
- context "when spelled out" do
1380
-
833
+ context 'when spelled out' do
1381
834
  let(:selection) do
1382
- query.send("#{method}", "field_one ascending, field_two descending")
835
+ query.send("#{method}", 'field_one ascending, field_two descending')
1383
836
  end
1384
837
 
1385
- it "adds the sorting criteria" do
838
+ it 'adds the sorting criteria' do
1386
839
  expect(selection.options).to eq(
1387
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
840
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1388
841
  )
1389
842
  end
1390
843
 
1391
- it_behaves_like "a cloning option"
844
+ it_behaves_like 'a cloning option'
1392
845
  end
1393
846
  end
1394
847
 
1395
- context "when the direction is uppercase" do
1396
-
1397
- context "when abbreviated" do
1398
-
848
+ context 'when the direction is uppercase' do
849
+ context 'when abbreviated' do
1399
850
  let(:selection) do
1400
- query.send("#{method}", "field_one ASC, field_two DESC")
851
+ query.send("#{method}", 'field_one ASC, field_two DESC')
1401
852
  end
1402
853
 
1403
- it "adds the sorting criteria" do
854
+ it 'adds the sorting criteria' do
1404
855
  expect(selection.options).to eq(
1405
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
856
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1406
857
  )
1407
858
  end
1408
859
 
1409
- it_behaves_like "a cloning option"
860
+ it_behaves_like 'a cloning option'
1410
861
  end
1411
862
 
1412
- context "when spelled out" do
1413
-
863
+ context 'when spelled out' do
1414
864
  let(:selection) do
1415
- query.send("#{method}", "field_one ASCENDING, field_two DESCENDING")
865
+ query.send("#{method}", 'field_one ASCENDING, field_two DESCENDING')
1416
866
  end
1417
867
 
1418
- it "adds the sorting criteria" do
868
+ it 'adds the sorting criteria' do
1419
869
  expect(selection.options).to eq(
1420
- { sort: [[ :field_one, 1 ], [ :field_two, -1 ]]}
870
+ { sort: { 'field_one' => 1, 'field_two' => -1 } }
1421
871
  )
1422
872
  end
1423
873
 
1424
- it_behaves_like "a cloning option"
874
+ it_behaves_like 'a cloning option'
1425
875
  end
1426
876
  end
1427
877
  end
1428
878
 
1429
- context "when provided no options" do
1430
-
879
+ context 'when provided no options' do
1431
880
  let(:selection) do
1432
881
  query.order_by
1433
882
  end
1434
883
 
1435
- it "returns the query" do
884
+ it 'returns the query' do
1436
885
  expect(selection).to eq(query)
1437
886
  end
1438
887
 
1439
- it_behaves_like "a cloning option"
888
+ it_behaves_like 'a cloning option'
1440
889
  end
1441
890
 
1442
- context "when provided nil" do
1443
-
891
+ context 'when provided nil' do
1444
892
  let(:selection) do
1445
893
  query.send("#{method}", nil)
1446
894
  end
1447
895
 
1448
- it "returns the query" do
896
+ it 'returns the query' do
1449
897
  expect(selection).to eq(query)
1450
898
  end
1451
899
 
1452
- it_behaves_like "a cloning option"
900
+ it_behaves_like 'a cloning option'
1453
901
  end
1454
902
  end
1455
903
  end
1456
904
  end
1457
905
 
1458
- describe "#reoder" do
1459
-
906
+ describe '#reoder' do
1460
907
  let(:selection) do
1461
908
  query.order_by(field_one: 1, field_two: -1)
1462
909
  end
@@ -1465,8 +912,8 @@ describe Mongoid::Criteria::Queryable::Optional do
1465
912
  selection.reorder(field_three: 1)
1466
913
  end
1467
914
 
1468
- it "replaces all order options with the new options" do
1469
- expect(reordered.options).to eq(sort: { "field_three" => 1 })
915
+ it 'replaces all order options with the new options' do
916
+ expect(reordered.options).to eq(sort: { 'field_three' => 1 })
1470
917
  end
1471
918
 
1472
919
  it 'does not alter the original criteria object' do
@@ -1474,324 +921,298 @@ describe Mongoid::Criteria::Queryable::Optional do
1474
921
  end
1475
922
  end
1476
923
 
1477
- [ :skip, :offset ].each do |method|
1478
-
1479
- describe "\##{method}" do
1480
-
1481
- context "when provided no options" do
1482
-
924
+ %i[skip offset].each do |method|
925
+ describe "##{method}" do
926
+ context 'when provided no options' do
1483
927
  let(:selection) do
1484
928
  query.send(method)
1485
929
  end
1486
930
 
1487
- it "does not add any options" do
931
+ it 'does not add any options' do
1488
932
  expect(selection.options).to eq({})
1489
933
  end
1490
934
 
1491
- it "returns the query" do
935
+ it 'returns the query' do
1492
936
  expect(selection).to eq(query)
1493
937
  end
1494
938
 
1495
- it_behaves_like "a cloning option"
939
+ it_behaves_like 'a cloning option'
1496
940
  end
1497
941
 
1498
- context "when provided nil" do
1499
-
942
+ context 'when provided nil' do
1500
943
  let(:selection) do
1501
944
  query.send(method, nil)
1502
945
  end
1503
946
 
1504
- it "does not add any options" do
947
+ it 'does not add any options' do
1505
948
  expect(selection.options).to eq({})
1506
949
  end
1507
950
 
1508
- it "returns the query" do
951
+ it 'returns the query' do
1509
952
  expect(selection).to eq(query)
1510
953
  end
1511
954
 
1512
- it_behaves_like "a cloning option"
955
+ it_behaves_like 'a cloning option'
1513
956
  end
1514
957
 
1515
- context "when the query is aggregating" do
1516
-
958
+ context 'when the query is aggregating' do
1517
959
  let(:selection) do
1518
960
  query.project(name: 1).skip(10)
1519
961
  end
1520
962
 
1521
- it "adds the field options" do
963
+ it 'adds the field options' do
1522
964
  expect(selection.options).to eq({ skip: 10 })
1523
965
  end
1524
966
 
1525
- it "adds the skip to the aggregation" do
1526
- expect(selection.pipeline).to include({ "$skip" => 10 })
967
+ it 'adds the skip to the aggregation' do
968
+ expect(selection.pipeline).to include({ '$skip' => 10 })
1527
969
  end
1528
970
 
1529
- it_behaves_like "a cloning option"
971
+ it_behaves_like 'a cloning option'
1530
972
  end
1531
973
 
1532
- context "when provided arguments" do
1533
-
1534
- context "when provided an integer" do
1535
-
974
+ context 'when provided arguments' do
975
+ context 'when provided an integer' do
1536
976
  let(:selection) do
1537
977
  query.send(method, 10)
1538
978
  end
1539
979
 
1540
- it "adds the field options" do
980
+ it 'adds the field options' do
1541
981
  expect(selection.options).to eq({ skip: 10 })
1542
982
  end
1543
983
 
1544
- it_behaves_like "a cloning option"
984
+ it_behaves_like 'a cloning option'
1545
985
  end
1546
986
 
1547
- context "when provided a float" do
1548
-
987
+ context 'when provided a float' do
1549
988
  let(:selection) do
1550
989
  query.send(method, 10.25)
1551
990
  end
1552
991
 
1553
- it "adds the field options converted to an integer" do
992
+ it 'adds the field options converted to an integer' do
1554
993
  expect(selection.options).to eq({ skip: 10 })
1555
994
  end
1556
995
 
1557
- it_behaves_like "a cloning option"
996
+ it_behaves_like 'a cloning option'
1558
997
  end
1559
998
 
1560
- context "when provided a non number" do
1561
-
999
+ context 'when provided a non number' do
1562
1000
  let(:selection) do
1563
- query.send(method, "10")
1001
+ query.send(method, '10')
1564
1002
  end
1565
1003
 
1566
- it "adds the field options converted to an integer" do
1004
+ it 'adds the field options converted to an integer' do
1567
1005
  expect(selection.options).to eq({ skip: 10 })
1568
1006
  end
1569
1007
 
1570
- it_behaves_like "a cloning option"
1008
+ it_behaves_like 'a cloning option'
1571
1009
  end
1572
1010
  end
1573
1011
  end
1574
1012
  end
1575
1013
 
1576
- describe "#slice" do
1577
-
1578
- context "when provided no options" do
1579
-
1014
+ describe '#slice' do
1015
+ context 'when provided no options' do
1580
1016
  let(:selection) do
1581
1017
  query.slice
1582
1018
  end
1583
1019
 
1584
- it "does not add any options" do
1020
+ it 'does not add any options' do
1585
1021
  expect(selection.options).to eq({})
1586
1022
  end
1587
1023
 
1588
- it "returns the query" do
1024
+ it 'returns the query' do
1589
1025
  expect(selection).to eq(query)
1590
1026
  end
1591
1027
 
1592
- it_behaves_like "a cloning option"
1028
+ it_behaves_like 'a cloning option'
1593
1029
  end
1594
1030
 
1595
- context "when provided nil" do
1596
-
1031
+ context 'when provided nil' do
1597
1032
  let(:selection) do
1598
1033
  query.slice(nil)
1599
1034
  end
1600
1035
 
1601
- it "does not add any options" do
1036
+ it 'does not add any options' do
1602
1037
  expect(selection.options).to eq({})
1603
1038
  end
1604
1039
 
1605
- it "returns the query" do
1040
+ it 'returns the query' do
1606
1041
  expect(selection).to eq(query)
1607
1042
  end
1608
1043
 
1609
- it_behaves_like "a cloning option"
1044
+ it_behaves_like 'a cloning option'
1610
1045
  end
1611
1046
 
1612
- context "when provided a single argument" do
1613
-
1047
+ context 'when provided a single argument' do
1614
1048
  let(:selection) do
1615
- query.slice(:first => 5)
1049
+ query.slice(first: 5)
1616
1050
  end
1617
1051
 
1618
- it "adds the field options" do
1052
+ it 'adds the field options' do
1619
1053
  expect(selection.options).to eq(
1620
- { fields: { "first" => { "$slice" => 5 }}}
1054
+ { fields: { 'first' => { '$slice' => 5 } } }
1621
1055
  )
1622
1056
  end
1623
1057
 
1624
- it_behaves_like "a cloning option"
1058
+ it_behaves_like 'a cloning option'
1625
1059
  end
1626
1060
 
1627
- context "when provided a multiple arguments" do
1628
-
1061
+ context 'when provided a multiple arguments' do
1629
1062
  let(:selection) do
1630
- query.slice(:first => 5, :second => [ 0, 3 ])
1063
+ query.slice(first: 5, second: [ 0, 3 ])
1631
1064
  end
1632
1065
 
1633
- it "adds the field options" do
1066
+ it 'adds the field options' do
1634
1067
  expect(selection.options).to eq({ fields:
1635
- { "first" => { "$slice" => 5 }, "second" => { "$slice" => [ 0, 3 ] }}
1636
- })
1068
+ { 'first' => { '$slice' => 5 }, 'second' => { '$slice' => [ 0, 3 ] } } })
1637
1069
  end
1638
1070
 
1639
- it_behaves_like "a cloning option"
1071
+ it_behaves_like 'a cloning option'
1640
1072
  end
1641
1073
 
1642
- context "when existing field arguments exist" do
1643
-
1074
+ context 'when existing field arguments exist' do
1644
1075
  let(:limited) do
1645
1076
  query.only(:name)
1646
1077
  end
1647
1078
 
1648
1079
  let(:selection) do
1649
- limited.slice(:first => 5, :second => [ 0, 3 ])
1080
+ limited.slice(first: 5, second: [ 0, 3 ])
1650
1081
  end
1651
1082
 
1652
- it "adds the field options" do
1083
+ it 'adds the field options' do
1653
1084
  expect(selection.options).to eq({
1654
- fields: {
1655
- "name" => 1,
1656
- "first" => { "$slice" => 5 },
1657
- "second" => { "$slice" => [ 0, 3 ] }
1658
- }
1659
- })
1085
+ fields: {
1086
+ 'name' => 1,
1087
+ 'first' => { '$slice' => 5 },
1088
+ 'second' => { '$slice' => [ 0, 3 ] }
1089
+ }
1090
+ })
1660
1091
  end
1661
1092
 
1662
- it_behaves_like "a cloning option"
1093
+ it_behaves_like 'a cloning option'
1663
1094
  end
1664
1095
  end
1665
1096
 
1666
- describe "#snapshot" do
1667
-
1097
+ describe '#snapshot' do
1668
1098
  let(:selection) do
1669
1099
  query.snapshot
1670
1100
  end
1671
1101
 
1672
- it "adds the snapshot option" do
1102
+ it 'adds the snapshot option' do
1673
1103
  expect(selection.options).to eq({ snapshot: true })
1674
1104
  end
1675
1105
 
1676
- it_behaves_like "a cloning option"
1106
+ it_behaves_like 'a cloning option'
1677
1107
  end
1678
1108
 
1679
- describe "#comment" do
1680
-
1109
+ describe '#comment' do
1681
1110
  let(:selection) do
1682
1111
  query.comment('slow query')
1683
1112
  end
1684
1113
 
1685
- it "adds the comment option" do
1114
+ it 'adds the comment option' do
1686
1115
  expect(selection.options).to eq({ comment: 'slow query' })
1687
1116
  end
1688
1117
 
1689
- it_behaves_like "a cloning option"
1118
+ it_behaves_like 'a cloning option'
1690
1119
  end
1691
1120
 
1692
- describe "#cursor_type" do
1693
-
1121
+ describe '#cursor_type' do
1694
1122
  let(:selection) do
1695
1123
  query.cursor_type(:tailable)
1696
1124
  end
1697
1125
 
1698
- it "adds the cursor type option" do
1126
+ it 'adds the cursor type option' do
1699
1127
  expect(selection.options).to eq({ cursor_type: :tailable })
1700
1128
  end
1701
1129
 
1702
- it_behaves_like "a cloning option"
1130
+ it_behaves_like 'a cloning option'
1703
1131
  end
1704
1132
 
1705
- describe "#collation" do
1706
-
1133
+ describe '#collation' do
1707
1134
  let(:selection) do
1708
1135
  query.collation(locale: 'fr', strength: 2)
1709
1136
  end
1710
1137
 
1711
- it "adds the collation option" do
1712
- expect(selection.options).to eq(collation: {'locale' => 'fr', 'strength' => 2})
1138
+ it 'adds the collation option' do
1139
+ expect(selection.options).to eq(collation: { 'locale' => 'fr', 'strength' => 2 })
1713
1140
  end
1714
1141
 
1715
- it_behaves_like "a cloning option"
1142
+ it_behaves_like 'a cloning option'
1716
1143
  end
1717
1144
 
1718
- describe "#without" do
1719
-
1720
- context "when provided no options" do
1721
-
1145
+ describe '#without' do
1146
+ context 'when provided no options' do
1722
1147
  let(:selection) do
1723
1148
  query.without
1724
1149
  end
1725
1150
 
1726
- it "does not add any options" do
1151
+ it 'does not add any options' do
1727
1152
  expect(selection.options).to eq({})
1728
1153
  end
1729
1154
 
1730
- it "returns the query" do
1155
+ it 'returns the query' do
1731
1156
  expect(selection).to eq(query)
1732
1157
  end
1733
1158
 
1734
- it_behaves_like "a cloning option"
1159
+ it_behaves_like 'a cloning option'
1735
1160
  end
1736
1161
 
1737
- context "when provided nil" do
1738
-
1162
+ context 'when provided nil' do
1739
1163
  let(:selection) do
1740
1164
  query.without(nil)
1741
1165
  end
1742
1166
 
1743
- it "does not add any options" do
1167
+ it 'does not add any options' do
1744
1168
  expect(selection.options).to eq({})
1745
1169
  end
1746
1170
 
1747
- it "returns the query" do
1171
+ it 'returns the query' do
1748
1172
  expect(selection).to eq(query)
1749
1173
  end
1750
1174
 
1751
- it_behaves_like "a cloning option"
1175
+ it_behaves_like 'a cloning option'
1752
1176
  end
1753
1177
 
1754
- context "when provided fields" do
1755
-
1756
- context "as sevaral arguments" do
1757
-
1178
+ context 'when provided fields' do
1179
+ context 'as several arguments' do
1758
1180
  let(:selection) do
1759
1181
  query.without(:first, :second)
1760
1182
  end
1761
1183
 
1762
- it "adds the field options" do
1184
+ it 'adds the field options' do
1763
1185
  expect(selection.options).to eq(
1764
- { fields: { "first" => 0, "second" => 0 }}
1186
+ { fields: { 'first' => 0, 'second' => 0 } }
1765
1187
  )
1766
1188
  end
1767
1189
 
1768
- it_behaves_like "a cloning option"
1190
+ it_behaves_like 'a cloning option'
1769
1191
  end
1770
1192
 
1771
- context "as one argument - array" do
1772
-
1193
+ context 'as one argument - array' do
1773
1194
  let(:selection) do
1774
- query.without([:first, :second])
1195
+ query.without(%i[first second])
1775
1196
  end
1776
1197
 
1777
- it "adds the field options" do
1198
+ it 'adds the field options' do
1778
1199
  expect(selection.options).to eq(
1779
- { fields: { "first" => 0, "second" => 0 }}
1200
+ { fields: { 'first' => 0, 'second' => 0 } }
1780
1201
  )
1781
1202
  end
1782
1203
 
1783
- it_behaves_like "a cloning option"
1204
+ it_behaves_like 'a cloning option'
1784
1205
  end
1785
1206
  end
1786
1207
 
1787
- context "when #only was called before" do
1208
+ context 'when #only was called before' do
1788
1209
  let(:selection) do
1789
1210
  query.only(:first).without(:id)
1790
1211
  end
1791
1212
 
1792
- it "adds both fields to options" do
1213
+ it 'adds both fields to options' do
1793
1214
  expect(selection.options).to eq(
1794
- { fields: { "first" => 1, "id" => 0 } }
1215
+ { fields: { 'first' => 1, 'id' => 0 } }
1795
1216
  )
1796
1217
  end
1797
1218
  end