mongoid 7.2.6 → 7.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +1 -1
  4. data/Rakefile +16 -0
  5. data/lib/config/locales/en.yml +2 -15
  6. data/lib/mongoid/association/accessors.rb +1 -1
  7. data/lib/mongoid/association/constrainable.rb +1 -1
  8. data/lib/mongoid/association/depending.rb +4 -4
  9. data/lib/mongoid/association/embedded/batchable.rb +1 -1
  10. data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
  11. data/lib/mongoid/association/embedded/embeds_many/proxy.rb +11 -4
  12. data/lib/mongoid/association/nested/many.rb +1 -1
  13. data/lib/mongoid/association/nested/one.rb +4 -2
  14. data/lib/mongoid/association/proxy.rb +7 -2
  15. data/lib/mongoid/association/referenced/auto_save.rb +2 -2
  16. data/lib/mongoid/association/referenced/has_many/enumerable.rb +493 -495
  17. data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
  18. data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
  19. data/lib/mongoid/association/relatable.rb +0 -2
  20. data/lib/mongoid/attributes/projector.rb +120 -0
  21. data/lib/mongoid/attributes.rb +24 -13
  22. data/lib/mongoid/cacheable.rb +2 -2
  23. data/lib/mongoid/clients/factory.rb +22 -8
  24. data/lib/mongoid/clients.rb +1 -1
  25. data/lib/mongoid/config/environment.rb +1 -9
  26. data/lib/mongoid/config.rb +19 -2
  27. data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
  28. data/lib/mongoid/contextual/atomic.rb +2 -7
  29. data/lib/mongoid/contextual/none.rb +0 -3
  30. data/lib/mongoid/copyable.rb +1 -1
  31. data/lib/mongoid/criteria/findable.rb +1 -1
  32. data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
  33. data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
  34. data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
  35. data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
  36. data/lib/mongoid/criteria/queryable/selectable.rb +10 -10
  37. data/lib/mongoid/criteria/queryable/storable.rb +4 -4
  38. data/lib/mongoid/criteria.rb +5 -6
  39. data/lib/mongoid/document.rb +3 -18
  40. data/lib/mongoid/errors/delete_restriction.rb +8 -9
  41. data/lib/mongoid/errors/mongoid_error.rb +1 -1
  42. data/lib/mongoid/errors.rb +0 -2
  43. data/lib/mongoid/evolvable.rb +1 -1
  44. data/lib/mongoid/extensions/boolean.rb +1 -2
  45. data/lib/mongoid/extensions/false_class.rb +1 -1
  46. data/lib/mongoid/extensions/hash.rb +2 -2
  47. data/lib/mongoid/extensions/true_class.rb +1 -1
  48. data/lib/mongoid/fields.rb +43 -5
  49. data/lib/mongoid/inspectable.rb +1 -1
  50. data/lib/mongoid/interceptable.rb +1 -1
  51. data/lib/mongoid/matcher/bits.rb +41 -0
  52. data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
  53. data/lib/mongoid/matcher/bits_all_set.rb +20 -0
  54. data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
  55. data/lib/mongoid/matcher/bits_any_set.rb +20 -0
  56. data/lib/mongoid/matcher/expression.rb +4 -0
  57. data/lib/mongoid/matcher/field_operator.rb +6 -0
  58. data/lib/mongoid/matcher/mod.rb +17 -0
  59. data/lib/mongoid/matcher/type.rb +99 -0
  60. data/lib/mongoid/matcher.rb +7 -0
  61. data/lib/mongoid/persistable/deletable.rb +1 -2
  62. data/lib/mongoid/persistable/destroyable.rb +8 -2
  63. data/lib/mongoid/persistable/updatable.rb +27 -2
  64. data/lib/mongoid/persistence_context.rb +1 -3
  65. data/lib/mongoid/query_cache.rb +36 -40
  66. data/lib/mongoid/selectable.rb +5 -7
  67. data/lib/mongoid/shardable.rb +21 -5
  68. data/lib/mongoid/tasks/database.rb +1 -1
  69. data/lib/mongoid/touchable.rb +23 -4
  70. data/lib/mongoid/validatable/associated.rb +1 -1
  71. data/lib/mongoid/validatable/presence.rb +3 -3
  72. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  73. data/lib/mongoid/version.rb +1 -1
  74. data/lib/mongoid.rb +0 -1
  75. data/lib/rails/generators/mongoid/config/templates/mongoid.yml +1 -1
  76. data/spec/integration/app_spec.rb +0 -3
  77. data/spec/integration/associations/embeds_many_spec.rb +44 -0
  78. data/spec/integration/associations/has_one_spec.rb +48 -0
  79. data/spec/integration/criteria/date_field_spec.rb +1 -1
  80. data/spec/integration/document_spec.rb +9 -0
  81. data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
  82. data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
  83. data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
  84. data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
  85. data/spec/integration/matcher_operator_data/comment.yml +22 -0
  86. data/spec/integration/matcher_operator_data/in.yml +16 -0
  87. data/spec/integration/matcher_operator_data/mod.yml +55 -0
  88. data/spec/integration/matcher_operator_data/type.yml +70 -0
  89. data/spec/integration/matcher_operator_data/type_array.yml +16 -0
  90. data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
  91. data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
  92. data/spec/integration/matcher_operator_data/type_code.yml +26 -0
  93. data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
  94. data/spec/integration/matcher_operator_data/type_date.yml +39 -0
  95. data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
  96. data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
  97. data/spec/integration/matcher_operator_data/type_double.yml +15 -0
  98. data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
  99. data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
  100. data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
  101. data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
  102. data/spec/integration/matcher_operator_data/type_null.yml +23 -0
  103. data/spec/integration/matcher_operator_data/type_object.yml +23 -0
  104. data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
  105. data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
  106. data/spec/integration/matcher_operator_data/type_string.yml +15 -0
  107. data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
  108. data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
  109. data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
  110. data/spec/integration/stringified_symbol_field_spec.rb +2 -2
  111. data/spec/lite_spec_helper.rb +2 -0
  112. data/spec/mongoid/association/depending_spec.rb +391 -352
  113. data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +4 -17
  114. data/spec/mongoid/association/nested/one_spec.rb +18 -14
  115. data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -25
  116. data/spec/mongoid/association/referenced/belongs_to_query_spec.rb +0 -20
  117. data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
  118. data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
  119. data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1 -1
  120. data/spec/mongoid/association/referenced/has_many_models.rb +0 -17
  121. data/spec/mongoid/association/referenced/has_one_models.rb +8 -0
  122. data/spec/mongoid/atomic/paths_spec.rb +64 -12
  123. data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
  124. data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
  125. data/spec/mongoid/attributes/projector_spec.rb +41 -0
  126. data/spec/mongoid/attributes_spec.rb +98 -6
  127. data/spec/mongoid/clients/factory_spec.rb +51 -9
  128. data/spec/mongoid/clients/options_spec.rb +3 -11
  129. data/spec/mongoid/config/environment_spec.rb +8 -86
  130. data/spec/mongoid/config_spec.rb +32 -0
  131. data/spec/mongoid/contextual/atomic_spec.rb +25 -64
  132. data/spec/mongoid/contextual/geo_near_spec.rb +1 -1
  133. data/spec/mongoid/contextual/mongo_spec.rb +2 -2
  134. data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
  135. data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
  136. data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
  137. data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
  138. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +229 -24
  139. data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
  140. data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
  141. data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
  142. data/spec/mongoid/criteria_projection_spec.rb +411 -0
  143. data/spec/mongoid/criteria_spec.rb +0 -279
  144. data/spec/mongoid/document_query_spec.rb +0 -51
  145. data/spec/mongoid/document_spec.rb +14 -34
  146. data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
  147. data/spec/mongoid/errors/mongoid_error_spec.rb +8 -20
  148. data/spec/mongoid/extensions/false_class_spec.rb +1 -1
  149. data/spec/mongoid/extensions/string_spec.rb +5 -5
  150. data/spec/mongoid/extensions/true_class_spec.rb +1 -1
  151. data/spec/mongoid/fields/localized_spec.rb +4 -4
  152. data/spec/mongoid/fields_spec.rb +4 -4
  153. data/spec/mongoid/inspectable_spec.rb +12 -4
  154. data/spec/mongoid/persistable/deletable_spec.rb +175 -1
  155. data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
  156. data/spec/mongoid/persistable/savable_spec.rb +3 -5
  157. data/spec/mongoid/persistable/updatable_spec.rb +0 -2
  158. data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
  159. data/spec/mongoid/persistable_spec.rb +2 -2
  160. data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
  161. data/spec/mongoid/query_cache_spec.rb +0 -24
  162. data/spec/mongoid/reloadable_spec.rb +18 -1
  163. data/spec/mongoid/shardable_spec.rb +44 -0
  164. data/spec/mongoid/touchable_spec.rb +104 -16
  165. data/spec/mongoid/touchable_spec_models.rb +52 -0
  166. data/spec/mongoid/validatable_spec.rb +1 -1
  167. data/spec/shared/lib/mrss/cluster_config.rb +3 -8
  168. data/spec/shared/lib/mrss/constraints.rb +10 -41
  169. data/spec/shared/lib/mrss/docker_runner.rb +1 -7
  170. data/spec/shared/lib/mrss/server_version_registry.rb +12 -17
  171. data/spec/shared/lib/mrss/spec_organizer.rb +1 -18
  172. data/spec/shared/share/Dockerfile.erb +33 -125
  173. data/spec/shared/shlib/server.sh +23 -100
  174. data/spec/shared/shlib/set_env.sh +1 -4
  175. data/spec/spec_helper.rb +7 -3
  176. data/spec/support/client_registry.rb +9 -0
  177. data/spec/support/models/address.rb +0 -4
  178. data/spec/support/models/bolt.rb +8 -0
  179. data/spec/support/models/hole.rb +13 -0
  180. data/spec/support/models/mop.rb +0 -1
  181. data/spec/support/models/nut.rb +8 -0
  182. data/spec/support/models/person.rb +6 -9
  183. data/spec/support/models/sealer.rb +8 -0
  184. data/spec/support/models/shirt.rb +12 -0
  185. data/spec/support/models/spacer.rb +8 -0
  186. data/spec/support/models/threadlocker.rb +8 -0
  187. data/spec/support/models/washer.rb +8 -0
  188. data.tar.gz.sig +0 -0
  189. metadata +609 -545
  190. metadata.gz.sig +0 -0
  191. data/lib/mongoid/errors/empty_config_file.rb +0 -26
  192. data/lib/mongoid/errors/invalid_config_file.rb +0 -26
  193. data/spec/integration/contextual/empty_spec.rb +0 -142
  194. data/spec/mongoid/errors/invalid_config_file_spec.rb +0 -32
  195. data/spec/shared/bin/s3-copy +0 -45
  196. data/spec/shared/bin/s3-upload +0 -69
  197. data/spec/shared/lib/mrss/event_subscriber.rb +0 -200
  198. data/spec/shared/share/haproxy-1.conf +0 -16
  199. data/spec/shared/share/haproxy-2.conf +0 -17
  200. data/spec/support/cluster_config.rb +0 -158
