mongoid 7.2.0.rc1 → 7.3.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.tar.gz.sig +0 -0
- data/Rakefile +45 -10
- data/lib/config/locales/en.yml +2 -2
- data/lib/mongoid/association/accessors.rb +1 -1
- data/lib/mongoid/association/constrainable.rb +1 -1
- data/lib/mongoid/association/depending.rb +4 -4
- data/lib/mongoid/association/embedded/batchable.rb +1 -1
- data/lib/mongoid/association/embedded/embedded_in.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +10 -3
- data/lib/mongoid/association/nested/many.rb +1 -1
- data/lib/mongoid/association/nested/one.rb +4 -2
- data/lib/mongoid/association/proxy.rb +6 -1
- data/lib/mongoid/association/referenced/auto_save.rb +2 -2
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +493 -495
- data/lib/mongoid/association/referenced/has_many/proxy.rb +2 -2
- data/lib/mongoid/association/referenced/has_one/buildable.rb +8 -0
- data/lib/mongoid/association/referenced/has_one/nested_builder.rb +2 -2
- data/lib/mongoid/association/referenced/has_one/proxy.rb +6 -1
- data/lib/mongoid/attributes.rb +32 -14
- data/lib/mongoid/attributes/projector.rb +120 -0
- data/lib/mongoid/cacheable.rb +2 -2
- data/lib/mongoid/clients.rb +1 -1
- data/lib/mongoid/clients/factory.rb +22 -8
- data/lib/mongoid/config.rb +19 -2
- data/lib/mongoid/contextual/aggregable/mongo.rb +10 -8
- data/lib/mongoid/copyable.rb +6 -2
- data/lib/mongoid/criteria.rb +4 -5
- data/lib/mongoid/criteria/findable.rb +1 -1
- data/lib/mongoid/criteria/queryable/expandable.rb +0 -24
- data/lib/mongoid/criteria/queryable/extensions.rb +0 -4
- data/lib/mongoid/criteria/queryable/extensions/boolean.rb +1 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +46 -20
- data/lib/mongoid/criteria/queryable/selectable.rb +8 -8
- data/lib/mongoid/criteria/queryable/selector.rb +0 -4
- data/lib/mongoid/document.rb +4 -17
- data/lib/mongoid/errors/delete_restriction.rb +8 -9
- data/lib/mongoid/evolvable.rb +1 -1
- data/lib/mongoid/extensions.rb +1 -0
- data/lib/mongoid/extensions/boolean.rb +1 -2
- data/lib/mongoid/extensions/false_class.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +2 -2
- data/lib/mongoid/extensions/true_class.rb +1 -1
- data/lib/mongoid/fields.rb +46 -5
- data/lib/mongoid/inspectable.rb +1 -1
- data/lib/mongoid/interceptable.rb +3 -1
- data/lib/mongoid/matcher.rb +26 -43
- data/lib/mongoid/matcher/bits.rb +41 -0
- data/lib/mongoid/matcher/bits_all_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_all_set.rb +20 -0
- data/lib/mongoid/matcher/bits_any_clear.rb +20 -0
- data/lib/mongoid/matcher/bits_any_set.rb +20 -0
- data/lib/mongoid/matcher/elem_match.rb +2 -1
- data/lib/mongoid/matcher/expression.rb +9 -14
- data/lib/mongoid/matcher/field_expression.rb +4 -5
- data/lib/mongoid/matcher/field_operator.rb +13 -11
- data/lib/mongoid/matcher/mod.rb +17 -0
- data/lib/mongoid/matcher/type.rb +99 -0
- data/lib/mongoid/persistable/deletable.rb +1 -2
- data/lib/mongoid/persistable/destroyable.rb +8 -2
- data/lib/mongoid/persistable/updatable.rb +27 -2
- data/lib/mongoid/query_cache.rb +35 -29
- data/lib/mongoid/reloadable.rb +5 -0
- data/lib/mongoid/selectable.rb +5 -7
- data/lib/mongoid/shardable.rb +21 -5
- data/lib/mongoid/stringified_symbol.rb +53 -0
- data/lib/mongoid/touchable.rb +23 -4
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/config_generator.rb +8 -1
- data/spec/README.md +19 -4
- data/spec/integration/app_spec.rb +175 -88
- data/spec/integration/associations/embeds_many_spec.rb +68 -0
- data/spec/integration/associations/embeds_one_spec.rb +24 -0
- data/spec/integration/associations/has_many_spec.rb +60 -0
- data/spec/integration/associations/has_one_spec.rb +108 -0
- data/spec/integration/callbacks_models.rb +49 -0
- data/spec/integration/callbacks_spec.rb +216 -0
- data/spec/integration/criteria/date_field_spec.rb +1 -1
- data/spec/integration/document_spec.rb +30 -0
- data/spec/integration/matcher_operator_data/bits_all_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_all_set.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_clear.yml +159 -0
- data/spec/integration/matcher_operator_data/bits_any_set.yml +159 -0
- data/spec/integration/matcher_operator_data/comment.yml +22 -0
- data/spec/integration/matcher_operator_data/elem_match.yml +46 -0
- data/spec/integration/matcher_operator_data/gt_types.yml +63 -0
- data/spec/integration/matcher_operator_data/gte_types.yml +15 -0
- data/spec/integration/matcher_operator_data/implicit_traversal.yml +96 -0
- data/spec/integration/matcher_operator_data/in.yml +16 -0
- data/spec/integration/matcher_operator_data/lt_types.yml +15 -0
- data/spec/integration/matcher_operator_data/lte_types.yml +15 -0
- data/spec/integration/matcher_operator_data/mod.yml +55 -0
- data/spec/integration/matcher_operator_data/ne_types.yml +15 -0
- data/spec/integration/matcher_operator_data/type.yml +70 -0
- data/spec/integration/matcher_operator_data/type_array.yml +16 -0
- data/spec/integration/matcher_operator_data/type_binary.yml +18 -0
- data/spec/integration/matcher_operator_data/type_boolean.yml +39 -0
- data/spec/integration/matcher_operator_data/type_code.yml +26 -0
- data/spec/integration/matcher_operator_data/type_code_with_scope.yml +26 -0
- data/spec/integration/matcher_operator_data/type_date.yml +39 -0
- data/spec/integration/matcher_operator_data/type_db_pointer.yml +19 -0
- data/spec/integration/matcher_operator_data/type_decimal.yml +40 -0
- data/spec/integration/matcher_operator_data/type_double.yml +15 -0
- data/spec/integration/matcher_operator_data/type_int32.yml +33 -0
- data/spec/integration/matcher_operator_data/type_int64.yml +33 -0
- data/spec/integration/matcher_operator_data/type_max_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_min_key.yml +17 -0
- data/spec/integration/matcher_operator_data/type_null.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object.yml +23 -0
- data/spec/integration/matcher_operator_data/type_object_id.yml +25 -0
- data/spec/integration/matcher_operator_data/type_regex.yml +44 -0
- data/spec/integration/matcher_operator_data/type_string.yml +15 -0
- data/spec/integration/matcher_operator_data/type_symbol.yml +32 -0
- data/spec/integration/matcher_operator_data/type_timestamp.yml +25 -0
- data/spec/integration/matcher_operator_data/type_undefined.yml +17 -0
- data/spec/integration/stringified_symbol_field_spec.rb +190 -0
- data/spec/lite_spec_helper.rb +9 -7
- data/spec/mongoid/association/depending_spec.rb +391 -352
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +50 -0
- data/spec/mongoid/association/nested/one_spec.rb +18 -14
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +25 -8
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/binding_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +1 -1
- data/spec/mongoid/association/referenced/has_many_models.rb +12 -0
- data/spec/mongoid/association/referenced/has_one_models.rb +20 -0
- data/spec/mongoid/association/referenced/has_one_spec.rb +1 -1
- data/spec/mongoid/atomic/paths_spec.rb +105 -12
- data/spec/mongoid/attributes/projector_data/embedded.yml +105 -0
- data/spec/mongoid/attributes/projector_data/fields.yml +93 -0
- data/spec/mongoid/attributes/projector_spec.rb +41 -0
- data/spec/mongoid/attributes_spec.rb +333 -0
- data/spec/mongoid/clients/factory_spec.rb +48 -0
- data/spec/mongoid/config_spec.rb +32 -0
- data/spec/mongoid/contextual/atomic_spec.rb +17 -4
- data/spec/mongoid/contextual/mongo_spec.rb +2 -2
- data/spec/mongoid/copyable_spec.rb +44 -17
- data/spec/mongoid/copyable_spec_models.rb +14 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/expandable_spec.rb +0 -73
- data/spec/mongoid/criteria/queryable/extensions/boolean_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +105 -7
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +265 -24
- data/spec/mongoid/criteria/queryable/selectable_shared_examples.rb +39 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -565
- data/spec/mongoid/criteria/queryable/selectable_where_spec.rb +590 -0
- data/spec/mongoid/criteria_projection_spec.rb +411 -0
- data/spec/mongoid/criteria_spec.rb +0 -275
- data/spec/mongoid/document_fields_spec.rb +26 -0
- data/spec/mongoid/document_spec.rb +13 -13
- data/spec/mongoid/equality_spec.rb +0 -1
- data/spec/mongoid/errors/delete_restriction_spec.rb +1 -1
- data/spec/mongoid/extensions/false_class_spec.rb +1 -1
- data/spec/mongoid/extensions/string_spec.rb +5 -5
- data/spec/mongoid/extensions/stringified_symbol_spec.rb +85 -0
- data/spec/mongoid/extensions/true_class_spec.rb +1 -1
- data/spec/mongoid/fields/localized_spec.rb +4 -4
- data/spec/mongoid/fields_spec.rb +4 -4
- data/spec/mongoid/inspectable_spec.rb +12 -4
- data/spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml +104 -0
- data/spec/mongoid/matcher/extract_attribute_data/traversal.yml +68 -88
- data/spec/mongoid/matcher/extract_attribute_spec.rb +3 -13
- data/spec/mongoid/persistable/deletable_spec.rb +175 -1
- data/spec/mongoid/persistable/destroyable_spec.rb +191 -3
- data/spec/mongoid/persistable/savable_spec.rb +3 -5
- data/spec/mongoid/persistable/settable_spec.rb +30 -0
- data/spec/mongoid/persistable/upsertable_spec.rb +1 -1
- data/spec/mongoid/query_cache_middleware_spec.rb +8 -0
- data/spec/mongoid/reloadable_spec.rb +18 -1
- data/spec/mongoid/shardable_spec.rb +44 -0
- data/spec/mongoid/touchable_spec.rb +104 -16
- data/spec/mongoid/touchable_spec_models.rb +52 -0
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +221 -0
- data/spec/shared/lib/mrss/constraints.rb +354 -0
- data/spec/shared/lib/mrss/docker_runner.rb +265 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +162 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +231 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +290 -0
- data/spec/shared/shlib/set_env.sh +128 -0
- data/spec/spec_helper.rb +7 -1
- data/spec/support/client_registry.rb +9 -0
- data/spec/support/constraints.rb +0 -226
- data/spec/support/models/bolt.rb +8 -0
- data/spec/support/models/customer.rb +11 -0
- data/spec/support/models/customer_address.rb +12 -0
- data/spec/support/models/dictionary.rb +6 -0
- data/spec/support/models/hole.rb +13 -0
- data/spec/support/models/mop.rb +9 -0
- data/spec/support/models/nut.rb +8 -0
- data/spec/support/models/order.rb +11 -0
- data/spec/support/models/person.rb +8 -0
- data/spec/support/models/sealer.rb +8 -0
- data/spec/support/models/series.rb +1 -0
- data/spec/support/models/shirt.rb +12 -0
- data/spec/support/models/spacer.rb +8 -0
- data/spec/support/models/threadlocker.rb +8 -0
- data/spec/support/models/washer.rb +8 -0
- data/spec/support/models/wiki_page.rb +1 -0
- data/spec/support/spec_config.rb +8 -0
- metadata +655 -507
- metadata.gz.sig +0 -0
- data/spec/support/child_process_helper.rb +0 -79
- data/spec/support/cluster_config.rb +0 -158
- data/spec/support/lite_constraints.rb +0 -22
- data/spec/support/spec_organizer.rb +0 -130
data/spec/spec_helper.rb
CHANGED
|
@@ -29,11 +29,16 @@ 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
43
|
|
|
39
44
|
# Give MongoDB servers time to start up in CI environments
|
|
@@ -128,6 +133,7 @@ RSpec.configure do |config|
|
|
|
128
133
|
config.raise_errors_for_deprecations!
|
|
129
134
|
config.include(Helpers)
|
|
130
135
|
config.include(Mongoid::Expectations)
|
|
136
|
+
config.extend(Mrss::Constraints)
|
|
131
137
|
config.extend(Constraints)
|
|
132
138
|
config.extend(Mongoid::Macros)
|
|
133
139
|
|
data/spec/support/constraints.rb
CHANGED
|
@@ -51,230 +51,4 @@ module Constraints
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
|
|
55
|
-
def min_server_version(version)
|
|
56
|
-
unless version =~ /\A\d+\.\d+\z/
|
|
57
|
-
raise ArgumentError, "Version can only be major.minor: #{version}"
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
before(:all) do
|
|
61
|
-
if version > ClusterConfig.instance.server_version
|
|
62
|
-
skip "Server version #{version} or higher required, we have #{ClusterConfig.instance.server_version}"
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def max_server_version(version)
|
|
68
|
-
unless version =~ /\A\d+\.\d+\z/
|
|
69
|
-
raise ArgumentError, "Version can only be major.minor: #{version}"
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
before(:all) do
|
|
73
|
-
if version < ClusterConfig.instance.short_server_version
|
|
74
|
-
skip "Server version #{version} or lower required, we have #{ClusterConfig.instance.server_version}"
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def require_topology(*topologies)
|
|
80
|
-
invalid_topologies = topologies - [:single, :replica_set, :sharded]
|
|
81
|
-
|
|
82
|
-
unless invalid_topologies.empty?
|
|
83
|
-
raise ArgumentError, "Invalid topologies requested: #{invalid_topologies.join(', ')}"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
before(:all) do
|
|
87
|
-
unless topologies.include?(topology = ClusterConfig.instance.topology)
|
|
88
|
-
skip "Topology #{topologies.join(' or ')} required, we have #{topology}"
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def max_example_run_time(timeout)
|
|
94
|
-
around do |example|
|
|
95
|
-
TimeoutInterrupt.timeout(timeout, TimeoutInterrupt::Error.new("Test execution terminated after #{timeout} seconds")) do
|
|
96
|
-
example.run
|
|
97
|
-
end
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def require_transaction_support
|
|
102
|
-
before(:all) do
|
|
103
|
-
case ClusterConfig.instance.topology
|
|
104
|
-
when :single
|
|
105
|
-
skip 'Transactions tests require a replica set (4.0+) or a sharded cluster (4.2+)'
|
|
106
|
-
when :replica_set
|
|
107
|
-
unless ClusterConfig.instance.server_version >= '4.0'
|
|
108
|
-
skip 'Transactions tests in a replica set topology require server 4.0+'
|
|
109
|
-
end
|
|
110
|
-
when :sharded
|
|
111
|
-
unless ClusterConfig.instance.server_version >= '4.2'
|
|
112
|
-
skip 'Transactions tests in a sharded cluster topology require server 4.2+'
|
|
113
|
-
end
|
|
114
|
-
else
|
|
115
|
-
raise NotImplementedError
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def require_tls
|
|
121
|
-
before(:all) do
|
|
122
|
-
unless SpecConfig.instance.ssl?
|
|
123
|
-
skip "SSL not enabled"
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def require_no_tls
|
|
129
|
-
before(:all) do
|
|
130
|
-
if SpecConfig.instance.ssl?
|
|
131
|
-
skip "SSL enabled"
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def require_local_tls
|
|
137
|
-
require_tls
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
def require_no_retry_writes
|
|
141
|
-
before(:all) do
|
|
142
|
-
if SpecConfig.instance.retry_writes?
|
|
143
|
-
skip "Retry writes is enabled"
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def require_compression
|
|
149
|
-
before(:all) do
|
|
150
|
-
if SpecConfig.instance.compressors.nil?
|
|
151
|
-
skip "Compression is not enabled"
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def require_no_compression
|
|
157
|
-
before(:all) do
|
|
158
|
-
if SpecConfig.instance.compressors
|
|
159
|
-
skip "Compression is enabled"
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
def ruby_version_gte(version)
|
|
165
|
-
before(:all) do
|
|
166
|
-
if RUBY_VERSION < version
|
|
167
|
-
skip "Ruby version #{version} or higher required"
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
def ruby_version_lt(version)
|
|
173
|
-
before(:all) do
|
|
174
|
-
if RUBY_VERSION >= version
|
|
175
|
-
skip "Ruby version less than #{version} required"
|
|
176
|
-
end
|
|
177
|
-
end
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
def require_auth
|
|
181
|
-
before(:all) do
|
|
182
|
-
unless ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
|
|
183
|
-
skip "Auth required"
|
|
184
|
-
end
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
def require_no_auth
|
|
189
|
-
before(:all) do
|
|
190
|
-
if ENV['AUTH'] == 'auth' || SpecConfig.instance.user || ClusterConfig.instance.auth_enabled?
|
|
191
|
-
skip "Auth not allowed"
|
|
192
|
-
end
|
|
193
|
-
end
|
|
194
|
-
end
|
|
195
|
-
|
|
196
|
-
def require_no_x509_auth
|
|
197
|
-
before(:all) do
|
|
198
|
-
if SpecConfig.instance.x509_auth?
|
|
199
|
-
skip "X.509 auth not allowed"
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
# Can the driver specify a write concern that won't be overridden?
|
|
205
|
-
# (mongos 4.0+ overrides the write concern)
|
|
206
|
-
def require_set_write_concern
|
|
207
|
-
before(:all) do
|
|
208
|
-
if ClusterConfig.instance.topology == :sharded && ClusterConfig.instance.short_server_version >= '4.0'
|
|
209
|
-
skip "mongos 4.0+ overrides write concern"
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def require_multi_shard
|
|
215
|
-
before(:all) do
|
|
216
|
-
if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length == 1
|
|
217
|
-
skip 'Test requires a minimum of two shards if run in sharded topology'
|
|
218
|
-
end
|
|
219
|
-
end
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
def require_no_multi_shard
|
|
223
|
-
before(:all) do
|
|
224
|
-
if ClusterConfig.instance.topology == :sharded && SpecConfig.instance.addresses.length > 1
|
|
225
|
-
skip 'Test requires a single shard if run in sharded topology'
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
def require_wired_tiger
|
|
231
|
-
before(:all) do
|
|
232
|
-
if ClusterConfig.instance.storage_engine != :wired_tiger
|
|
233
|
-
skip 'Test requires WiredTiger storage engine'
|
|
234
|
-
end
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
def require_wired_tiger_on_36
|
|
239
|
-
before(:all) do
|
|
240
|
-
if ClusterConfig.instance.short_server_version >= '3.6'
|
|
241
|
-
if ClusterConfig.instance.storage_engine != :wired_tiger
|
|
242
|
-
skip 'Test requires WiredTiger storage engine on 3.6+ servers'
|
|
243
|
-
end
|
|
244
|
-
end
|
|
245
|
-
end
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
def require_mmapv1
|
|
249
|
-
before(:all) do
|
|
250
|
-
if ClusterConfig.instance.storage_engine != :mmapv1
|
|
251
|
-
skip 'Test requires MMAPv1 storage engine'
|
|
252
|
-
end
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
def require_enterprise
|
|
257
|
-
before(:all) do
|
|
258
|
-
unless ClusterConfig.instance.enterprise?
|
|
259
|
-
skip 'Test requires enterprise build of MongoDB'
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
# Integration tests for SRV polling require internet connectivity to
|
|
265
|
-
# look up SRV records and a sharded cluster configured on default port on
|
|
266
|
-
# localhost (localhost:27017, localhost:27018).
|
|
267
|
-
def require_default_port_deployment
|
|
268
|
-
# Because the DNS records at test1.test.build.10gen.cc point to
|
|
269
|
-
# localhost:27017 & localhost:27018, the test suite must have been
|
|
270
|
-
# configured to use these addresses
|
|
271
|
-
before(:all) do
|
|
272
|
-
have_default_port = SpecConfig.instance.addresses.any? do |address|
|
|
273
|
-
%w(127.0.0.1 127.0.0.1:27017 localhost localhost:27017).include?(address)
|
|
274
|
-
end
|
|
275
|
-
unless have_default_port
|
|
276
|
-
skip 'This test requires the test suite to be configured for localhost:27017'
|
|
277
|
-
end
|
|
278
|
-
end
|
|
279
|
-
end
|
|
280
54
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
class Customer
|
|
5
|
+
include Mongoid::Document
|
|
6
|
+
|
|
7
|
+
field :name
|
|
8
|
+
|
|
9
|
+
embeds_one :home_address, class_name: 'CustomerAddress', as: :addressable
|
|
10
|
+
embeds_one :work_address, class_name: 'CustomerAddress', as: :addressable
|
|
11
|
+
end
|
|
@@ -6,7 +6,13 @@ class Dictionary
|
|
|
6
6
|
field :name, type: String
|
|
7
7
|
field :publisher, type: String
|
|
8
8
|
field :year, type: Integer
|
|
9
|
+
|
|
10
|
+
# This field must be a Time
|
|
9
11
|
field :published, type: Time
|
|
12
|
+
|
|
13
|
+
# This field must be a Date
|
|
14
|
+
field :submitted_on, type: Date
|
|
15
|
+
|
|
10
16
|
field :description, type: String, localize: true
|
|
11
17
|
field :l, type: String, as: :language
|
|
12
18
|
has_many :words, validate: false
|
|
@@ -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
|
data/spec/support/models/mop.rb
CHANGED
|
@@ -13,4 +13,13 @@ class Mop
|
|
|
13
13
|
# transformed differently based on the type of field being queried.
|
|
14
14
|
field :int_field, type: Integer
|
|
15
15
|
field :array_field, type: Array
|
|
16
|
+
field :date_field, type: Date
|
|
17
|
+
field :time_field, type: Time
|
|
18
|
+
field :datetime_field, type: DateTime
|
|
19
|
+
field :big_decimal_field, type: BigDecimal
|
|
20
|
+
field :decimal128_field, type: BSON::Decimal128
|
|
21
|
+
field :symbol_field, type: Symbol
|
|
22
|
+
field :bson_symbol_field, type: BSON::Symbol::Raw
|
|
23
|
+
field :regexp_field, type: Regexp
|
|
24
|
+
field :bson_regexp_field, type: BSON::Regexp::Raw
|
|
16
25
|
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
class Order
|
|
5
|
+
include Mongoid::Document
|
|
6
|
+
field :status, type: Mongoid::StringifiedSymbol
|
|
7
|
+
|
|
8
|
+
# This is a dummy field that verifies the Mongoid::Fields::StringifiedSymbol
|
|
9
|
+
# alias.
|
|
10
|
+
field :saved_status, type: StringifiedSymbol
|
|
11
|
+
end
|
|
@@ -80,6 +80,7 @@ class Person
|
|
|
80
80
|
end
|
|
81
81
|
embeds_one :quiz, validate: false
|
|
82
82
|
|
|
83
|
+
# Must have dependent: :destroy
|
|
83
84
|
has_one :game, dependent: :destroy, validate: false do
|
|
84
85
|
def extension
|
|
85
86
|
"Testing"
|
|
@@ -105,6 +106,7 @@ class Person
|
|
|
105
106
|
has_and_belongs_to_many :ordered_preferences, order: :value.desc, validate: false
|
|
106
107
|
|
|
107
108
|
has_many :drugs, validate: false
|
|
109
|
+
# Must not have dependent: :destroy
|
|
108
110
|
has_one :account, validate: false
|
|
109
111
|
has_one :cat, dependent: :nullify, validate: false, primary_key: :username
|
|
110
112
|
has_one :book, autobuild: true, validate: false
|
|
@@ -208,6 +210,12 @@ class Person
|
|
|
208
210
|
reset_callbacks(:create)
|
|
209
211
|
reset_callbacks(:save)
|
|
210
212
|
reset_callbacks(:destroy)
|
|
213
|
+
|
|
214
|
+
private
|
|
215
|
+
|
|
216
|
+
def secret_name
|
|
217
|
+
"secret"
|
|
218
|
+
end
|
|
211
219
|
end
|
|
212
220
|
|
|
213
221
|
require "support/models/doctor"
|