mongoid 8.0.12 → 8.1.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +3 -3
- data/README.md +3 -3
- data/Rakefile +17 -66
- data/lib/config/locales/en.yml +46 -14
- data/lib/mongoid/association/accessors.rb +3 -7
- data/lib/mongoid/association/builders.rb +1 -1
- data/lib/mongoid/association/eager_loadable.rb +0 -3
- data/lib/mongoid/association/embedded/batchable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/buildable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_many/buildable.rb +3 -2
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +6 -6
- data/lib/mongoid/association/embedded/embeds_one/buildable.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +2 -2
- data/lib/mongoid/association/macros.rb +0 -6
- data/lib/mongoid/association/nested/one.rb +40 -2
- data/lib/mongoid/association/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +6 -23
- data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
- data/lib/mongoid/association/reflections.rb +2 -2
- data/lib/mongoid/atomic.rb +7 -16
- data/lib/mongoid/attributes/dynamic.rb +1 -1
- data/lib/mongoid/attributes/nested.rb +2 -2
- data/lib/mongoid/attributes/processing.rb +5 -29
- data/lib/mongoid/attributes/projector.rb +1 -1
- data/lib/mongoid/attributes/readonly.rb +1 -1
- data/lib/mongoid/attributes.rb +8 -2
- data/lib/mongoid/changeable.rb +107 -5
- data/lib/mongoid/clients/factory.rb +0 -4
- data/lib/mongoid/clients/storage_options.rb +2 -5
- data/lib/mongoid/clients/validators/storage.rb +1 -13
- data/lib/mongoid/collection_configurable.rb +58 -0
- data/lib/mongoid/composable.rb +2 -0
- data/lib/mongoid/config/defaults.rb +60 -0
- data/lib/mongoid/config/options.rb +0 -3
- data/lib/mongoid/config/validators/async_query_executor.rb +24 -0
- data/lib/mongoid/config/validators.rb +1 -0
- data/lib/mongoid/config.rb +88 -27
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +233 -33
- data/lib/mongoid/contextual/mongo/documents_loader.rb +177 -0
- data/lib/mongoid/contextual/mongo.rb +370 -133
- data/lib/mongoid/contextual/none.rb +162 -7
- data/lib/mongoid/contextual.rb +12 -0
- data/lib/mongoid/criteria/findable.rb +2 -2
- data/lib/mongoid/criteria/includable.rb +4 -3
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -15
- data/lib/mongoid/criteria/queryable/key.rb +1 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +1 -1
- data/lib/mongoid/criteria/queryable/optional.rb +8 -8
- data/lib/mongoid/criteria/queryable/selectable.rb +43 -12
- data/lib/mongoid/criteria/queryable/selector.rb +1 -1
- data/lib/mongoid/criteria/queryable/storable.rb +1 -1
- data/lib/mongoid/criteria.rb +6 -5
- data/lib/mongoid/deprecable.rb +1 -2
- data/lib/mongoid/deprecation.rb +3 -3
- data/lib/mongoid/document.rb +1 -8
- data/lib/mongoid/errors/create_collection_failure.rb +33 -0
- data/lib/mongoid/errors/drop_collection_failure.rb +27 -0
- data/lib/mongoid/errors/immutable_attribute.rb +26 -0
- data/lib/mongoid/errors/invalid_async_query_executor.rb +25 -0
- data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +22 -0
- data/lib/mongoid/errors/invalid_storage_parent.rb +2 -0
- data/lib/mongoid/errors.rb +4 -1
- data/lib/mongoid/extensions/hash.rb +3 -51
- data/lib/mongoid/extensions/object.rb +2 -2
- data/lib/mongoid/extensions/time.rb +2 -0
- data/lib/mongoid/fields/localized.rb +10 -0
- data/lib/mongoid/fields/standard.rb +10 -0
- data/lib/mongoid/fields.rb +59 -35
- data/lib/mongoid/findable.rb +27 -3
- data/lib/mongoid/interceptable.rb +6 -116
- data/lib/mongoid/matcher/eq_impl.rb +1 -1
- data/lib/mongoid/matcher/type.rb +1 -1
- data/lib/mongoid/persistable/creatable.rb +1 -0
- data/lib/mongoid/persistable/deletable.rb +1 -1
- data/lib/mongoid/persistable/savable.rb +13 -1
- data/lib/mongoid/persistable/unsettable.rb +2 -2
- data/lib/mongoid/persistable/updatable.rb +51 -1
- data/lib/mongoid/persistable/upsertable.rb +20 -1
- data/lib/mongoid/persistable.rb +3 -0
- data/lib/mongoid/query_cache.rb +5 -1
- data/lib/mongoid/railties/database.rake +7 -2
- data/lib/mongoid/reloadable.rb +5 -3
- data/lib/mongoid/stateful.rb +22 -1
- data/lib/mongoid/tasks/database.rake +12 -0
- data/lib/mongoid/tasks/database.rb +20 -0
- data/lib/mongoid/timestamps/created.rb +1 -8
- data/lib/mongoid/traversable.rb +0 -12
- data/lib/mongoid/utils.rb +22 -0
- data/lib/mongoid/validatable/associated.rb +17 -98
- data/lib/mongoid/validatable/macros.rb +5 -20
- data/lib/mongoid/validatable.rb +4 -10
- data/lib/mongoid/version.rb +1 -5
- data/lib/mongoid/warnings.rb +17 -1
- data/lib/mongoid.rb +16 -3
- data/spec/integration/app_spec.rb +2 -12
- data/spec/integration/associations/embeds_one_spec.rb +5 -25
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +0 -40
- data/spec/integration/callbacks_spec.rb +99 -12
- data/spec/integration/discriminator_key_spec.rb +4 -5
- data/spec/integration/i18n_fallbacks_spec.rb +3 -2
- data/spec/mongoid/association/eager_spec.rb +2 -24
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +27 -0
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +20 -25
- data/spec/mongoid/association/embedded/embeds_many_models.rb +1 -0
- data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +0 -4
- data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +15 -2
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2 -18
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +42 -55
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +9 -50
- data/spec/mongoid/association/syncable_spec.rb +1 -1
- data/spec/mongoid/attributes_spec.rb +3 -33
- data/spec/mongoid/changeable_spec.rb +299 -24
- data/spec/mongoid/clients/factory_spec.rb +0 -30
- data/spec/mongoid/clients_spec.rb +122 -13
- data/spec/mongoid/collection_configurable_spec.rb +158 -0
- data/spec/mongoid/config/defaults_spec.rb +160 -0
- data/spec/mongoid/config_spec.rb +154 -27
- data/spec/mongoid/contextual/memory_spec.rb +332 -76
- data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +187 -0
- data/spec/mongoid/contextual/mongo_spec.rb +1009 -125
- data/spec/mongoid/contextual/none_spec.rb +49 -2
- data/spec/mongoid/copyable_spec.rb +2 -10
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +4 -10
- data/spec/mongoid/criteria/queryable/options_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +419 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selector_spec.rb +3 -76
- data/spec/mongoid/criteria/queryable/storable_spec.rb +0 -72
- data/spec/mongoid/criteria_projection_spec.rb +1 -4
- data/spec/mongoid/criteria_spec.rb +5 -9
- data/spec/mongoid/document_spec.rb +0 -27
- data/spec/mongoid/errors/readonly_document_spec.rb +2 -2
- data/spec/mongoid/extensions/hash_spec.rb +3 -239
- data/spec/mongoid/extensions/time_spec.rb +8 -43
- data/spec/mongoid/extensions/time_with_zone_spec.rb +7 -52
- data/spec/mongoid/fields/localized_spec.rb +46 -28
- data/spec/mongoid/fields_spec.rb +136 -77
- data/spec/mongoid/findable_spec.rb +391 -34
- data/spec/mongoid/indexable_spec.rb +16 -10
- data/spec/mongoid/interceptable_spec.rb +153 -442
- data/spec/mongoid/interceptable_spec_models.rb +111 -51
- data/spec/mongoid/persistable/deletable_spec.rb +26 -6
- data/spec/mongoid/persistable/destroyable_spec.rb +26 -6
- data/spec/mongoid/persistable/incrementable_spec.rb +37 -0
- data/spec/mongoid/persistable/logical_spec.rb +37 -0
- data/spec/mongoid/persistable/poppable_spec.rb +36 -0
- data/spec/mongoid/persistable/pullable_spec.rb +72 -0
- data/spec/mongoid/persistable/pushable_spec.rb +72 -0
- data/spec/mongoid/persistable/renamable_spec.rb +36 -0
- data/spec/mongoid/persistable/savable_spec.rb +96 -0
- data/spec/mongoid/persistable/settable_spec.rb +37 -0
- data/spec/mongoid/persistable/unsettable_spec.rb +36 -0
- data/spec/mongoid/persistable/updatable_spec.rb +20 -28
- data/spec/mongoid/persistable/upsertable_spec.rb +80 -6
- data/spec/mongoid/persistence_context_spec.rb +7 -57
- data/spec/mongoid/query_cache_spec.rb +56 -61
- data/spec/mongoid/reloadable_spec.rb +24 -28
- data/spec/mongoid/scopable_spec.rb +70 -0
- data/spec/mongoid/serializable_spec.rb +23 -44
- data/spec/mongoid/stateful_spec.rb +122 -8
- data/spec/mongoid/tasks/database_rake_spec.rb +74 -0
- data/spec/mongoid/tasks/database_spec.rb +127 -0
- data/spec/mongoid/timestamps/created_spec.rb +0 -23
- data/spec/mongoid/timestamps_spec.rb +9 -11
- data/spec/mongoid/touchable_spec.rb +277 -5
- data/spec/mongoid/touchable_spec_models.rb +3 -1
- data/spec/mongoid/traversable_spec.rb +9 -24
- data/spec/mongoid/validatable/associated_spec.rb +34 -27
- data/spec/mongoid/validatable/numericality_spec.rb +0 -16
- data/spec/mongoid/validatable/uniqueness_spec.rb +2 -3
- data/spec/mongoid_spec.rb +36 -10
- data/spec/shared/lib/mrss/docker_runner.rb +1 -1
- data/spec/shared/lib/mrss/server_version_registry.rb +1 -1
- data/spec/shared/lib/mrss/spec_organizer.rb +3 -32
- data/spec/shared/share/Dockerfile.erb +85 -15
- data/spec/shared/shlib/distro.sh +0 -10
- data/spec/shared/shlib/server.sh +27 -34
- data/spec/shared/shlib/set_env.sh +68 -9
- data/spec/spec_helper.rb +5 -0
- data/spec/support/expectations.rb +17 -20
- data/spec/support/immutable_ids.rb +118 -0
- data/spec/support/macros.rb +47 -15
- data/spec/support/models/artist.rb +0 -1
- data/spec/support/models/band.rb +1 -0
- data/spec/support/models/building.rb +2 -0
- data/spec/support/models/name.rb +0 -10
- data/spec/support/models/person.rb +0 -1
- data/spec/support/models/product.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +715 -662
- metadata.gz.sig +2 -0
- data/lib/mongoid/validatable/numericality.rb +0 -19
- data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +0 -61
- data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +0 -61
- data/spec/shared/CANDIDATE.md +0 -28
- data/spec/shared/lib/mrss/release/candidate.rb +0 -281
- data/spec/shared/lib/mrss/release/product_data.rb +0 -144
- data/spec/shared/lib/tasks/candidate.rake +0 -64
- data/spec/support/models/purse.rb +0 -9
data/spec/shared/shlib/server.sh
CHANGED
|
@@ -35,34 +35,38 @@ add_uri_option() {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
prepare_server() {
|
|
38
|
+
arch=$1
|
|
39
|
+
|
|
38
40
|
if test -n "$USE_OPT_MONGODB"; then
|
|
39
41
|
export BINDIR=/opt/mongodb/bin
|
|
40
42
|
export PATH=$BINDIR:$PATH
|
|
41
43
|
return
|
|
42
44
|
fi
|
|
43
45
|
|
|
44
|
-
|
|
46
|
+
if test "$MONGODB_VERSION" = latest; then
|
|
47
|
+
# Test on the most recent published 4.3 release.
|
|
48
|
+
# https://jira.mongodb.org/browse/RUBY-1724
|
|
45
49
|
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
. $PROJECT_DIRECTORY/.mod/drivers-evergreen-tools/.evergreen/download-mongodb.sh
|
|
51
|
+
|
|
52
|
+
get_distro
|
|
53
|
+
get_mongodb_download_url_for "$DISTRO" "latest"
|
|
54
|
+
prepare_server_from_url $MONGODB_DOWNLOAD_URL
|
|
55
|
+
else
|
|
56
|
+
download_version="$MONGODB_VERSION"
|
|
57
|
+
url=`$(dirname $0)/get-mongodb-download-url $download_version $arch`
|
|
58
|
+
prepare_server_from_url $url
|
|
59
|
+
fi
|
|
48
60
|
|
|
49
|
-
get_mongodb_download_url_for "$arch" "$MONGODB_VERSION"
|
|
50
|
-
prepare_server_from_url "$MONGODB_DOWNLOAD_URL" "$MONGOSH_DOWNLOAD_URL"
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
prepare_server_from_url() {
|
|
54
|
-
|
|
55
|
-
mongosh_url=$2
|
|
64
|
+
url=$1
|
|
56
65
|
|
|
57
|
-
dirname=`basename $
|
|
66
|
+
dirname=`basename $url |sed -e s/.tgz//`
|
|
58
67
|
mongodb_dir="$MONGO_ORCHESTRATION_HOME"/mdb/"$dirname"
|
|
59
68
|
mkdir -p "$mongodb_dir"
|
|
60
|
-
curl --retry 3 $
|
|
61
|
-
|
|
62
|
-
if test -n "$mongosh_url"; then
|
|
63
|
-
curl --retry 3 $mongosh_url | tar xz -C "$mongodb_dir" --strip-components 1 -f -
|
|
64
|
-
fi
|
|
65
|
-
|
|
69
|
+
curl --retry 3 $url | tar xz -C "$mongodb_dir" --strip-components 1 -f -
|
|
66
70
|
BINDIR="$mongodb_dir"/bin
|
|
67
71
|
export PATH="$BINDIR":$PATH
|
|
68
72
|
}
|
|
@@ -78,7 +82,7 @@ install_mlaunch_venv() {
|
|
|
78
82
|
# Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
|
|
79
83
|
# the python3-venv package is also installed (it lacks the ensurepip
|
|
80
84
|
# module).
|
|
81
|
-
sudo apt-get
|
|
85
|
+
sudo apt-get install --yes python3-venv
|
|
82
86
|
fi
|
|
83
87
|
if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
|
|
84
88
|
python3 -m pip list |grep mtools
|
|
@@ -100,7 +104,6 @@ install_mlaunch_venv() {
|
|
|
100
104
|
#pip install 'mtools==1.7' 'pymongo==4.1' python-dateutil psutil
|
|
101
105
|
|
|
102
106
|
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
|
103
|
-
pip install --upgrade setuptools
|
|
104
107
|
pip install 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
|
|
105
108
|
fi
|
|
106
109
|
}
|
|
@@ -166,26 +169,13 @@ install_mlaunch_git() {
|
|
|
166
169
|
fi
|
|
167
170
|
}
|
|
168
171
|
|
|
169
|
-
install_haproxy() {
|
|
170
|
-
if ! command -v haproxy &> /dev/null; then
|
|
171
|
-
if ! command -v apt-get &> /dev/null; then
|
|
172
|
-
# no apt-get; assume RHEL
|
|
173
|
-
sudo yum -y install haproxy
|
|
174
|
-
else
|
|
175
|
-
sudo apt-get update && sudo apt-get install --yes haproxy
|
|
176
|
-
fi
|
|
177
|
-
else
|
|
178
|
-
echo 'haproxy is present'
|
|
179
|
-
fi
|
|
180
|
-
}
|
|
181
|
-
|
|
182
172
|
install_cmake() {
|
|
183
173
|
if ! command -v cmake &> /dev/null; then
|
|
184
174
|
if ! command -v apt-get &> /dev/null; then
|
|
185
175
|
# no apt-get; assume RHEL
|
|
186
176
|
sudo yum -y install cmake libarchive
|
|
187
177
|
else
|
|
188
|
-
sudo apt-get
|
|
178
|
+
sudo apt-get install --yes cmake
|
|
189
179
|
fi
|
|
190
180
|
else
|
|
191
181
|
echo 'cmake is present'
|
|
@@ -218,14 +208,17 @@ calculate_server_args() {
|
|
|
218
208
|
args="$args --setParameter acceptAPIVersion2=1"
|
|
219
209
|
fi
|
|
220
210
|
|
|
221
|
-
|
|
222
|
-
|
|
211
|
+
# diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
|
|
212
|
+
# and mlaunch does not support specifying mongod-only parameters:
|
|
213
|
+
# https://github.com/rueckstiess/mtools/issues/696
|
|
214
|
+
# Pass it to 3.4 and newer servers where it is accepted by all daemons.
|
|
215
|
+
if test $mongo_version -ge 34; then
|
|
216
|
+
args="$args --setParameter diagnosticDataCollectionEnabled=false"
|
|
217
|
+
fi
|
|
223
218
|
local uri_options=
|
|
224
219
|
if test "$TOPOLOGY" = replica-set; then
|
|
225
220
|
args="$args --replicaset --name test-rs --nodes 2 --arbiter"
|
|
226
221
|
export HAVE_ARBITER=1
|
|
227
|
-
elif test "$TOPOLOGY" = replica-set-single-node; then
|
|
228
|
-
args="$args --replicaset --name test-rs --nodes 1"
|
|
229
222
|
elif test "$TOPOLOGY" = sharded-cluster; then
|
|
230
223
|
args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
|
|
231
224
|
if test -z "$SINGLE_MONGOS"; then
|
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
# When changing, also update the hash in share/Dockerfile.
|
|
2
|
-
|
|
2
|
+
TOOLCHAIN_VERSION=e8c60866f54bed7e336a37df3a97d6ae1b971b7d
|
|
3
3
|
|
|
4
4
|
set_env_java() {
|
|
5
5
|
ls -l /opt || true
|
|
6
6
|
ls -l /usr/lib/jvm || true
|
|
7
7
|
|
|
8
8
|
# Use toolchain java if it exists
|
|
9
|
-
if [ -f /opt/java
|
|
10
|
-
export JAVACMD=/opt/java
|
|
9
|
+
if [ -f /opt/java/jdk8/bin/java ]; then
|
|
10
|
+
export JAVACMD=/opt/java/jdk8/bin/java
|
|
11
|
+
#export PATH=$PATH:/opt/java/jdk8/bin
|
|
12
|
+
fi
|
|
13
|
+
|
|
14
|
+
# ppc64le has it in a different place
|
|
15
|
+
if test -z "$JAVACMD" && [ -f /usr/lib/jvm/java-1.8.0/bin/java ]; then
|
|
16
|
+
export JAVACMD=/usr/lib/jvm/java-1.8.0/bin/java
|
|
17
|
+
#export PATH=$PATH:/usr/lib/jvm/java-1.8.0/bin
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
if true; then
|
|
21
|
+
# newer
|
|
22
|
+
# rhel71-ppc, https://jira.mongodb.org/browse/BUILD-9231
|
|
23
|
+
if test -z "$JAVACMD" &&
|
|
24
|
+
(ls /opt/java || true) |grep -q java-1.8.0-openjdk-1.8.0 &&
|
|
25
|
+
test -f /opt/java/java-1.8.0-openjdk-1.8.0*/bin/java;
|
|
26
|
+
then
|
|
27
|
+
path=$(cd /opt/java && ls -d java-1.8.0-openjdk-1.8.0* |head -n 1)
|
|
28
|
+
export JAVACMD=/opt/java/"$path"/bin/java
|
|
29
|
+
fi
|
|
11
30
|
else
|
|
12
|
-
|
|
31
|
+
# older
|
|
32
|
+
# rhel71-ppc seems to have an /opt/java/jdk8/bin/java but it doesn't work
|
|
33
|
+
if test -n "$JAVACMD" && ! exec $JAVACMD -version; then
|
|
34
|
+
JAVACMD=
|
|
35
|
+
# we will try the /usr/lib/jvm then
|
|
36
|
+
fi
|
|
13
37
|
fi
|
|
14
38
|
|
|
15
39
|
if test -n "$JAVACMD"; then
|
|
@@ -89,13 +113,34 @@ set_env_ruby() {
|
|
|
89
113
|
if test "$USE_OPT_TOOLCHAIN" = 1; then
|
|
90
114
|
# Nothing, also PATH is already set
|
|
91
115
|
:
|
|
116
|
+
elif true; then
|
|
117
|
+
|
|
118
|
+
# For testing toolchains:
|
|
119
|
+
#toolchain_url=https://s3.amazonaws.com//mciuploads/mongo-ruby-toolchain/`host_distro`/f11598d091441ffc8d746aacfdc6c26741a3e629/mongo_ruby_driver_toolchain_`host_distro |tr - _`_patch_f11598d091441ffc8d746aacfdc6c26741a3e629_5e46f2793e8e866f36eda2c5_20_02_14_19_18_18.tar.gz
|
|
120
|
+
toolchain_url=http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/$TOOLCHAIN_VERSION/`host_distro`/$RVM_RUBY.tar.xz
|
|
121
|
+
curl --retry 3 -fL $toolchain_url |tar Jxf -
|
|
122
|
+
export PATH=`pwd`/rubies/$RVM_RUBY/bin:$PATH
|
|
123
|
+
#export PATH=`pwd`/rubies/python/3/bin:$PATH
|
|
124
|
+
|
|
125
|
+
# Attempt to get bundler to report all errors - so far unsuccessful
|
|
126
|
+
#curl --retry 3 -o bundler-openssl.diff https://github.com/bundler/bundler/compare/v2.0.1...p-mongo:report-errors.diff
|
|
127
|
+
#find . -path \*/lib/bundler/fetcher.rb -exec patch {} bundler-openssl.diff \;
|
|
128
|
+
|
|
92
129
|
else
|
|
93
|
-
# For testing unpublished builds:
|
|
94
|
-
#build_url=https://s3.amazonaws.com/mciuploads/mongo-ruby-toolchain/library/`host_distro`/$RVM_RUBY.tar.xz
|
|
95
130
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
131
|
+
# Normal operation
|
|
132
|
+
if ! test -d $HOME/.rubies/$RVM_RUBY/bin; then
|
|
133
|
+
echo "Ruby directory does not exist: $HOME/.rubies/$RVM_RUBY/bin" 1>&2
|
|
134
|
+
echo "Contents of /opt:" 1>&2
|
|
135
|
+
ls -l /opt 1>&2 || true
|
|
136
|
+
echo ".rubies symlink:" 1>&2
|
|
137
|
+
ls -ld $HOME/.rubies 1>&2 || true
|
|
138
|
+
echo "Our rubies:" 1>&2
|
|
139
|
+
ls -l $HOME/.rubies 1>&2 || true
|
|
140
|
+
exit 2
|
|
141
|
+
fi
|
|
142
|
+
export PATH=$HOME/.rubies/$RVM_RUBY/bin:$PATH
|
|
143
|
+
|
|
99
144
|
fi
|
|
100
145
|
|
|
101
146
|
ruby --version
|
|
@@ -106,5 +151,19 @@ set_env_ruby() {
|
|
|
106
151
|
|
|
107
152
|
ruby -v |fgrep $ruby_name
|
|
108
153
|
ruby -v |fgrep $ruby_version
|
|
154
|
+
|
|
155
|
+
# We shouldn't need to update rubygems, and there is value in
|
|
156
|
+
# testing on whatever rubygems came with each supported ruby version
|
|
157
|
+
#echo 'updating rubygems'
|
|
158
|
+
#gem update --system
|
|
159
|
+
|
|
160
|
+
# Only install bundler when not using ruby-head.
|
|
161
|
+
# ruby-head comes with bundler and gem complains
|
|
162
|
+
# because installing bundler would overwrite the bundler binary.
|
|
163
|
+
# We now install bundler in the toolchain, hence nothing needs to be done
|
|
164
|
+
# in the tests.
|
|
165
|
+
if false && echo "$RVM_RUBY" |grep -q jruby; then
|
|
166
|
+
gem install bundler -v '<2'
|
|
167
|
+
fi
|
|
109
168
|
fi
|
|
110
169
|
}
|
data/spec/spec_helper.rb
CHANGED
|
@@ -124,6 +124,11 @@ end
|
|
|
124
124
|
|
|
125
125
|
I18n.config.enforce_available_locales = false
|
|
126
126
|
|
|
127
|
+
|
|
128
|
+
if %w(yes true 1).include?((ENV['TEST_I18N_FALLBACKS'] || '').downcase)
|
|
129
|
+
require "i18n/backend/fallbacks"
|
|
130
|
+
end
|
|
131
|
+
|
|
127
132
|
# The user must be created before any of the tests are loaded, until
|
|
128
133
|
# https://jira.mongodb.org/browse/MONGOID-4827 is implemented.
|
|
129
134
|
client = Mongo::Client.new(SpecConfig.instance.addresses, server_selection_timeout: 3.03)
|
|
@@ -2,30 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
module Mongoid
|
|
4
4
|
module Expectations
|
|
5
|
-
# Previously this method used RSpec::Mocks with .exactly.times(n).and_call_original,
|
|
6
|
-
# which stopped working reliably in Ruby 3.3. Now we directly wrap the target method.
|
|
7
|
-
def expect_query(number)
|
|
8
|
-
if %i[ sharded load-balanced ].include?(ClusterConfig.instance.topology) && number > 0
|
|
9
|
-
skip 'This spec requires replica set or standalone topology'
|
|
10
|
-
end
|
|
11
5
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
def connection_class
|
|
7
|
+
if defined?(Mongo::Server::ConnectionBase)
|
|
8
|
+
Mongo::Server::ConnectionBase
|
|
9
|
+
else
|
|
10
|
+
# Pre-2.8 drivers
|
|
11
|
+
Mongo::Server::Connection
|
|
12
|
+
end
|
|
13
|
+
end
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
def expect_query(number)
|
|
16
|
+
rv = nil
|
|
17
|
+
RSpec::Mocks.with_temporary_scope do
|
|
18
|
+
if number > 0
|
|
19
|
+
expect_any_instance_of(connection_class).to receive(:command_started).exactly(number).times.and_call_original
|
|
20
|
+
else
|
|
21
|
+
expect_any_instance_of(connection_class).not_to receive(:command_started)
|
|
20
22
|
end
|
|
21
|
-
|
|
22
|
-
result = yield
|
|
23
|
-
expect(query_count).to eq(number)
|
|
24
|
-
result
|
|
25
|
-
ensure
|
|
26
|
-
klass.remove_method(:command_started)
|
|
27
|
-
klass.define_method(:command_started, original_method)
|
|
23
|
+
rv = yield
|
|
28
24
|
end
|
|
25
|
+
rv
|
|
29
26
|
end
|
|
30
27
|
|
|
31
28
|
def expect_no_queries(&block)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
module Mongoid
|
|
2
|
+
module ImmutableIds
|
|
3
|
+
def immutable_id_examples_as(name)
|
|
4
|
+
shared_examples_for name do
|
|
5
|
+
shared_examples 'a persisted document' do
|
|
6
|
+
it 'should ignore the change and issue a warning' do
|
|
7
|
+
expect(Mongoid::Warnings).to receive(:warn_mutable_ids)
|
|
8
|
+
expect { invoke_operation! }.not_to raise_error
|
|
9
|
+
expect(id_is_unchanged).not_to be legacy_behavior_expects_id_to_change
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
context 'when immutable_ids is true' do
|
|
13
|
+
before { Mongoid::Config.immutable_ids = true }
|
|
14
|
+
after { Mongoid::Config.immutable_ids = false }
|
|
15
|
+
|
|
16
|
+
it 'should disallow _id to be updated' do
|
|
17
|
+
expect { invoke_operation! }
|
|
18
|
+
.to raise_error(Mongoid::Errors::ImmutableAttribute)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'when id is set to the existing value' do
|
|
22
|
+
let(:new_id_value) { object._id }
|
|
23
|
+
|
|
24
|
+
it 'should allow the update to proceed' do
|
|
25
|
+
expect { invoke_operation! }
|
|
26
|
+
.not_to raise_error
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
context 'when the field is _id' do
|
|
33
|
+
let(:new_id_value) { 1234 }
|
|
34
|
+
|
|
35
|
+
context 'when the document is top-level' do
|
|
36
|
+
let(:legacy_behavior_expects_id_to_change) { false }
|
|
37
|
+
|
|
38
|
+
context 'when the document is new' do
|
|
39
|
+
let(:object) { Person.new }
|
|
40
|
+
|
|
41
|
+
it 'should allow _id to be updated' do
|
|
42
|
+
invoke_operation!
|
|
43
|
+
expect(object.new_record?).to be false
|
|
44
|
+
expect(object.reload._id).to be == new_id_value
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
context 'when the document has been persisted' do
|
|
49
|
+
let(:object) { Person.create }
|
|
50
|
+
let!(:original_id) { object._id }
|
|
51
|
+
let(:id_is_unchanged) { Person.exists?(original_id) }
|
|
52
|
+
|
|
53
|
+
it_behaves_like 'a persisted document'
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
context 'when the document is embedded' do
|
|
58
|
+
let(:parent) { Person.create }
|
|
59
|
+
let(:legacy_behavior_expects_id_to_change) { true }
|
|
60
|
+
|
|
61
|
+
context 'when the document is new' do
|
|
62
|
+
let(:object) { parent.favorites.new }
|
|
63
|
+
|
|
64
|
+
it 'should allow _id to be updated' do
|
|
65
|
+
invoke_operation!
|
|
66
|
+
expect(object.new_record?).to be false
|
|
67
|
+
expect(parent.reload.favorites.first._id).to be == new_id_value
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
context 'when the document has been persisted' do
|
|
72
|
+
let(:object) { parent.favorites.create }
|
|
73
|
+
let!(:original_id) { object._id }
|
|
74
|
+
let(:id_is_unchanged) { parent.favorites.where(_id: original_id).exists? }
|
|
75
|
+
|
|
76
|
+
it_behaves_like 'a persisted document'
|
|
77
|
+
|
|
78
|
+
context 'updating embeds_one via parent' do
|
|
79
|
+
context 'when immutable_ids is false' do
|
|
80
|
+
before { expect(Mongoid::Config.immutable_ids).to be false }
|
|
81
|
+
|
|
82
|
+
it 'should ignore the change' do
|
|
83
|
+
expect(Mongoid::Warnings).to receive(:warn_mutable_ids)
|
|
84
|
+
|
|
85
|
+
parent.pet = pet = Pet.new
|
|
86
|
+
parent.save
|
|
87
|
+
|
|
88
|
+
original_id = pet._id
|
|
89
|
+
new_id = BSON::ObjectId.new
|
|
90
|
+
|
|
91
|
+
expect { parent.update(pet: { _id: new_id }) }.not_to raise_error
|
|
92
|
+
expect(parent.reload.pet._id.to_s).to be == original_id.to_s
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
context 'when immutable_ids is true' do
|
|
97
|
+
before { Mongoid::Config.immutable_ids = true }
|
|
98
|
+
after { Mongoid::Config.immutable_ids = false }
|
|
99
|
+
|
|
100
|
+
it 'should raise an exception' do
|
|
101
|
+
parent.pet = pet = Pet.new
|
|
102
|
+
parent.save
|
|
103
|
+
|
|
104
|
+
original_id = pet._id
|
|
105
|
+
new_id = BSON::ObjectId.new
|
|
106
|
+
|
|
107
|
+
expect { parent.update(pet: { _id: new_id }) }
|
|
108
|
+
.to raise_error(Mongoid::Errors::ImmutableAttribute)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
data/spec/support/macros.rb
CHANGED
|
@@ -2,9 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
module Mongoid
|
|
4
4
|
module Macros
|
|
5
|
-
class I18nBackendWithFallbacks < I18n::Backend::Simple
|
|
6
|
-
include I18n::Backend::Fallbacks
|
|
7
|
-
end
|
|
8
5
|
|
|
9
6
|
def use_spec_mongoid_config
|
|
10
7
|
around do |example|
|
|
@@ -43,18 +40,6 @@ module Mongoid
|
|
|
43
40
|
end
|
|
44
41
|
end
|
|
45
42
|
|
|
46
|
-
def with_i18n_fallbacks
|
|
47
|
-
require_fallbacks
|
|
48
|
-
|
|
49
|
-
around do |example|
|
|
50
|
-
old_backend = I18n.backend
|
|
51
|
-
I18n.backend = I18nBackendWithFallbacks.new
|
|
52
|
-
example.run
|
|
53
|
-
ensure
|
|
54
|
-
I18n.backend = old_backend
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
43
|
def driver_config_override(key, value)
|
|
59
44
|
around do |example|
|
|
60
45
|
existing = Mongo.send(key)
|
|
@@ -93,5 +78,52 @@ module Mongoid
|
|
|
93
78
|
end
|
|
94
79
|
end
|
|
95
80
|
end
|
|
81
|
+
|
|
82
|
+
def override_query_cache(enabled)
|
|
83
|
+
around do |example|
|
|
84
|
+
cache_enabled = Mongo::QueryCache.enabled?
|
|
85
|
+
Mongo::QueryCache.enabled = enabled
|
|
86
|
+
example.run
|
|
87
|
+
Mongo::QueryCache.enabled = cache_enabled
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Override the global persistence context.
|
|
92
|
+
#
|
|
93
|
+
# @param [ :client, :database ] component The component to override.
|
|
94
|
+
# @param [ Object ] value The value to override to.
|
|
95
|
+
def persistence_context_override(component, value)
|
|
96
|
+
around do |example|
|
|
97
|
+
meth = "#{component}_override"
|
|
98
|
+
old_value = Mongoid::Threaded.send(meth)
|
|
99
|
+
Mongoid::Threaded.send("#{meth}=", value)
|
|
100
|
+
example.run
|
|
101
|
+
Mongoid::Threaded.send("#{meth}=", old_value)
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def time_zone_override(tz)
|
|
106
|
+
around do |example|
|
|
107
|
+
old_tz = Time.zone
|
|
108
|
+
Time.zone = tz
|
|
109
|
+
example.run
|
|
110
|
+
Time.zone = old_tz
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def with_default_i18n_configs
|
|
115
|
+
around do |example|
|
|
116
|
+
I18n.locale = :en
|
|
117
|
+
I18n.default_locale = :en
|
|
118
|
+
I18n.try(:fallbacks=, I18n::Locale::Fallbacks.new)
|
|
119
|
+
I18n.enforce_available_locales = false
|
|
120
|
+
example.run
|
|
121
|
+
ensure
|
|
122
|
+
I18n.locale = :en
|
|
123
|
+
I18n.default_locale = :en
|
|
124
|
+
I18n.try(:fallbacks=, I18n::Locale::Fallbacks.new)
|
|
125
|
+
I18n.enforce_available_locales = false
|
|
126
|
+
end
|
|
127
|
+
end
|
|
96
128
|
end
|
|
97
129
|
end
|
data/spec/support/models/band.rb
CHANGED
data/spec/support/models/name.rb
CHANGED
|
@@ -4,8 +4,6 @@ class Name
|
|
|
4
4
|
include Mongoid::Document
|
|
5
5
|
include Mongoid::Attributes::Dynamic
|
|
6
6
|
|
|
7
|
-
validate :is_not_jamis
|
|
8
|
-
|
|
9
7
|
field :_id, type: String, overwrite: true, default: ->{
|
|
10
8
|
"#{first_name}-#{last_name}"
|
|
11
9
|
}
|
|
@@ -25,12 +23,4 @@ class Name
|
|
|
25
23
|
def set_parent=(set = false)
|
|
26
24
|
self.parent_title = namable.title if set
|
|
27
25
|
end
|
|
28
|
-
|
|
29
|
-
private
|
|
30
|
-
|
|
31
|
-
def is_not_jamis
|
|
32
|
-
if first_name == 'Jamis' && last_name == 'Buck'
|
|
33
|
-
errors.add(:base, :invalid)
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
26
|
end
|
|
@@ -70,7 +70,6 @@ class Person
|
|
|
70
70
|
embeds_many :messages, validate: false
|
|
71
71
|
|
|
72
72
|
embeds_one :passport, autobuild: true, store_as: :pass, validate: false
|
|
73
|
-
embeds_one :purse, store_as: "Purse"
|
|
74
73
|
embeds_one :pet, class_name: "Animal", validate: false
|
|
75
74
|
embeds_one :name, as: :namable, validate: false do
|
|
76
75
|
def extension
|
data.tar.gz.sig
ADDED
|
Binary file
|