@@ -10,21 +10,21 @@ set_fcv() {
10
10
 
11
11
  add_uri_option() {
12
12
  opt=$1
13
-
13
+
14
14
  if ! echo $MONGODB_URI |sed -e s,//,, |grep -q /; then
15
15
  MONGODB_URI="$MONGODB_URI/"
16
16
  fi
17
-
17
+
18
18
  if ! echo $MONGODB_URI |grep -q '?'; then
19
19
  MONGODB_URI="$MONGODB_URI?"
20
20
  fi
21
-
21
+
22
22
  MONGODB_URI="$MONGODB_URI&$opt"
23
23
  }
24
24
 
25
25
  prepare_server() {
26
26
  arch=$1
27
-
27
+
28
28
  if test -n "$USE_OPT_MONGODB"; then
29
29
  export BINDIR=/opt/mongodb/bin
30
30
  export PATH=$BINDIR:$PATH
@@ -39,7 +39,7 @@ prepare_server() {
39
39
  else
40
40
  download_version="$MONGODB_VERSION"
41
41
  fi
42
-
42
+
43
43
  url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
44
44
 
45
45
  prepare_server_from_url $url
@@ -80,7 +80,7 @@ install_mlaunch_pip() {
80
80
  # mlaunch is preinstalled in the docker image, do not install it here
81
81
  return
82
82
  fi
83
-
83
+
84
84
  python -V || true
85
85
  python3 -V || true
86
86
  pythonpath="$MONGO_ORCHESTRATION_HOME"/python
@@ -96,20 +96,20 @@ install_mlaunch_git() {
96
96
  python3 -V || true
97
97
  which pip || true
98
98
  which pip3 || true
99
-
99
+
100
100
  if false; then
101
101
  if ! virtualenv --version; then
102
102
  python3 `which pip3` install --user virtualenv
103
103
  export PATH=$HOME/.local/bin:$PATH
104
104
  virtualenv --version
105
105
  fi
106
-
106
+
107
107
  venvpath="$MONGO_ORCHESTRATION_HOME"/venv
108
108
  virtualenv -p python3 $venvpath
109
109
  . $venvpath/bin/activate
110
-
110
+
111
111
  pip3 install psutil pymongo
112
-
112
+
113
113
  git clone $repo mlaunch
114
114
  cd mlaunch
115
115
  git checkout origin/$branch
@@ -118,13 +118,13 @@ install_mlaunch_git() {
118
118
  else
119
119
  pip install --user 'virtualenv==13'
120
120
  export PATH=$HOME/.local/bin:$PATH
121
-
121
+
122
122
  venvpath="$MONGO_ORCHESTRATION_HOME"/venv
123
123
  virtualenv $venvpath
124
124
  . $venvpath/bin/activate
125
-
125
+
126
126
  pip install psutil pymongo
127
-
127
+
128
128
  git clone $repo mlaunch
129
129
  (cd mlaunch &&
130
130
  git checkout origin/$branch &&
@@ -133,32 +133,24 @@ install_mlaunch_git() {
133
133
  fi
134
134
  }
135
135
 
136
- # This function sets followong global variables:
137
- # server_cert_path
138
- # server_ca_path
139
- # server_client_cert_path
140
- #
141
- # These variables are used later to connect to processes via mongo client.
142
136
  calculate_server_args() {
143
137
  local mongo_version=`echo $MONGODB_VERSION |tr -d .`
144
-
138
+
145
139
  if test -z "$mongo_version"; then
146
140
  echo "$MONGODB_VERSION must be set and not contain only dots" 1>&2
147
141
  exit 3
148
142
  fi
149
-
143
+
150
144
  if test $mongo_version = latest; then
151
145
  mongo_version=49
152
146
  fi
153
147
 
154
148
  local args="--setParameter enableTestCommands=1"
155
-
156
- if test $mongo_version -ge 50; then
157
- args="$args --setParameter acceptApiVersion2=1"
158
- elif test $mongo_version -ge 47; then
149
+
150
+ if test $mongo_version -ge 47; then
159
151
  args="$args --setParameter acceptAPIVersion2=1"
160
152
  fi
161
-
153
+
162
154
  # diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
163
155
  # and mlaunch does not support specifying mongod-only parameters:
164
156
  # https://github.com/rueckstiess/mtools/issues/696
@@ -168,31 +160,15 @@ calculate_server_args() {
168
160
  fi
169
161
  local uri_options=
170
162
  if test "$TOPOLOGY" = replica-set; then
171
- args="$args --replicaset --name test-rs --nodes 2 --arbiter"
163
+ args="$args --replicaset --name ruby-driver-rs --nodes 2 --arbiter"
172
164
  export HAVE_ARBITER=1
173
165
  elif test "$TOPOLOGY" = sharded-cluster; then
174
- args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
166
+ args="$args --replicaset --nodes 2 --sharded 1 --name ruby-driver-rs"
175
167
  if test -z "$SINGLE_MONGOS"; then
176
168
  args="$args --mongos 2"
177
169
  fi
178
- elif test "$TOPOLOGY" = standalone; then
179
- args="$args --single"
180
- elif test "$TOPOLOGY" = load-balanced; then
181
- args="$args --replicaset --nodes 2 --sharded 1 --name test-rs --port 27117"
182
- if test -z "$MRSS_ROOT"; then
183
- echo "Please set MRSS_ROOT" 1>&2
184
- exit 2
185
- fi
186
- if test -n "$SINGLE_MONGOS"; then
187
- haproxy_config=$MRSS_ROOT/share/haproxy-1.conf
188
- else
189
- args="$args --mongos 2"
190
- haproxy_config=$MRSS_ROOT/share/haproxy-2.conf
191
- fi
192
- uri_options="$uri_options&loadBalanced=true"
193
170
  else
194
- echo "Unknown topology: $TOPOLOGY" 1>&2
195
- exit 1
171
+ args="$args --single"
196
172
  fi
197
173
  if test -n "$MMAPV1"; then
198
174
  args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
@@ -215,6 +191,7 @@ calculate_server_args() {
215
191
  fi
216
192
  fi
217
193
 
194
+ local server_cert_path server_ca_path server_client_cert_path
218
195
  if test "$SSL" = ssl || test -n "$OCSP_ALGORITHM"; then
219
196
  if test -n "$OCSP_ALGORITHM"; then
220
197
  if test "$OCSP_MUST_STAPLE" = 1; then
@@ -293,7 +270,7 @@ calculate_server_args() {
293
270
  ocsp_args="$ocsp_args --fault $OCSP_STATUS"
294
271
  fi
295
272
  fi
296
-
273
+
297
274
  OCSP_ARGS="$ocsp_args"
298
275
  SERVER_ARGS="$args"
299
276
  URI_OPTIONS="$uri_options"
@@ -310,58 +287,4 @@ launch_ocsp_mock() {
310
287
  launch_server() {
311
288
  local dbdir="$1"
312
289
  python -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
313
-
314
- if test "$TOPOLOGY" = sharded-cluster && test $MONGODB_VERSION = 3.6; then
315
- # On 3.6 server the sessions collection is not immediately available,
316
- # so we run the refreshLogicalSessionCacheNow command on the config server
317
- # and again on each mongos in order for the mongoses
318
- # to correctly report logicalSessionTimeoutMinutes.
319
- mongos_regex="\s*mongos\s+([0-9]+)\s+running\s+[0-9]+"
320
- config_server_regex="\s*config\sserver\s+([0-9]+)\s+running\s+[0-9]+"
321
- config_server=""
322
- mongoses=()
323
- if test "$AUTH" = auth
324
- then
325
- base_url="mongodb://bob:pwd123@localhost"
326
- else
327
- base_url="mongodb://localhost"
328
- fi
329
- if test "$SSL" = "ssl"
330
- then
331
- mongo_command="${BINDIR}/mongo --ssl --sslPEMKeyFile $server_cert_path --sslCAFile $server_ca_path"
332
- else
333
- mongo_command="${BINDIR}/mongo"
334
- fi
335
-
336
- while read -r line
337
- do
338
- if [[ $line =~ $config_server_regex ]]
339
- then
340
- port="${BASH_REMATCH[1]}"
341
- config_server="${base_url}:${port}"
342
- fi
343
- if [[ $line =~ $mongos_regex ]]
344
- then
345
- port="${BASH_REMATCH[1]}"
346
- mongoses+=("${base_url}:${port}")
347
- fi
348
- done < <(python -m mtools.mlaunch.mlaunch list --dir "$dbdir" --binarypath "$BINDIR")
349
-
350
- if [ -n "$config_server" ]; then
351
- ${mongo_command} "$config_server" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
352
- for mongos in ${mongoses[*]}
353
- do
354
- ${mongo_command} "$mongos" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
355
- done
356
- fi
357
- fi
358
-
359
- if test "$TOPOLOGY" = load-balanced; then
360
- if test -z "$haproxy_config"; then
361
- echo haproxy_config should have been set 1>&2
362
- exit 3
363
- fi
364
-
365
- haproxy -D -f $haproxy_config -p $mongodb_dir/haproxy.pid
366
- fi
367
290
  }
@@ -68,12 +68,9 @@ set_env_ruby() {
68
68
  export PATH=`pwd`/ruby-head/bin:`pwd`/ruby-head/lib/ruby/gems/2.6.0/bin:$PATH
69
69
  ruby --version
70
70
  ruby --version |grep dev
71
- elif test "$SYSTEM_RUBY" = 1; then
72
- # Nothing
73
- :
74
71
  else
75
72
  if test "$USE_OPT_TOOLCHAIN" = 1; then
76
- # Nothing, also PATH is already set
73
+ # nothing, also PATH is already set
77
74
  :
78
75
  elif true; then
79
76
 
data/spec/spec_helper.rb CHANGED
@@ -29,13 +29,17 @@ def database_id_alt
29
29
  "mongoid_test_alt"
30
30
  end
31
31
 
32
+ require 'mrss/cluster_config'
33
+ require 'support/client_registry'
34
+ require 'mrss/constraints'
35
+
36
+ ClusterConfig = Mrss::ClusterConfig
37
+
32
38
  require 'support/authorization'
33
39
  require 'support/expectations'
34
40
  require 'support/helpers'
35
41
  require 'support/macros'
36
- require 'support/cluster_config'
37
42
  require 'support/constraints'
38
- require 'mrss/constraints'
39
43
 
40
44
  # Give MongoDB servers time to start up in CI environments
41
45
  if SpecConfig.instance.ci?
@@ -43,7 +47,7 @@ if SpecConfig.instance.ci?
43
47
  client = Mongo::Client.new(SpecConfig.instance.addresses)
44
48
  while starting
45
49
  begin
46
- client.command(ping: 1)
50
+ client.command(Mongo::Server::Monitor::Connection::ISMASTER)
47
51
  break
48
52
  rescue Mongo::Error::OperationFailure => e
49
53
  sleep(2)
@@ -0,0 +1,9 @@
1
+ require 'singleton'
2
+
3
+ class ClientRegistry
4
+ include Singleton
5
+
6
+ def global_client(name)
7
+ Mongoid.default_client
8
+ end
9
+ end
@@ -78,9 +78,5 @@ class Address
78
78
  def streets
79
79
  all.map(&:street)
80
80
  end
81
-
82
- def city_and_state(city:, state:)
83
- where(city: city, state: state)
84
- end
85
81
  end
86
82
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Bolt
5
+ include Mongoid::Document
6
+
7
+ belongs_to :hole
8
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Hole
5
+ include Mongoid::Document
6
+
7
+ has_one :bolt, dependent: :destroy
8
+ has_one :threadlocker, dependent: :delete_all
9
+ has_one :sealer, dependent: :restrict_with_exception
10
+ has_many :nuts, dependent: :destroy
11
+ has_many :washers, dependent: :delete_all
12
+ has_many :spacers, dependent: :restrict_with_exception
13
+ end
@@ -23,4 +23,3 @@ class Mop
23
23
  field :regexp_field, type: Regexp
24
24
  field :bson_regexp_field, type: BSON::Regexp::Raw
25
25
  end
26
-
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Nut
5
+ include Mongoid::Document
6
+
7
+ belongs_to :hole
8
+ end
@@ -136,10 +136,6 @@ class Person
136
136
  scope :without_ssn, ->{ without(:ssn) }
137
137
  scope :search, ->(query){ any_of({ title: query }) }
138
138
 
139
- def self.older_than(age:)
140
- where(:age.gt => age)
141
- end
142
-
143
139
  def score_with_rescoring=(score)
144
140
  @rescored = score.to_i + 20
145
141
  self.score_without_rescoring = score
@@ -210,15 +206,16 @@ class Person
210
206
  self.map_with_default["key"] = value
211
207
  end
212
208
 
213
- def set_personal_data(ssn:, age:)
214
- self.ssn = ssn
215
- self.age = age
216
- end
217
-
218
209
  reset_callbacks(:validate)
219
210
  reset_callbacks(:create)
220
211
  reset_callbacks(:save)
221
212
  reset_callbacks(:destroy)
213
+
214
+ private
215
+
216
+ def secret_name
217
+ "secret"
218
+ end
222
219
  end
223
220
 
224
221
  require "support/models/doctor"
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Sealer
5
+ include Mongoid::Document
6
+
7
+ belongs_to :hole
8
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Shirt
5
+ include Mongoid::Document
6
+
7
+ field :color, type: String
8
+
9
+ unalias_attribute :id
10
+
11
+ field :id, type: String
12
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Spacer
5
+ include Mongoid::Document
6
+
7
+ belongs_to :hole
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Threadlocker
5
+ include Mongoid::Document
6
+
7
+ belongs_to :hole
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+ # encoding: utf-8
3
+
4
+ class Washer
5
+ include Mongoid::Document
6
+
7
+ belongs_to :hole
8
+ end
data.tar.gz.sig CHANGED
Binary file