mongoid 7.6.2 → 8.0.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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +2 -0
- data/README.md +3 -3
- data/Rakefile +21 -85
- data/lib/config/locales/en.yml +46 -56
- data/lib/mongoid/association/accessors.rb +32 -3
- data/lib/mongoid/association/bindable.rb +48 -0
- data/lib/mongoid/association/builders.rb +4 -2
- data/lib/mongoid/association/depending.rb +4 -8
- data/lib/mongoid/association/eager_loadable.rb +29 -7
- data/lib/mongoid/association/embedded/batchable.rb +28 -5
- data/lib/mongoid/association/embedded/embedded_in/binding.rb +24 -2
- data/lib/mongoid/association/embedded/embedded_in.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_many/binding.rb +1 -0
- data/lib/mongoid/association/embedded/embeds_many/buildable.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +40 -18
- data/lib/mongoid/association/embedded/embeds_one/buildable.rb +18 -4
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +21 -2
- data/lib/mongoid/association/macros.rb +2 -1
- data/lib/mongoid/association/many.rb +5 -0
- data/lib/mongoid/association/nested/many.rb +5 -39
- data/lib/mongoid/association/nested/nested_buildable.rb +0 -14
- data/lib/mongoid/association/proxy.rb +12 -0
- data/lib/mongoid/association/referenced/auto_save.rb +3 -2
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +1 -0
- data/lib/mongoid/association/referenced/belongs_to/buildable.rb +1 -1
- data/lib/mongoid/association/referenced/belongs_to.rb +1 -1
- data/lib/mongoid/association/referenced/counter_cache.rb +8 -8
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +64 -11
- data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +4 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +10 -18
- data/lib/mongoid/association/referenced/has_many/proxy.rb +11 -107
- data/lib/mongoid/association/referenced/has_one/buildable.rb +1 -1
- data/lib/mongoid/association/referenced/has_one/proxy.rb +8 -11
- data/lib/mongoid/association/referenced/syncable.rb +2 -2
- data/lib/mongoid/association/relatable.rb +38 -4
- data/lib/mongoid/attributes/processing.rb +9 -2
- data/lib/mongoid/attributes.rb +30 -27
- data/lib/mongoid/cacheable.rb +2 -2
- data/lib/mongoid/changeable.rb +37 -2
- data/lib/mongoid/clients/factory.rb +0 -4
- data/lib/mongoid/clients/options.rb +4 -0
- data/lib/mongoid/clients/sessions.rb +2 -14
- data/lib/mongoid/config.rb +15 -73
- data/lib/mongoid/contextual/aggregable/memory.rb +22 -20
- data/lib/mongoid/contextual/aggregable/mongo.rb +1 -1
- data/lib/mongoid/contextual/map_reduce.rb +2 -2
- data/lib/mongoid/contextual/memory.rb +63 -47
- data/lib/mongoid/contextual/mongo.rb +173 -287
- data/lib/mongoid/contextual/none.rb +33 -15
- data/lib/mongoid/copyable.rb +32 -8
- data/lib/mongoid/criteria/includable.rb +24 -20
- data/lib/mongoid/criteria/marshalable.rb +10 -2
- data/lib/mongoid/criteria/queryable/extensions/array.rb +2 -15
- data/lib/mongoid/criteria/queryable/extensions/big_decimal.rb +25 -4
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/date.rb +6 -1
- data/lib/mongoid/criteria/queryable/extensions/date_time.rb +6 -1
- data/lib/mongoid/criteria/queryable/extensions/hash.rb +0 -16
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/object.rb +2 -1
- data/lib/mongoid/criteria/queryable/extensions/range.rb +13 -5
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/symbol.rb +3 -1
- data/lib/mongoid/criteria/queryable/extensions/time.rb +6 -1
- data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +6 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +0 -12
- data/lib/mongoid/criteria/queryable/optional.rb +3 -9
- data/lib/mongoid/criteria/queryable/options.rb +1 -1
- data/lib/mongoid/criteria/queryable/selectable.rb +2 -133
- data/lib/mongoid/criteria/queryable/selector.rb +90 -5
- data/lib/mongoid/criteria/queryable/smash.rb +39 -6
- data/lib/mongoid/criteria/queryable/storable.rb +1 -1
- data/lib/mongoid/criteria/queryable.rb +11 -6
- data/lib/mongoid/criteria.rb +1 -28
- data/lib/mongoid/deprecable.rb +36 -0
- data/lib/mongoid/deprecation.rb +25 -0
- data/lib/mongoid/document.rb +88 -33
- data/lib/mongoid/equality.rb +4 -4
- data/lib/mongoid/errors/document_not_found.rb +6 -2
- data/lib/mongoid/errors/invalid_dot_dollar_assignment.rb +23 -0
- data/lib/mongoid/errors/invalid_field.rb +5 -1
- data/lib/mongoid/errors/invalid_field_type.rb +26 -0
- data/lib/mongoid/errors/too_many_nested_attribute_records.rb +1 -1
- data/lib/mongoid/errors.rb +2 -3
- data/lib/mongoid/extensions/array.rb +8 -6
- data/lib/mongoid/extensions/big_decimal.rb +29 -10
- data/lib/mongoid/extensions/binary.rb +42 -0
- data/lib/mongoid/extensions/boolean.rb +8 -2
- data/lib/mongoid/extensions/date.rb +26 -20
- data/lib/mongoid/extensions/date_time.rb +1 -1
- data/lib/mongoid/extensions/float.rb +4 -5
- data/lib/mongoid/extensions/hash.rb +13 -32
- data/lib/mongoid/extensions/integer.rb +4 -5
- data/lib/mongoid/extensions/object.rb +2 -0
- data/lib/mongoid/extensions/range.rb +41 -10
- data/lib/mongoid/extensions/regexp.rb +11 -4
- data/lib/mongoid/extensions/set.rb +11 -4
- data/lib/mongoid/extensions/string.rb +2 -13
- data/lib/mongoid/extensions/symbol.rb +3 -14
- data/lib/mongoid/extensions/time.rb +27 -16
- data/lib/mongoid/extensions/time_with_zone.rb +1 -2
- data/lib/mongoid/extensions.rb +1 -0
- data/lib/mongoid/factory.rb +42 -7
- data/lib/mongoid/fields/foreign_key.rb +7 -0
- data/lib/mongoid/fields/validators/macro.rb +3 -9
- data/lib/mongoid/fields.rb +49 -7
- data/lib/mongoid/findable.rb +21 -16
- data/lib/mongoid/indexable/specification.rb +1 -1
- data/lib/mongoid/indexable/validators/options.rb +4 -1
- data/lib/mongoid/interceptable.rb +69 -9
- data/lib/mongoid/matchable.rb +1 -6
- data/lib/mongoid/matcher/eq_impl_with_regexp.rb +5 -3
- data/lib/mongoid/matcher/regex.rb +9 -8
- data/lib/mongoid/matcher.rb +0 -1
- data/lib/mongoid/persistable/creatable.rb +14 -5
- data/lib/mongoid/persistable/updatable.rb +12 -5
- data/lib/mongoid/persistence_context.rb +8 -42
- data/lib/mongoid/query_cache.rb +6 -258
- data/lib/mongoid/railties/controller_runtime.rb +1 -1
- data/lib/mongoid/reloadable.rb +7 -3
- data/lib/mongoid/scopable.rb +9 -11
- data/lib/mongoid/selectable.rb +1 -2
- data/lib/mongoid/shardable.rb +11 -35
- data/lib/mongoid/stateful.rb +27 -1
- data/lib/mongoid/threaded.rb +0 -3
- data/lib/mongoid/timestamps/created.rb +1 -1
- data/lib/mongoid/timestamps/updated.rb +1 -1
- data/lib/mongoid/touchable.rb +2 -3
- data/lib/mongoid/traversable.rb +1 -0
- data/lib/mongoid/validatable/uniqueness.rb +2 -1
- data/lib/mongoid/version.rb +1 -5
- data/lib/mongoid/warnings.rb +3 -5
- data/lib/mongoid.rb +1 -0
- data/spec/config/mongoid.yml +16 -0
- data/spec/integration/app_spec.rb +8 -20
- data/spec/integration/associations/belongs_to_spec.rb +18 -0
- data/spec/integration/associations/embedded_spec.rb +15 -0
- data/spec/integration/associations/embeds_many_spec.rb +15 -2
- data/spec/integration/associations/embeds_one_spec.rb +18 -0
- data/spec/integration/associations/foreign_key_spec.rb +9 -0
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +21 -0
- data/spec/integration/associations/has_one_spec.rb +97 -1
- data/spec/integration/associations/scope_option_spec.rb +1 -1
- data/spec/integration/callbacks_models.rb +95 -1
- data/spec/integration/callbacks_spec.rb +226 -4
- data/spec/integration/criteria/range_spec.rb +95 -1
- data/spec/integration/discriminator_key_spec.rb +115 -76
- data/spec/integration/dots_and_dollars_spec.rb +277 -0
- data/spec/integration/i18n_fallbacks_spec.rb +1 -15
- data/spec/integration/matcher_examples_spec.rb +20 -13
- data/spec/integration/matcher_operator_data/regex.yml +0 -21
- data/spec/integration/matcher_operator_data/type_decimal.yml +3 -2
- data/spec/integration/matcher_operator_spec.rb +3 -5
- data/spec/integration/persistence/range_field_spec.rb +350 -0
- data/spec/mongoid/association/counter_cache_spec.rb +1 -1
- data/spec/mongoid/association/depending_spec.rb +9 -9
- data/spec/mongoid/association/eager_spec.rb +2 -1
- data/spec/mongoid/association/embedded/embedded_in/binding_spec.rb +2 -1
- data/spec/mongoid/association/embedded/embedded_in/buildable_spec.rb +54 -0
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +69 -9
- data/spec/mongoid/association/embedded/embeds_many/buildable_spec.rb +112 -0
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +198 -8
- data/spec/mongoid/association/embedded/embeds_many_models.rb +36 -0
- data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +12 -0
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +68 -0
- data/spec/mongoid/association/embedded/embeds_one/buildable_spec.rb +25 -0
- data/spec/mongoid/association/embedded/embeds_one_models.rb +19 -0
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +28 -0
- data/spec/mongoid/association/referenced/belongs_to/binding_spec.rb +2 -1
- data/spec/mongoid/association/referenced/belongs_to/buildable_spec.rb +54 -0
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +15 -0
- data/spec/mongoid/association/referenced/belongs_to_models.rb +11 -0
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2 -2
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +36 -51
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_models.rb +25 -0
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb +35 -2
- data/spec/mongoid/association/referenced/has_many/buildable_spec.rb +109 -0
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +2 -56
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +60 -156
- data/spec/mongoid/association/referenced/has_many_models.rb +3 -1
- data/spec/mongoid/association/referenced/has_many_spec.rb +25 -0
- data/spec/mongoid/association/referenced/has_one/buildable_spec.rb +2 -2
- data/spec/mongoid/association/referenced/has_one/proxy_spec.rb +107 -1
- data/spec/mongoid/association/referenced/has_one_models.rb +16 -0
- data/spec/mongoid/association/syncable_spec.rb +14 -0
- data/spec/mongoid/atomic/paths_spec.rb +0 -14
- data/spec/mongoid/attributes/nested_spec.rb +73 -198
- data/spec/mongoid/attributes/nested_spec_models.rb +48 -0
- data/spec/mongoid/attributes/projector_spec.rb +1 -5
- data/spec/mongoid/attributes_spec.rb +480 -27
- data/spec/mongoid/cacheable_spec.rb +3 -3
- data/spec/mongoid/changeable_spec.rb +130 -13
- data/spec/mongoid/clients/factory_spec.rb +22 -60
- data/spec/mongoid/clients/sessions_spec.rb +0 -38
- data/spec/mongoid/clients_spec.rb +2 -2
- data/spec/mongoid/config_spec.rb +52 -15
- data/spec/mongoid/contextual/aggregable/memory_spec.rb +371 -231
- data/spec/mongoid/contextual/aggregable/memory_table.yml +88 -0
- data/spec/mongoid/contextual/aggregable/memory_table_spec.rb +62 -0
- data/spec/mongoid/contextual/map_reduce_spec.rb +2 -16
- data/spec/mongoid/contextual/memory_spec.rb +467 -156
- data/spec/mongoid/contextual/mongo_spec.rb +566 -426
- data/spec/mongoid/contextual/none_spec.rb +11 -19
- data/spec/mongoid/copyable_spec.rb +451 -2
- data/spec/mongoid/criteria/findable_spec.rb +86 -210
- data/spec/mongoid/criteria/includable_spec.rb +1492 -0
- data/spec/mongoid/criteria/includable_spec_models.rb +54 -0
- data/spec/mongoid/criteria/marshalable_spec.rb +18 -1
- data/spec/mongoid/criteria/queryable/extensions/array_spec.rb +7 -19
- data/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb +134 -26
- data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +1 -2
- data/spec/mongoid/criteria/queryable/extensions/date_spec.rb +11 -0
- data/spec/mongoid/criteria/queryable/extensions/date_time_spec.rb +11 -0
- data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +1 -2
- data/spec/mongoid/criteria/queryable/extensions/hash_spec.rb +0 -15
- data/spec/mongoid/criteria/queryable/extensions/numeric_spec.rb +73 -7
- data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +11 -0
- data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +11 -0
- data/spec/mongoid/criteria/queryable/optional_spec.rb +0 -484
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +50 -2
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +77 -85
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +0 -200
- data/spec/mongoid/criteria/queryable/selector_spec.rb +16 -77
- data/spec/mongoid/criteria/queryable/storable_spec.rb +0 -72
- data/spec/mongoid/criteria_spec.rb +469 -1203
- data/spec/mongoid/document_fields_spec.rb +173 -24
- data/spec/mongoid/document_spec.rb +32 -41
- data/spec/mongoid/equality_spec.rb +12 -12
- data/spec/mongoid/errors/document_not_found_spec.rb +29 -2
- data/spec/mongoid/errors/invalid_field_spec.rb +1 -1
- data/spec/mongoid/errors/invalid_field_type_spec.rb +55 -0
- data/spec/mongoid/errors/mongoid_error_spec.rb +3 -1
- data/spec/mongoid/errors/no_environment_spec.rb +3 -3
- data/spec/mongoid/errors/too_many_nested_attribute_records_spec.rb +1 -1
- data/spec/mongoid/extensions/array_spec.rb +16 -2
- data/spec/mongoid/extensions/big_decimal_spec.rb +697 -212
- data/spec/mongoid/extensions/binary_spec.rb +44 -9
- data/spec/mongoid/extensions/boolean_spec.rb +68 -82
- data/spec/mongoid/extensions/date_class_mongoize_spec.rb +7 -3
- data/spec/mongoid/extensions/date_spec.rb +71 -1
- data/spec/mongoid/extensions/date_time_spec.rb +15 -9
- data/spec/mongoid/extensions/float_spec.rb +48 -76
- data/spec/mongoid/extensions/hash_spec.rb +30 -236
- data/spec/mongoid/extensions/integer_spec.rb +45 -66
- data/spec/mongoid/extensions/range_spec.rb +255 -54
- data/spec/mongoid/extensions/regexp_spec.rb +58 -33
- data/spec/mongoid/extensions/set_spec.rb +106 -0
- data/spec/mongoid/extensions/string_spec.rb +53 -25
- data/spec/mongoid/extensions/symbol_spec.rb +18 -25
- data/spec/mongoid/extensions/time_spec.rb +634 -66
- data/spec/mongoid/extensions/time_with_zone_spec.rb +17 -31
- data/spec/mongoid/factory_spec.rb +61 -1
- data/spec/mongoid/fields_spec.rb +321 -50
- data/spec/mongoid/findable_spec.rb +64 -29
- data/spec/mongoid/indexable/specification_spec.rb +2 -2
- data/spec/mongoid/indexable_spec.rb +16 -19
- data/spec/mongoid/interceptable_spec.rb +584 -5
- data/spec/mongoid/interceptable_spec_models.rb +235 -4
- data/spec/mongoid/matcher/extract_attribute_spec.rb +1 -5
- data/spec/mongoid/mongoizable_spec.rb +285 -0
- data/spec/mongoid/persistable/creatable_spec.rb +2 -2
- data/spec/mongoid/persistable/deletable_spec.rb +2 -2
- data/spec/mongoid/persistable/destroyable_spec.rb +2 -2
- data/spec/mongoid/persistable/upsertable_spec.rb +14 -0
- data/spec/mongoid/persistence_context_spec.rb +24 -0
- data/spec/mongoid/query_cache_middleware_spec.rb +0 -18
- data/spec/mongoid/query_cache_spec.rb +1 -156
- data/spec/mongoid/reloadable_spec.rb +35 -2
- data/spec/mongoid/scopable_spec.rb +36 -34
- data/spec/mongoid/serializable_spec.rb +14 -7
- data/spec/mongoid/shardable_models.rb +0 -14
- data/spec/mongoid/shardable_spec.rb +61 -153
- data/spec/mongoid/stateful_spec.rb +28 -0
- data/spec/mongoid/timestamps_spec.rb +390 -0
- data/spec/mongoid/timestamps_spec_models.rb +67 -0
- data/spec/mongoid/touchable_spec.rb +116 -0
- data/spec/mongoid/touchable_spec_models.rb +12 -8
- data/spec/mongoid/traversable_spec.rb +4 -11
- data/spec/mongoid/validatable/presence_spec.rb +1 -1
- data/spec/mongoid/validatable/uniqueness_spec.rb +60 -31
- data/spec/mongoid/warnings_spec.rb +35 -0
- data/spec/mongoid_spec.rb +1 -7
- data/spec/rails/controller_extension/controller_runtime_spec.rb +2 -2
- data/spec/rails/mongoid_spec.rb +4 -16
- data/spec/shared/lib/mrss/cluster_config.rb +40 -5
- data/spec/shared/lib/mrss/constraints.rb +46 -7
- data/spec/shared/lib/mrss/docker_runner.rb +21 -17
- data/spec/shared/lib/mrss/eg_config_utils.rb +31 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +5 -15
- data/spec/shared/lib/mrss/lite_constraints.rb +2 -10
- data/spec/shared/lib/mrss/server_version_registry.rb +29 -18
- data/spec/shared/lib/mrss/spec_organizer.rb +3 -32
- data/spec/shared/lib/mrss/utils.rb +6 -28
- data/spec/shared/share/Dockerfile.erb +114 -38
- data/spec/shared/shlib/distro.sh +0 -10
- data/spec/shared/shlib/server.sh +83 -64
- data/spec/shared/shlib/set_env.sh +81 -16
- data/spec/support/constraints.rb +24 -0
- data/spec/support/expectations.rb +17 -20
- data/spec/support/macros.rb +30 -0
- data/spec/support/models/augmentation.rb +12 -0
- data/spec/support/models/band.rb +3 -0
- data/spec/support/models/catalog.rb +24 -0
- data/spec/support/models/circus.rb +3 -0
- data/spec/support/models/fanatic.rb +8 -0
- data/spec/support/models/implant.rb +9 -0
- data/spec/support/models/label.rb +2 -0
- data/spec/support/models/passport.rb +9 -0
- data/spec/support/models/person.rb +1 -0
- data/spec/support/models/player.rb +2 -0
- data/spec/support/models/powerup.rb +12 -0
- data/spec/support/models/registry.rb +1 -0
- data/spec/support/models/school.rb +14 -0
- data/spec/support/models/shield.rb +18 -0
- data/spec/support/models/student.rb +14 -0
- data/spec/support/models/weapon.rb +12 -0
- data.tar.gz.sig +0 -0
- metadata +695 -650
- metadata.gz.sig +0 -0
- data/lib/mongoid/errors/eager_load.rb +0 -23
- data/lib/mongoid/errors/in_memory_regexp_timeout.rb +0 -26
- data/lib/mongoid/errors/invalid_value.rb +0 -17
- data/lib/mongoid/field_readable.rb +0 -70
- data/lib/mongoid/matcher/regexp_budget.rb +0 -389
- data/spec/integration/matcher_regexp_timeout_spec.rb +0 -215
- data/spec/integration/query_operator_guard_spec.rb +0 -89
- data/spec/mongoid/errors/eager_load_spec.rb +0 -31
- data/spec/mongoid/matcher/regexp_budget_spec.rb +0 -570
- data/spec/shared/CANDIDATE.md +0 -28
- data/spec/shared/lib/mrss/release/candidate.rb +0 -287
- data/spec/shared/lib/mrss/release/product_data.rb +0 -144
- data/spec/shared/lib/tasks/candidate.rake +0 -64
data/spec/shared/shlib/server.sh
CHANGED
|
@@ -35,50 +35,48 @@ 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
|
}
|
|
69
73
|
|
|
70
|
-
|
|
74
|
+
install_mlaunch_virtualenv() {
|
|
71
75
|
python3 -V || true
|
|
72
|
-
if ! python3 -m
|
|
76
|
+
if ! python3 -m virtualenv -h >/dev/null; then
|
|
73
77
|
# Current virtualenv fails with
|
|
74
78
|
# https://github.com/pypa/virtualenv/issues/1630
|
|
75
|
-
python3 -m pip install
|
|
76
|
-
fi
|
|
77
|
-
if ! python3 -m ensurepip -h > /dev/null; then
|
|
78
|
-
# Debian11/Ubuntu2204 have venv installed, but it is nonfunctional unless
|
|
79
|
-
# the python3-venv package is also installed (it lacks the ensurepip
|
|
80
|
-
# module).
|
|
81
|
-
sudo apt-get update && sudo apt-get install --yes python3-venv
|
|
79
|
+
python3 -m pip install 'virtualenv<20' --user
|
|
82
80
|
fi
|
|
83
81
|
if test "$USE_SYSTEM_PYTHON_PACKAGES" = 1 &&
|
|
84
82
|
python3 -m pip list |grep mtools
|
|
@@ -86,21 +84,15 @@ install_mlaunch_venv() {
|
|
|
86
84
|
# Use the existing mtools-legacy
|
|
87
85
|
:
|
|
88
86
|
else
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
|
93
|
-
python3 -m venv $venvpath
|
|
94
|
-
. $venvpath/bin/activate
|
|
95
|
-
fi
|
|
96
|
-
|
|
87
|
+
venvpath="$MONGO_ORCHESTRATION_HOME"/venv
|
|
88
|
+
python3 -m virtualenv -p python3 $venvpath
|
|
89
|
+
. $venvpath/bin/activate
|
|
97
90
|
# [mlaunch] does not work:
|
|
98
91
|
# https://github.com/rueckstiess/mtools/issues/856
|
|
99
92
|
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
|
100
93
|
#pip install 'mtools==1.7' 'pymongo==4.1' python-dateutil psutil
|
|
101
|
-
|
|
94
|
+
|
|
102
95
|
# dateutil dependency is missing in mtools: https://github.com/rueckstiess/mtools/issues/864
|
|
103
|
-
pip install --upgrade setuptools
|
|
104
96
|
pip install 'mtools-legacy[mlaunch]' 'pymongo<4' python-dateutil
|
|
105
97
|
fi
|
|
106
98
|
}
|
|
@@ -166,32 +158,6 @@ install_mlaunch_git() {
|
|
|
166
158
|
fi
|
|
167
159
|
}
|
|
168
160
|
|
|
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
|
-
install_cmake() {
|
|
183
|
-
if ! command -v cmake &> /dev/null; then
|
|
184
|
-
if ! command -v apt-get &> /dev/null; then
|
|
185
|
-
# no apt-get; assume RHEL
|
|
186
|
-
sudo yum -y install cmake libarchive
|
|
187
|
-
else
|
|
188
|
-
sudo apt-get update && sudo apt-get install --yes cmake
|
|
189
|
-
fi
|
|
190
|
-
else
|
|
191
|
-
echo 'cmake is present'
|
|
192
|
-
fi
|
|
193
|
-
}
|
|
194
|
-
|
|
195
161
|
# This function sets followong global variables:
|
|
196
162
|
# server_cert_path
|
|
197
163
|
# server_ca_path
|
|
@@ -207,7 +173,7 @@ calculate_server_args() {
|
|
|
207
173
|
fi
|
|
208
174
|
|
|
209
175
|
if test $mongo_version = latest; then
|
|
210
|
-
mongo_version=
|
|
176
|
+
mongo_version=60
|
|
211
177
|
fi
|
|
212
178
|
|
|
213
179
|
local args="--setParameter enableTestCommands=1"
|
|
@@ -218,14 +184,17 @@ calculate_server_args() {
|
|
|
218
184
|
args="$args --setParameter acceptAPIVersion2=1"
|
|
219
185
|
fi
|
|
220
186
|
|
|
221
|
-
|
|
222
|
-
|
|
187
|
+
# diagnosticDataCollectionEnabled is a mongod-only parameter on server 3.2,
|
|
188
|
+
# and mlaunch does not support specifying mongod-only parameters:
|
|
189
|
+
# https://github.com/rueckstiess/mtools/issues/696
|
|
190
|
+
# Pass it to 3.4 and newer servers where it is accepted by all daemons.
|
|
191
|
+
if test $mongo_version -ge 34; then
|
|
192
|
+
args="$args --setParameter diagnosticDataCollectionEnabled=false"
|
|
193
|
+
fi
|
|
223
194
|
local uri_options=
|
|
224
195
|
if test "$TOPOLOGY" = replica-set; then
|
|
225
196
|
args="$args --replicaset --name test-rs --nodes 2 --arbiter"
|
|
226
197
|
export HAVE_ARBITER=1
|
|
227
|
-
elif test "$TOPOLOGY" = replica-set-single-node; then
|
|
228
|
-
args="$args --replicaset --name test-rs --nodes 1"
|
|
229
198
|
elif test "$TOPOLOGY" = sharded-cluster; then
|
|
230
199
|
args="$args --replicaset --nodes 2 --sharded 1 --name test-rs"
|
|
231
200
|
if test -z "$SINGLE_MONGOS"; then
|
|
@@ -250,6 +219,10 @@ calculate_server_args() {
|
|
|
250
219
|
echo "Unknown topology: $TOPOLOGY" 1>&2
|
|
251
220
|
exit 1
|
|
252
221
|
fi
|
|
222
|
+
if test -n "$MMAPV1"; then
|
|
223
|
+
args="$args --storageEngine mmapv1 --smallfiles --noprealloc"
|
|
224
|
+
uri_options="$uri_options&retryReads=false&retryWrites=false"
|
|
225
|
+
fi
|
|
253
226
|
if test "$AUTH" = auth; then
|
|
254
227
|
args="$args --auth --username bob --password pwd123"
|
|
255
228
|
elif test "$AUTH" = x509; then
|
|
@@ -312,6 +285,7 @@ calculate_server_args() {
|
|
|
312
285
|
args="$args --bind_ip_all"
|
|
313
286
|
fi
|
|
314
287
|
|
|
288
|
+
# MongoDB servers pre-4.2 do not enable zlib compression by default
|
|
315
289
|
if test "$COMPRESSOR" = snappy; then
|
|
316
290
|
args="$args --networkMessageCompressors snappy"
|
|
317
291
|
elif test "$COMPRESSOR" = zlib; then
|
|
@@ -362,6 +336,51 @@ launch_server() {
|
|
|
362
336
|
local dbdir="$1"
|
|
363
337
|
python3 -m mtools.mlaunch.mlaunch --dir "$dbdir" --binarypath "$BINDIR" $SERVER_ARGS
|
|
364
338
|
|
|
339
|
+
if test "$TOPOLOGY" = sharded-cluster && test $MONGODB_VERSION = 3.6; then
|
|
340
|
+
# On 3.6 server the sessions collection is not immediately available,
|
|
341
|
+
# so we run the refreshLogicalSessionCacheNow command on the config server
|
|
342
|
+
# and again on each mongos in order for the mongoses
|
|
343
|
+
# to correctly report logicalSessionTimeoutMinutes.
|
|
344
|
+
mongos_regex="\s*mongos\s+([0-9]+)\s+running\s+[0-9]+"
|
|
345
|
+
config_server_regex="\s*config\sserver\s+([0-9]+)\s+running\s+[0-9]+"
|
|
346
|
+
config_server=""
|
|
347
|
+
mongoses=()
|
|
348
|
+
if test "$AUTH" = auth
|
|
349
|
+
then
|
|
350
|
+
base_url="mongodb://bob:pwd123@localhost"
|
|
351
|
+
else
|
|
352
|
+
base_url="mongodb://localhost"
|
|
353
|
+
fi
|
|
354
|
+
if test "$SSL" = "ssl"
|
|
355
|
+
then
|
|
356
|
+
mongo_command="${BINDIR}/mongo --ssl --sslPEMKeyFile $server_cert_path --sslCAFile $server_ca_path"
|
|
357
|
+
else
|
|
358
|
+
mongo_command="${BINDIR}/mongo"
|
|
359
|
+
fi
|
|
360
|
+
|
|
361
|
+
while read -r line
|
|
362
|
+
do
|
|
363
|
+
if [[ $line =~ $config_server_regex ]]
|
|
364
|
+
then
|
|
365
|
+
port="${BASH_REMATCH[1]}"
|
|
366
|
+
config_server="${base_url}:${port}"
|
|
367
|
+
fi
|
|
368
|
+
if [[ $line =~ $mongos_regex ]]
|
|
369
|
+
then
|
|
370
|
+
port="${BASH_REMATCH[1]}"
|
|
371
|
+
mongoses+=("${base_url}:${port}")
|
|
372
|
+
fi
|
|
373
|
+
done < <(python2 -m mtools.mlaunch.mlaunch list --dir "$dbdir" --binarypath "$BINDIR")
|
|
374
|
+
|
|
375
|
+
if [ -n "$config_server" ]; then
|
|
376
|
+
${mongo_command} "$config_server" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
|
|
377
|
+
for mongos in ${mongoses[*]}
|
|
378
|
+
do
|
|
379
|
+
${mongo_command} "$mongos" --eval 'db.adminCommand("refreshLogicalSessionCacheNow")'
|
|
380
|
+
done
|
|
381
|
+
fi
|
|
382
|
+
fi
|
|
383
|
+
|
|
365
384
|
if test "$TOPOLOGY" = load-balanced; then
|
|
366
385
|
if test -z "$haproxy_config"; then
|
|
367
386
|
echo haproxy_config should have been set 1>&2
|
|
@@ -1,15 +1,39 @@
|
|
|
1
1
|
# When changing, also update the hash in share/Dockerfile.
|
|
2
|
-
|
|
2
|
+
TOOLCHAIN_VERSION=219833abad4d9d3bf43c0fef101a8ca082ac4ae9
|
|
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
|
|
@@ -29,7 +53,7 @@ set_env_python() {
|
|
|
29
53
|
curl -fL --retry 3 https://github.com/p-mongodb/deps/raw/main/"$arch"-python37.tar.xz | \
|
|
30
54
|
tar xfJ - -C /opt
|
|
31
55
|
fi
|
|
32
|
-
|
|
56
|
+
|
|
33
57
|
if test -d /opt/python/3.7/bin; then
|
|
34
58
|
# Most Evergreen configurations.
|
|
35
59
|
export PATH=/opt/python/3.7/bin:$PATH
|
|
@@ -37,7 +61,7 @@ set_env_python() {
|
|
|
37
61
|
# Configurations that use Docker in Evergreen - these don't preload.
|
|
38
62
|
export PATH=/opt/python37/bin:$PATH
|
|
39
63
|
fi
|
|
40
|
-
|
|
64
|
+
|
|
41
65
|
python3 -V
|
|
42
66
|
fi
|
|
43
67
|
}
|
|
@@ -54,7 +78,7 @@ set_env_node() {
|
|
|
54
78
|
# Node from toolchain in Evergreen
|
|
55
79
|
export PATH=/opt/node/bin:$PATH
|
|
56
80
|
fi
|
|
57
|
-
|
|
81
|
+
|
|
58
82
|
node -v
|
|
59
83
|
}
|
|
60
84
|
|
|
@@ -70,10 +94,16 @@ set_env_ruby() {
|
|
|
70
94
|
set_env_java
|
|
71
95
|
|
|
72
96
|
if [ "$RVM_RUBY" == "ruby-head" ]; then
|
|
73
|
-
# we
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
97
|
+
# When we use ruby-head, we do not install the Ruby toolchain.
|
|
98
|
+
# But we still need Python 3.6+ to run mlaunch.
|
|
99
|
+
# Since the ruby-head tests are run on ubuntu1604, we can use the
|
|
100
|
+
# globally installed Python toolchain.
|
|
101
|
+
#export PATH=/opt/python/3.7/bin:$PATH
|
|
102
|
+
|
|
103
|
+
# 12.04, 14.04 and 16.04 are good
|
|
104
|
+
curl --retry 3 -fL http://rubies.travis-ci.org/ubuntu/`lsb_release -rs`/x86_64/ruby-head.tar.bz2 |tar xfj -
|
|
105
|
+
# TODO adjust gem path?
|
|
106
|
+
export PATH=`pwd`/ruby-head/bin:`pwd`/ruby-head/lib/ruby/gems/2.6.0/bin:$PATH
|
|
77
107
|
ruby --version
|
|
78
108
|
ruby --version |grep dev
|
|
79
109
|
elif test "$SYSTEM_RUBY" = 1; then
|
|
@@ -83,13 +113,34 @@ set_env_ruby() {
|
|
|
83
113
|
if test "$USE_OPT_TOOLCHAIN" = 1; then
|
|
84
114
|
# Nothing, also PATH is already set
|
|
85
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
|
+
|
|
86
129
|
else
|
|
87
|
-
# For testing unpublished builds:
|
|
88
|
-
#build_url=https://s3.amazonaws.com/mciuploads/mongo-ruby-toolchain/library/`host_distro`/$RVM_RUBY.tar.xz
|
|
89
130
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
|
|
93
144
|
fi
|
|
94
145
|
|
|
95
146
|
ruby --version
|
|
@@ -100,5 +151,19 @@ set_env_ruby() {
|
|
|
100
151
|
|
|
101
152
|
ruby -v |fgrep $ruby_name
|
|
102
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
|
|
103
168
|
fi
|
|
104
169
|
}
|
data/spec/support/constraints.rb
CHANGED
|
@@ -27,6 +27,30 @@ module Constraints
|
|
|
27
27
|
Mongo::VERSION.split('.')[0...precision].map(&:to_i)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def min_bson_version(version)
|
|
31
|
+
required_version = version.split('.').map(&:to_i)
|
|
32
|
+
actual_version = bson_version(required_version.length)
|
|
33
|
+
before(:all) do
|
|
34
|
+
if (actual_version <=> required_version) < 0
|
|
35
|
+
skip "bson-ruby version #{version} or higher is required"
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def max_bson_version(version)
|
|
41
|
+
required_version = version.split('.').map(&:to_i)
|
|
42
|
+
actual_version = bson_version(required_version.length)
|
|
43
|
+
before(:all) do
|
|
44
|
+
if (actual_version <=> required_version) > 0
|
|
45
|
+
skip "bson-ruby version #{version} or lower is required"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def bson_version(precision)
|
|
51
|
+
BSON::VERSION.split('.')[0...precision].map(&:to_i)
|
|
52
|
+
end
|
|
53
|
+
|
|
30
54
|
def min_rails_version(version)
|
|
31
55
|
unless version =~ /\A\d+\.\d+\z/
|
|
32
56
|
raise ArgumentError, "Version can only be major.minor: #{version}"
|
|
@@ -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)
|
data/spec/support/macros.rb
CHANGED
|
@@ -39,6 +39,28 @@ module Mongoid
|
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
+
def driver_config_override(key, value)
|
|
43
|
+
around do |example|
|
|
44
|
+
existing = Mongo.send(key)
|
|
45
|
+
|
|
46
|
+
Mongo.send("#{key}=", value)
|
|
47
|
+
|
|
48
|
+
example.run
|
|
49
|
+
|
|
50
|
+
Mongo.send("#{key}=", existing)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def with_driver_config_values(key, *values, &block)
|
|
55
|
+
values.each do |value|
|
|
56
|
+
context "when #{key} is #{value}" do
|
|
57
|
+
driver_config_override key, value
|
|
58
|
+
|
|
59
|
+
class_exec(value, &block)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
42
64
|
def restore_config_clients
|
|
43
65
|
around do |example|
|
|
44
66
|
# Duplicate the config because some tests mutate it.
|
|
@@ -47,5 +69,13 @@ module Mongoid
|
|
|
47
69
|
Mongoid::Config.send(:clients=, old_config)
|
|
48
70
|
end
|
|
49
71
|
end
|
|
72
|
+
|
|
73
|
+
def query_cache_enabled
|
|
74
|
+
around do |example|
|
|
75
|
+
Mongoid::QueryCache.cache do
|
|
76
|
+
example.run
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
50
80
|
end
|
|
51
81
|
end
|
|
@@ -10,4 +10,16 @@ class Augmentation
|
|
|
10
10
|
after_build do
|
|
11
11
|
self.name = "Infolink (#{player.frags})"
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
field :after_find_player
|
|
15
|
+
field :after_initialize_player
|
|
16
|
+
field :after_default_player, default: ->{ self.player&._id }
|
|
17
|
+
|
|
18
|
+
after_find do |doc|
|
|
19
|
+
doc.after_find_player = player&._id
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
after_initialize do |doc|
|
|
23
|
+
doc.after_initialize_player = player&._id
|
|
24
|
+
end
|
|
13
25
|
end
|
data/spec/support/models/band.rb
CHANGED
|
@@ -20,10 +20,13 @@ class Band
|
|
|
20
20
|
field :y, as: :years, type: Integer
|
|
21
21
|
field :founded, type: Date
|
|
22
22
|
field :deleted, type: Boolean
|
|
23
|
+
field :mojo, type: Object
|
|
24
|
+
field :fans
|
|
23
25
|
|
|
24
26
|
embeds_many :records, cascade_callbacks: true
|
|
25
27
|
embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
|
|
26
28
|
embeds_many :labels
|
|
29
|
+
embeds_many :fanatics
|
|
27
30
|
embeds_one :label, cascade_callbacks: true
|
|
28
31
|
|
|
29
32
|
scope :highly_rated, -> { gte(rating: 7) }
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Catalog
|
|
4
|
+
include Mongoid::Document
|
|
5
|
+
|
|
6
|
+
field :array_field, type: Array
|
|
7
|
+
field :big_decimal_field, type: BigDecimal
|
|
8
|
+
field :boolean_field, type: Boolean
|
|
9
|
+
field :date_field, type: Date
|
|
10
|
+
field :date_time_field, type: DateTime
|
|
11
|
+
field :float_field, type: Float
|
|
12
|
+
field :hash_field, type: Hash
|
|
13
|
+
field :integer_field, type: Integer
|
|
14
|
+
field :object_id_field, type: BSON::ObjectId
|
|
15
|
+
field :binary_field, type: BSON::Binary
|
|
16
|
+
field :range_field, type: Range
|
|
17
|
+
field :regexp_field, type: Regexp
|
|
18
|
+
field :set_field, type: Set
|
|
19
|
+
field :string_field, type: String
|
|
20
|
+
field :stringified_symbol_field, type: StringifiedSymbol
|
|
21
|
+
field :symbol_field, type: Symbol
|
|
22
|
+
field :time_field, type: Time
|
|
23
|
+
field :time_with_zone_field, type: ActiveSupport::TimeWithZone
|
|
24
|
+
end
|
|
@@ -12,7 +12,16 @@ class Implant
|
|
|
12
12
|
doc.name = "Cochlear Implant (#{player.frags})"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
field :after_find_player
|
|
16
|
+
field :after_initialize_player
|
|
17
|
+
field :after_default_player, default: ->{ self.player&._id }
|
|
18
|
+
|
|
15
19
|
after_find do |doc|
|
|
16
20
|
doc.impressions += 1
|
|
21
|
+
doc.after_find_player = player&._id
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
after_initialize do |doc|
|
|
25
|
+
doc.after_initialize_player = player&._id
|
|
17
26
|
end
|
|
18
27
|
end
|
|
@@ -6,6 +6,8 @@ class Label
|
|
|
6
6
|
|
|
7
7
|
field :name, type: String
|
|
8
8
|
field :sales, type: BigDecimal
|
|
9
|
+
field :age, type: Integer
|
|
10
|
+
|
|
9
11
|
field :after_create_called, type: Mongoid::Boolean, default: false
|
|
10
12
|
field :after_save_called, type: Mongoid::Boolean, default: false
|
|
11
13
|
field :after_update_called, type: Mongoid::Boolean, default: false
|
|
@@ -10,4 +10,13 @@ class Passport
|
|
|
10
10
|
field :localized_translations, localize: true
|
|
11
11
|
|
|
12
12
|
embedded_in :person, autobuild: true
|
|
13
|
+
|
|
14
|
+
embeds_many :passport_pages
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class PassportPage
|
|
18
|
+
include Mongoid::Document
|
|
19
|
+
|
|
20
|
+
field :num_stamps, type: Integer
|
|
21
|
+
embedded_in :passport
|
|
13
22
|
end
|
|
@@ -10,4 +10,16 @@ class Powerup
|
|
|
10
10
|
after_build do
|
|
11
11
|
self.name = "Quad Damage (#{player.frags})"
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
field :after_find_player
|
|
15
|
+
field :after_initialize_player
|
|
16
|
+
field :after_default_player, default: ->{ self.player&._id }
|
|
17
|
+
|
|
18
|
+
after_find do |doc|
|
|
19
|
+
doc.after_find_player = player&._id
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
after_initialize do |doc|
|
|
23
|
+
doc.after_initialize_player = player&._id
|
|
24
|
+
end
|
|
13
25
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class School
|
|
4
|
+
include Mongoid::Document
|
|
5
|
+
|
|
6
|
+
has_many :students
|
|
7
|
+
|
|
8
|
+
field :district, type: String
|
|
9
|
+
field :team, type: String
|
|
10
|
+
|
|
11
|
+
field :after_destroy_triggered, default: false
|
|
12
|
+
|
|
13
|
+
accepts_nested_attributes_for :students, allow_destroy: true
|
|
14
|
+
end
|