mongoid 6.4.8 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/Rakefile +0 -26
- data/lib/config/locales/en.yml +17 -0
- data/lib/mongoid/association/accessors.rb +339 -0
- data/lib/mongoid/{relations/binding.rb → association/bindable.rb} +32 -52
- data/lib/mongoid/association/builders.rb +92 -0
- data/lib/mongoid/{relations/constraint.rb → association/constrainable.rb} +11 -22
- data/lib/mongoid/association/depending.rb +116 -0
- data/lib/mongoid/{relations/eager.rb → association/eager_loadable.rb} +11 -11
- data/lib/mongoid/{relations → association}/embedded/batchable.rb +21 -21
- data/lib/mongoid/association/embedded/cyclic.rb +109 -0
- data/lib/mongoid/association/embedded/embedded_in/binding.rb +56 -0
- data/lib/mongoid/{relations/builders/embedded/in.rb → association/embedded/embedded_in/buildable.rb} +12 -6
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +121 -0
- data/lib/mongoid/association/embedded/embedded_in.rb +154 -0
- data/lib/mongoid/{relations/bindings/embedded/many.rb → association/embedded/embeds_many/binding.rb} +11 -9
- data/lib/mongoid/{relations/builders/embedded/many.rb → association/embedded/embeds_many/buildable.rb} +13 -7
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +529 -0
- data/lib/mongoid/association/embedded/embeds_many.rb +210 -0
- data/lib/mongoid/{relations/bindings/embedded/one.rb → association/embedded/embeds_one/binding.rb} +12 -10
- data/lib/mongoid/{relations/builders/embedded/one.rb → association/embedded/embeds_one/buildable.rb} +13 -7
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +130 -0
- data/lib/mongoid/association/embedded/embeds_one.rb +173 -0
- data/lib/mongoid/association/embedded.rb +4 -0
- data/lib/mongoid/association/macros.rb +204 -0
- data/lib/mongoid/{relations → association}/many.rb +20 -50
- data/lib/mongoid/{relations → association}/marshalable.rb +6 -4
- data/lib/mongoid/association/nested/many.rb +200 -0
- data/lib/mongoid/association/nested/nested_buildable.rb +72 -0
- data/lib/mongoid/association/nested/one.rb +127 -0
- data/lib/mongoid/association/nested.rb +15 -0
- data/lib/mongoid/{relations → association}/one.rb +6 -6
- data/lib/mongoid/association/options.rb +152 -0
- data/lib/mongoid/{relations → association}/proxy.rb +31 -58
- data/lib/mongoid/association/referenced/auto_save.rb +79 -0
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +87 -0
- data/lib/mongoid/association/referenced/belongs_to/buildable.rb +46 -0
- data/lib/mongoid/association/referenced/belongs_to/eager.rb +36 -0
- data/lib/mongoid/association/referenced/belongs_to/proxy.rb +136 -0
- data/lib/mongoid/association/referenced/belongs_to.rb +248 -0
- data/lib/mongoid/association/referenced/counter_cache.rb +163 -0
- data/lib/mongoid/association/referenced/eager.rb +159 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/binding.rb +71 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/buildable.rb +40 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/eager.rb +52 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +310 -0
- data/lib/mongoid/association/referenced/has_and_belongs_to_many.rb +290 -0
- data/lib/mongoid/{relations/bindings/referenced/many.rb → association/referenced/has_many/binding.rb} +6 -5
- data/lib/mongoid/association/referenced/has_many/buildable.rb +38 -0
- data/lib/mongoid/association/referenced/has_many/eager.rb +43 -0
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +510 -0
- data/lib/mongoid/association/referenced/has_many/proxy.rb +578 -0
- data/lib/mongoid/association/referenced/has_many.rb +275 -0
- data/lib/mongoid/{relations/bindings/referenced/one.rb → association/referenced/has_one/binding.rb} +11 -8
- data/lib/mongoid/association/referenced/has_one/buildable.rb +60 -0
- data/lib/mongoid/association/referenced/has_one/eager.rb +35 -0
- data/lib/mongoid/{relations/builders/nested_attributes/one.rb → association/referenced/has_one/nested_builder.rb} +9 -9
- data/lib/mongoid/association/referenced/has_one/proxy.rb +113 -0
- data/lib/mongoid/association/referenced/has_one.rb +204 -0
- data/lib/mongoid/association/referenced/syncable.rb +170 -0
- data/lib/mongoid/association/referenced.rb +7 -0
- data/lib/mongoid/{relations → association}/reflections.rb +21 -17
- data/lib/mongoid/association/relatable.rb +415 -0
- data/lib/mongoid/association/touchable.rb +97 -0
- data/lib/mongoid/association.rb +150 -0
- data/lib/mongoid/atomic/paths/embedded/many.rb +1 -1
- data/lib/mongoid/atomic/paths/embedded/one.rb +1 -1
- data/lib/mongoid/atomic.rb +4 -4
- data/lib/mongoid/attributes/dynamic.rb +2 -2
- data/lib/mongoid/attributes/nested.rb +10 -10
- data/lib/mongoid/attributes/processing.rb +2 -2
- data/lib/mongoid/attributes/readonly.rb +2 -4
- data/lib/mongoid/attributes.rb +22 -13
- data/lib/mongoid/changeable.rb +1 -1
- data/lib/mongoid/clients/options.rb +1 -1
- data/lib/mongoid/clients/sessions.rb +2 -2
- data/lib/mongoid/composable.rb +4 -4
- data/lib/mongoid/config.rb +1 -0
- data/lib/mongoid/contextual/aggregable/mongo.rb +1 -1
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/geo_near.rb +1 -1
- data/lib/mongoid/contextual/map_reduce.rb +4 -4
- data/lib/mongoid/contextual/memory.rb +25 -7
- data/lib/mongoid/contextual/mongo.rb +13 -11
- data/lib/mongoid/copyable.rb +6 -6
- data/lib/mongoid/criteria/includable.rb +14 -14
- data/lib/mongoid/criteria/modifiable.rb +8 -14
- data/lib/mongoid/criteria/queryable/extensions/string.rb +1 -1
- data/lib/mongoid/criteria/queryable/pipeline.rb +10 -5
- data/lib/mongoid/criteria/queryable/selectable.rb +10 -34
- data/lib/mongoid/criteria.rb +2 -2
- data/lib/mongoid/document.rb +6 -6
- data/lib/mongoid/errors/invalid_dependent_strategy.rb +32 -0
- data/lib/mongoid/errors/invalid_relation_option.rb +29 -0
- data/lib/mongoid/errors/unknown_model.rb +25 -0
- data/lib/mongoid/errors.rb +3 -0
- data/lib/mongoid/extensions/array.rb +5 -5
- data/lib/mongoid/extensions/big_decimal.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +5 -2
- data/lib/mongoid/extensions/object.rb +4 -4
- data/lib/mongoid/extensions/range.rb +1 -0
- data/lib/mongoid/extensions/regexp.rb +0 -1
- data/lib/mongoid/extensions/string.rb +1 -3
- data/lib/mongoid/extensions.rb +0 -4
- data/lib/mongoid/factory.rb +13 -3
- data/lib/mongoid/fields/foreign_key.rb +5 -5
- data/lib/mongoid/fields/standard.rb +2 -14
- data/lib/mongoid/fields/validators/macro.rb +1 -1
- data/lib/mongoid/fields.rb +3 -3
- data/lib/mongoid/indexable.rb +8 -5
- data/lib/mongoid/interceptable.rb +5 -5
- data/lib/mongoid/matchable/and.rb +1 -1
- data/lib/mongoid/matchable/elem_match.rb +9 -3
- data/lib/mongoid/matchable.rb +0 -3
- data/lib/mongoid/persistable/creatable.rb +2 -2
- data/lib/mongoid/persistable/deletable.rb +9 -8
- data/lib/mongoid/persistable/incrementable.rb +1 -1
- data/lib/mongoid/persistable/logical.rb +1 -1
- data/lib/mongoid/persistable/settable.rb +5 -5
- data/lib/mongoid/persistable/updatable.rb +2 -2
- data/lib/mongoid/persistable/upsertable.rb +1 -1
- data/lib/mongoid/persistable.rb +5 -6
- data/lib/mongoid/persistence_context.rb +1 -5
- data/lib/mongoid/query_cache.rb +19 -64
- data/lib/mongoid/railtie.rb +0 -17
- data/lib/mongoid/reloadable.rb +1 -1
- data/lib/mongoid/scopable.rb +3 -3
- data/lib/mongoid/serializable.rb +4 -4
- data/lib/mongoid/shardable.rb +1 -1
- data/lib/mongoid/tasks/database.rb +2 -2
- data/lib/mongoid/threaded.rb +0 -36
- data/lib/mongoid/traversable.rb +3 -3
- data/lib/mongoid/validatable/presence.rb +2 -2
- data/lib/mongoid/validatable/uniqueness.rb +4 -4
- data/lib/mongoid/validatable.rb +8 -8
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +3 -0
- data/spec/app/models/animal.rb +2 -1
- data/spec/app/models/bomb.rb +1 -1
- data/spec/app/models/message.rb +1 -1
- data/spec/app/models/person.rb +5 -2
- data/spec/app/models/shipment_address.rb +1 -0
- data/spec/app/models/vertex.rb +6 -0
- data/spec/app/models/wiki_page.rb +1 -1
- data/spec/config/mongoid.yml +1 -0
- data/spec/mongoid/{relations → association}/accessors_spec.rb +1 -1
- data/spec/mongoid/{relations → association}/auto_save_spec.rb +60 -12
- data/spec/mongoid/{relations → association}/builders_spec.rb +1 -1
- data/spec/mongoid/association/constrainable_spec.rb +115 -0
- data/spec/mongoid/{relations → association}/counter_cache_spec.rb +1 -1
- data/spec/mongoid/association/depending_spec.rb +613 -0
- data/spec/mongoid/{relations → association}/eager_spec.rb +12 -12
- data/spec/mongoid/{relations → association/embedded}/cyclic_spec.rb +1 -1
- data/spec/mongoid/{relations/bindings/embedded/in_spec.rb → association/embedded/embedded_in/binding_spec.rb} +13 -13
- data/spec/mongoid/{relations/builders/embedded/in_spec.rb → association/embedded/embedded_in/buildable_spec.rb} +9 -9
- data/spec/mongoid/{relations/embedded/in_spec.rb → association/embedded/embedded_in/proxy_spec.rb} +5 -77
- data/spec/mongoid/association/embedded/embedded_in_spec.rb +843 -0
- data/spec/mongoid/{relations/bindings/embedded/many_spec.rb → association/embedded/embeds_many/binding_spec.rb} +3 -3
- data/spec/mongoid/{relations/builders/embedded/many_spec.rb → association/embedded/embeds_many/buildable_spec.rb} +17 -45
- data/spec/mongoid/{relations/embedded/many_spec.rb → association/embedded/embeds_many/proxy_spec.rb} +140 -428
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +852 -0
- data/spec/mongoid/{relations/bindings/embedded/one_spec.rb → association/embedded/embeds_one/binding_spec.rb} +4 -4
- data/spec/mongoid/{relations/builders/embedded/one_spec.rb → association/embedded/embeds_one/buildable_spec.rb} +14 -34
- data/spec/mongoid/{relations/embedded/one_spec.rb → association/embedded/embeds_one/proxy_spec.rb} +39 -84
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +908 -0
- data/spec/mongoid/{relations → association}/macros_spec.rb +148 -73
- data/spec/mongoid/{relations/builders/nested_attributes → association/nested}/many_spec.rb +16 -19
- data/spec/mongoid/{relations/builders/nested_attributes → association/nested}/one_spec.rb +17 -20
- data/spec/mongoid/association/options_spec.rb +1321 -0
- data/spec/mongoid/{relations → association}/polymorphic_spec.rb +7 -34
- data/spec/mongoid/{relations/bindings/referenced/in_spec.rb → association/referenced/belongs_to/binding_spec.rb} +7 -7
- data/spec/mongoid/{relations/builders/referenced/in_spec.rb → association/referenced/belongs_to/buildable_spec.rb} +46 -79
- data/spec/mongoid/{relations/eager/belongs_to_spec.rb → association/referenced/belongs_to/eager_spec.rb} +9 -9
- data/spec/mongoid/{relations/referenced/in_spec.rb → association/referenced/belongs_to/proxy_spec.rb} +57 -91
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +1963 -0
- data/spec/mongoid/{relations/bindings/referenced/many_to_many_spec.rb → association/referenced/has_and_belongs_to_many/binding_spec.rb} +5 -5
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/buildable_spec.rb +121 -0
- data/spec/mongoid/{relations/eager/has_and_belongs_to_many_spec.rb → association/referenced/has_and_belongs_to_many/eager_spec.rb} +5 -5
- data/spec/mongoid/{relations/referenced/many_to_many_spec.rb → association/referenced/has_and_belongs_to_many/proxy_spec.rb} +107 -98
- data/spec/mongoid/association/referenced/has_and_belongs_to_many_spec.rb +1027 -0
- data/spec/mongoid/{relations/bindings/referenced/many_spec.rb → association/referenced/has_many/binding_spec.rb} +5 -5
- data/spec/mongoid/association/referenced/has_many/buildable_spec.rb +119 -0
- data/spec/mongoid/{relations/eager/has_many_spec.rb → association/referenced/has_many/eager_spec.rb} +26 -11
- data/spec/mongoid/{relations/targets → association/referenced/has_many}/enumerable_spec.rb +122 -1
- data/spec/mongoid/{relations/referenced/many_spec.rb → association/referenced/has_many/proxy_spec.rb} +28 -93
- data/spec/mongoid/association/referenced/has_many_spec.rb +1225 -0
- data/spec/mongoid/{relations/bindings/referenced/one_spec.rb → association/referenced/has_one/binding_spec.rb} +4 -4
- data/spec/mongoid/association/referenced/has_one/buildable_spec.rb +113 -0
- data/spec/mongoid/{relations/eager/has_one_spec.rb → association/referenced/has_one/eager_spec.rb} +10 -10
- data/spec/mongoid/{relations/referenced/one_spec.rb → association/referenced/has_one/proxy_spec.rb} +9 -109
- data/spec/mongoid/association/referenced/has_one_spec.rb +1244 -0
- data/spec/mongoid/{relations → association}/reflections_spec.rb +1 -12
- data/spec/mongoid/{relations/synchronization_spec.rb → association/syncable_spec.rb} +4 -2
- data/spec/mongoid/{relations → association}/touchable_spec.rb +19 -1
- data/spec/mongoid/{relations_spec.rb → association_spec.rb} +1 -1
- data/spec/mongoid/atomic/modifiers_spec.rb +2 -2
- data/spec/mongoid/atomic_spec.rb +4 -4
- data/spec/mongoid/attributes/nested_spec.rb +14 -12
- data/spec/mongoid/attributes/readonly_spec.rb +80 -125
- data/spec/mongoid/attributes_spec.rb +38 -2
- data/spec/mongoid/clients/factory_spec.rb +28 -52
- data/spec/mongoid/clients/options_spec.rb +65 -69
- data/spec/mongoid/clients/sessions_spec.rb +4 -13
- data/spec/mongoid/config_spec.rb +24 -0
- data/spec/mongoid/contextual/geo_near_spec.rb +0 -1
- data/spec/mongoid/contextual/memory_spec.rb +19 -0
- data/spec/mongoid/contextual/mongo_spec.rb +30 -5
- data/spec/mongoid/copyable_spec.rb +34 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +183 -60
- data/spec/mongoid/criteria/queryable/extensions/big_decimal_spec.rb +3 -3
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +43 -0
- data/spec/mongoid/criteria/queryable/pipeline_spec.rb +12 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +3 -42
- data/spec/mongoid/criteria/queryable/selector_spec.rb +2 -2
- data/spec/mongoid/criteria/scopable_spec.rb +0 -81
- data/spec/mongoid/criteria_spec.rb +16 -19
- data/spec/mongoid/document_spec.rb +2 -56
- data/spec/mongoid/extensions/array_spec.rb +11 -15
- data/spec/mongoid/extensions/big_decimal_spec.rb +9 -9
- data/spec/mongoid/extensions/hash_spec.rb +18 -1
- data/spec/mongoid/extensions/object_spec.rb +7 -11
- data/spec/mongoid/extensions/range_spec.rb +7 -0
- data/spec/mongoid/extensions/regexp_spec.rb +0 -23
- data/spec/mongoid/extensions/string_spec.rb +7 -35
- data/spec/mongoid/factory_spec.rb +19 -1
- data/spec/mongoid/fields/foreign_key_spec.rb +24 -32
- data/spec/mongoid/fields_spec.rb +2 -2
- data/spec/mongoid/findable_spec.rb +1 -1
- data/spec/mongoid/indexable_spec.rb +18 -8
- data/spec/mongoid/interceptable_spec.rb +22 -1
- data/spec/mongoid/matchable/elem_match_spec.rb +20 -0
- data/spec/mongoid/matchable_spec.rb +1 -26
- data/spec/mongoid/persistable/incrementable_spec.rb +6 -6
- data/spec/mongoid/persistable/savable_spec.rb +2 -2
- data/spec/mongoid/persistable/settable_spec.rb +1 -35
- data/spec/mongoid/persistable_spec.rb +21 -6
- data/spec/mongoid/query_cache_spec.rb +16 -99
- data/spec/mongoid/relations/proxy_spec.rb +124 -124
- data/spec/mongoid/scopable_spec.rb +0 -13
- data/spec/mongoid/shardable_spec.rb +32 -12
- data/spec/mongoid/threaded_spec.rb +0 -68
- data/spec/mongoid/validatable/associated_spec.rb +1 -1
- data/spec/mongoid/validatable/presence_spec.rb +7 -6
- data/spec/mongoid/validatable_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -14
- data.tar.gz.sig +1 -1
- metadata +192 -207
- metadata.gz.sig +0 -0
- data/lib/mongoid/matchable/nor.rb +0 -37
- data/lib/mongoid/railties/controller_runtime.rb +0 -86
- data/lib/mongoid/relations/accessors.rb +0 -267
- data/lib/mongoid/relations/auto_save.rb +0 -94
- data/lib/mongoid/relations/bindings/embedded/in.rb +0 -59
- data/lib/mongoid/relations/bindings/referenced/in.rb +0 -65
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +0 -70
- data/lib/mongoid/relations/bindings.rb +0 -9
- data/lib/mongoid/relations/builder.rb +0 -57
- data/lib/mongoid/relations/builders/nested_attributes/many.rb +0 -199
- data/lib/mongoid/relations/builders/referenced/in.rb +0 -26
- data/lib/mongoid/relations/builders/referenced/many.rb +0 -26
- data/lib/mongoid/relations/builders/referenced/many_to_many.rb +0 -39
- data/lib/mongoid/relations/builders/referenced/one.rb +0 -26
- data/lib/mongoid/relations/builders.rb +0 -106
- data/lib/mongoid/relations/cascading/delete.rb +0 -44
- data/lib/mongoid/relations/cascading/destroy.rb +0 -43
- data/lib/mongoid/relations/cascading/nullify.rb +0 -35
- data/lib/mongoid/relations/cascading/restrict.rb +0 -39
- data/lib/mongoid/relations/cascading.rb +0 -56
- data/lib/mongoid/relations/conversions.rb +0 -34
- data/lib/mongoid/relations/counter_cache.rb +0 -160
- data/lib/mongoid/relations/cyclic.rb +0 -107
- data/lib/mongoid/relations/eager/base.rb +0 -153
- data/lib/mongoid/relations/eager/belongs_to.rb +0 -31
- data/lib/mongoid/relations/eager/has_and_belongs_to_many.rb +0 -47
- data/lib/mongoid/relations/eager/has_many.rb +0 -38
- data/lib/mongoid/relations/eager/has_one.rb +0 -30
- data/lib/mongoid/relations/embedded/in.rb +0 -241
- data/lib/mongoid/relations/embedded/many.rb +0 -683
- data/lib/mongoid/relations/embedded/one.rb +0 -235
- data/lib/mongoid/relations/macros.rb +0 -367
- data/lib/mongoid/relations/metadata.rb +0 -1179
- data/lib/mongoid/relations/nested_builder.rb +0 -74
- data/lib/mongoid/relations/options.rb +0 -49
- data/lib/mongoid/relations/polymorphic.rb +0 -39
- data/lib/mongoid/relations/referenced/in.rb +0 -304
- data/lib/mongoid/relations/referenced/many.rb +0 -812
- data/lib/mongoid/relations/referenced/many_to_many.rb +0 -479
- data/lib/mongoid/relations/referenced/one.rb +0 -290
- data/lib/mongoid/relations/synchronization.rb +0 -169
- data/lib/mongoid/relations/targets/enumerable.rb +0 -493
- data/lib/mongoid/relations/targets.rb +0 -2
- data/lib/mongoid/relations/touchable.rb +0 -97
- data/lib/mongoid/relations.rb +0 -148
- data/spec/app/models/array_field.rb +0 -7
- data/spec/app/models/delegating_patient.rb +0 -16
- data/spec/integration/document_spec.rb +0 -22
- data/spec/mongoid/fields/internal/foreign_keys/array_spec.rb +0 -184
- data/spec/mongoid/fields/internal/foreign_keys/object_spec.rb +0 -201
- data/spec/mongoid/matchable/nor_spec.rb +0 -209
- data/spec/mongoid/relations/builders/referenced/many_spec.rb +0 -137
- data/spec/mongoid/relations/builders/referenced/many_to_many_spec.rb +0 -178
- data/spec/mongoid/relations/builders/referenced/one_spec.rb +0 -111
- data/spec/mongoid/relations/cascading/delete_spec.rb +0 -101
- data/spec/mongoid/relations/cascading/destroy_spec.rb +0 -47
- data/spec/mongoid/relations/cascading/nullify_spec.rb +0 -32
- data/spec/mongoid/relations/cascading/restrict_spec.rb +0 -68
- data/spec/mongoid/relations/cascading_spec.rb +0 -355
- data/spec/mongoid/relations/constraint_spec.rb +0 -75
- data/spec/mongoid/relations/conversions_spec.rb +0 -128
- data/spec/mongoid/relations/metadata_spec.rb +0 -1985
- data/spec/mongoid/relations/options_spec.rb +0 -35
- data/spec/rails/controller_extension/controller_runtime_spec.rb +0 -110
- data/spec/support/cluster_config.rb +0 -158
- data/spec/support/constraints.rb +0 -101
- data/spec/support/macros.rb +0 -20
- data/spec/support/session_registry.rb +0 -50
- data/spec/support/spec_config.rb +0 -42
- /data/spec/mongoid/{relations → association}/embedded/dirty_spec.rb +0 -0
@@ -1,35 +1,7 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
1
|
require "spec_helper"
|
5
2
|
|
6
3
|
describe Mongoid::Clients::Factory do
|
7
4
|
|
8
|
-
shared_examples_for 'includes seed address' do
|
9
|
-
let(:configured_address) do
|
10
|
-
address = SpecConfig.instance.addresses.first
|
11
|
-
unless address.include?(':')
|
12
|
-
address = "#{address}:27017"
|
13
|
-
end
|
14
|
-
address
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:expected_addresses) do
|
18
|
-
[
|
19
|
-
configured_address,
|
20
|
-
configured_address.sub(/\Alocalhost:/, '127.0.0.1:'),
|
21
|
-
configured_address.sub(/\A127\.0\.0\.1:/, 'localhost:'),
|
22
|
-
].uniq
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'includes seed address' do
|
26
|
-
ok = cluster_addresses.any? do |address|
|
27
|
-
expected_addresses.include?(address)
|
28
|
-
end
|
29
|
-
expect(ok).to be true
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
5
|
describe ".create" do
|
34
6
|
|
35
7
|
context "when provided a name" do
|
@@ -40,8 +12,8 @@ describe Mongoid::Clients::Factory do
|
|
40
12
|
|
41
13
|
let(:config) do
|
42
14
|
{
|
43
|
-
default: { hosts:
|
44
|
-
secondary: { hosts:
|
15
|
+
default: { hosts: [ "127.0.0.1:27017" ], database: database_id },
|
16
|
+
secondary: { hosts: [ "127.0.0.1:27017" ], database: database_id }
|
45
17
|
}
|
46
18
|
end
|
47
19
|
|
@@ -65,12 +37,10 @@ describe Mongoid::Clients::Factory do
|
|
65
37
|
expect(client).to be_a(Mongo::Client)
|
66
38
|
end
|
67
39
|
|
68
|
-
|
69
|
-
cluster.addresses.
|
40
|
+
it "sets the cluster's seeds" do
|
41
|
+
expect(cluster.addresses.first.to_s).to eq("127.0.0.1:27017")
|
70
42
|
end
|
71
43
|
|
72
|
-
it_behaves_like 'includes seed address'
|
73
|
-
|
74
44
|
it "sets the platform to Mongoid's platform constant" do
|
75
45
|
expect(client.options[:platform]).to eq(Mongoid::PLATFORM_DETAILS)
|
76
46
|
end
|
@@ -110,11 +80,11 @@ describe Mongoid::Clients::Factory do
|
|
110
80
|
end
|
111
81
|
|
112
82
|
it "sets the cluster's seed ports to 27017" do
|
113
|
-
expect(
|
83
|
+
expect(cluster.addresses.first.to_s).to eq("127.0.0.1:27017")
|
114
84
|
end
|
115
85
|
|
116
86
|
it "sets ips with no ports to 27017" do
|
117
|
-
expect(
|
87
|
+
expect(default.cluster.addresses.first.to_s).to eq("127.0.0.1:27017")
|
118
88
|
end
|
119
89
|
end
|
120
90
|
|
@@ -150,7 +120,7 @@ describe Mongoid::Clients::Factory do
|
|
150
120
|
end
|
151
121
|
|
152
122
|
it "sets the cluster's seeds" do
|
153
|
-
expect(
|
123
|
+
expect(cluster.addresses.first.to_s).to eq("127.0.0.1:27017")
|
154
124
|
end
|
155
125
|
|
156
126
|
it "sets the database" do
|
@@ -162,8 +132,8 @@ describe Mongoid::Clients::Factory do
|
|
162
132
|
|
163
133
|
let(:config) do
|
164
134
|
{
|
165
|
-
default: { hosts: [ "127.0.0.1:
|
166
|
-
secondary: { uri: "mongodb://127.0.0.1:
|
135
|
+
default: { hosts: [ "127.0.0.1:27017" ], database: database_id },
|
136
|
+
secondary: { uri: "mongodb://127.0.0.1:27017,127.0.0.1:27018/mongoid_test" }
|
167
137
|
}
|
168
138
|
end
|
169
139
|
|
@@ -192,7 +162,7 @@ describe Mongoid::Clients::Factory do
|
|
192
162
|
end
|
193
163
|
|
194
164
|
it "sets the cluster's seeds" do
|
195
|
-
expect(seeds).to eq([ "127.0.0.1:
|
165
|
+
expect(seeds).to eq([ "127.0.0.1:27017", "127.0.0.1:27018" ])
|
196
166
|
end
|
197
167
|
end
|
198
168
|
end
|
@@ -211,7 +181,7 @@ describe Mongoid::Clients::Factory do
|
|
211
181
|
context "when no name is provided" do
|
212
182
|
|
213
183
|
let(:config) do
|
214
|
-
{ default: { hosts:
|
184
|
+
{ default: { hosts: ["127.0.0.1:27017"], database: database_id }}
|
215
185
|
end
|
216
186
|
|
217
187
|
before do
|
@@ -230,15 +200,17 @@ describe Mongoid::Clients::Factory do
|
|
230
200
|
client.cluster
|
231
201
|
end
|
232
202
|
|
233
|
-
let(:
|
234
|
-
cluster.addresses.map
|
203
|
+
let(:seeds) do
|
204
|
+
cluster.addresses.map{ |address| address.to_s }
|
235
205
|
end
|
236
206
|
|
237
207
|
it "returns the default client" do
|
238
208
|
expect(client).to be_a(Mongo::Client)
|
239
209
|
end
|
240
210
|
|
241
|
-
|
211
|
+
it "sets the cluster's seeds" do
|
212
|
+
expect(seeds).to eq([ "127.0.0.1:27017" ])
|
213
|
+
end
|
242
214
|
end
|
243
215
|
|
244
216
|
context "when nil is provided and no default config" do
|
@@ -258,7 +230,7 @@ describe Mongoid::Clients::Factory do
|
|
258
230
|
describe ".default" do
|
259
231
|
|
260
232
|
let(:config) do
|
261
|
-
{ default: { hosts:
|
233
|
+
{ default: { hosts: ["127.0.0.1:27017"], database: database_id }}
|
262
234
|
end
|
263
235
|
|
264
236
|
before do
|
@@ -277,15 +249,17 @@ describe Mongoid::Clients::Factory do
|
|
277
249
|
client.cluster
|
278
250
|
end
|
279
251
|
|
280
|
-
let(:
|
281
|
-
cluster.addresses.map
|
252
|
+
let(:seeds) do
|
253
|
+
cluster.addresses.map{ |address| address.to_s }
|
282
254
|
end
|
283
255
|
|
284
256
|
it "returns the default client" do
|
285
257
|
expect(client).to be_a(Mongo::Client)
|
286
258
|
end
|
287
259
|
|
288
|
-
|
260
|
+
it "sets the cluster's seeds" do
|
261
|
+
expect(seeds).to eq([ "127.0.0.1:27017" ])
|
262
|
+
end
|
289
263
|
end
|
290
264
|
|
291
265
|
context "when options are provided with string keys" do
|
@@ -293,7 +267,7 @@ describe Mongoid::Clients::Factory do
|
|
293
267
|
let(:config) do
|
294
268
|
{
|
295
269
|
default: {
|
296
|
-
hosts:
|
270
|
+
hosts: [ "127.0.0.1:27017" ],
|
297
271
|
database: database_id,
|
298
272
|
options: {
|
299
273
|
"server_selection_timeout" => 10,
|
@@ -319,15 +293,17 @@ describe Mongoid::Clients::Factory do
|
|
319
293
|
client.cluster
|
320
294
|
end
|
321
295
|
|
322
|
-
let(:
|
323
|
-
cluster.addresses.map
|
296
|
+
let(:seeds) do
|
297
|
+
cluster.addresses.map{ |address| address.to_s }
|
324
298
|
end
|
325
299
|
|
326
300
|
it "returns the default client" do
|
327
301
|
expect(client).to be_a(Mongo::Client)
|
328
302
|
end
|
329
303
|
|
330
|
-
|
304
|
+
it "sets the cluster's seeds" do
|
305
|
+
expect(seeds).to eq([ "127.0.0.1:27017" ])
|
306
|
+
end
|
331
307
|
|
332
308
|
it "sets the server selection timeout" do
|
333
309
|
expect(cluster.options[:server_selection_timeout]).to eq(10)
|
@@ -2,12 +2,23 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
describe Mongoid::Clients::Options do
|
4
4
|
|
5
|
+
before(:all) do
|
6
|
+
class TestModel
|
7
|
+
include Mongoid::Document
|
8
|
+
field :name
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:all) do
|
13
|
+
Object.send(:remove_const, :TestModel)
|
14
|
+
end
|
15
|
+
|
5
16
|
describe '#with', if: non_legacy_server? do
|
6
17
|
|
7
18
|
context 'when passing some options' do
|
8
19
|
|
9
20
|
let(:persistence_context) do
|
10
|
-
|
21
|
+
TestModel.with(options) do |klass|
|
11
22
|
klass.persistence_context
|
12
23
|
end
|
13
24
|
end
|
@@ -19,13 +30,13 @@ describe Mongoid::Clients::Options do
|
|
19
30
|
end
|
20
31
|
|
21
32
|
it 'does not set the options on class level' do
|
22
|
-
expect(
|
33
|
+
expect(TestModel.persistence_context.client.options['database']).to eq('mongoid_test')
|
23
34
|
end
|
24
35
|
|
25
36
|
context 'when the options are not valid mongo client options' do
|
26
37
|
|
27
38
|
let(:persistence_context) do
|
28
|
-
|
39
|
+
TestModel.with(invalid_options) do |klass|
|
29
40
|
klass.persistence_context
|
30
41
|
end
|
31
42
|
end
|
@@ -40,7 +51,7 @@ describe Mongoid::Clients::Options do
|
|
40
51
|
|
41
52
|
it 'clears the persistence context' do
|
42
53
|
begin; persistence_context; rescue Mongoid::Errors::InvalidPersistenceOption; end
|
43
|
-
expect(
|
54
|
+
expect(TestModel.persistence_context).to eq(Mongoid::PersistenceContext.new(TestModel))
|
44
55
|
end
|
45
56
|
end
|
46
57
|
|
@@ -66,14 +77,14 @@ describe Mongoid::Clients::Options do
|
|
66
77
|
context 'when passing a block', if: testing_locally? do
|
67
78
|
|
68
79
|
let!(:connections_before) do
|
69
|
-
|
80
|
+
TestModel.mongo_client.database.command(serverStatus: 1).first['connections']['current']
|
70
81
|
end
|
71
82
|
|
72
83
|
let!(:connections_and_cluster_during) do
|
73
84
|
connections = nil
|
74
|
-
cluster =
|
85
|
+
cluster = TestModel.with(options) do |klass|
|
75
86
|
klass.where(name: 'emily').to_a
|
76
|
-
connections =
|
87
|
+
connections = TestModel.mongo_client.database.command(serverStatus: 1).first['connections']['current']
|
77
88
|
end
|
78
89
|
[ connections, cluster ]
|
79
90
|
end
|
@@ -87,15 +98,15 @@ describe Mongoid::Clients::Options do
|
|
87
98
|
end
|
88
99
|
|
89
100
|
let(:connections_after) do
|
90
|
-
|
101
|
+
TestModel.mongo_client.database.command(serverStatus: 1).first['connections']['current']
|
91
102
|
end
|
92
103
|
|
93
104
|
let!(:cluster_before) do
|
94
|
-
|
105
|
+
TestModel.persistence_context.cluster
|
95
106
|
end
|
96
107
|
|
97
108
|
let(:cluster_after) do
|
98
|
-
|
109
|
+
TestModel.persistence_context.cluster
|
99
110
|
end
|
100
111
|
|
101
112
|
context 'when the options create a new cluster' do
|
@@ -148,7 +159,7 @@ describe Mongoid::Clients::Options do
|
|
148
159
|
end
|
149
160
|
|
150
161
|
let(:persistence_context) do
|
151
|
-
|
162
|
+
TestModel.with(client: :secondary) do |klass|
|
152
163
|
klass.persistence_context
|
153
164
|
end
|
154
165
|
end
|
@@ -177,40 +188,25 @@ describe Mongoid::Clients::Options do
|
|
177
188
|
|
178
189
|
context 'when returning a criteria' do
|
179
190
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
collection =
|
184
|
-
|
185
|
-
collection = klass.all.collection
|
186
|
-
klass.persistence_context
|
187
|
-
end
|
188
|
-
[ cxt, collection ]
|
189
|
-
end
|
190
|
-
|
191
|
-
let(:persistence_context) do
|
192
|
-
context_and_criteria[0]
|
193
|
-
end
|
194
|
-
|
195
|
-
let(:client) do
|
196
|
-
context_and_criteria[1].client
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'applies the options to the criteria client' do
|
200
|
-
expect(client.options['read']).to eq('mode' => :secondary)
|
191
|
+
let(:context_and_criteria) do
|
192
|
+
collection = nil
|
193
|
+
cxt = TestModel.with(read: :secondary) do |klass|
|
194
|
+
collection = klass.all.collection
|
195
|
+
klass.persistence_context
|
201
196
|
end
|
197
|
+
[ cxt, collection ]
|
202
198
|
end
|
203
199
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
it_behaves_like 'applies secondary read preference'
|
200
|
+
let(:persistence_context) do
|
201
|
+
context_and_criteria[0]
|
208
202
|
end
|
209
203
|
|
210
|
-
|
211
|
-
|
204
|
+
let(:client) do
|
205
|
+
context_and_criteria[1].client
|
206
|
+
end
|
212
207
|
|
213
|
-
|
208
|
+
it 'applies the options to the criteria client' do
|
209
|
+
expect(client.options['read']).to eq(:secondary)
|
214
210
|
end
|
215
211
|
end
|
216
212
|
|
@@ -221,11 +217,11 @@ describe Mongoid::Clients::Options do
|
|
221
217
|
100.times do |i|
|
222
218
|
threads << Thread.new do
|
223
219
|
if i % 2 == 0
|
224
|
-
|
220
|
+
TestModel.with(collection: 'British') do |klass|
|
225
221
|
klass.create(name: 'realised')
|
226
222
|
end
|
227
223
|
else
|
228
|
-
|
224
|
+
TestModel.with(collection: 'American') do |klass|
|
229
225
|
klass.create(name: 'realized')
|
230
226
|
end
|
231
227
|
end
|
@@ -235,13 +231,13 @@ describe Mongoid::Clients::Options do
|
|
235
231
|
end
|
236
232
|
|
237
233
|
let(:british_count) do
|
238
|
-
|
234
|
+
TestModel.with(collection: 'British') do |klass|
|
239
235
|
klass.all.count
|
240
236
|
end
|
241
237
|
end
|
242
238
|
|
243
239
|
let(:american_count) do
|
244
|
-
|
240
|
+
TestModel.with(collection: 'American') do |klass|
|
245
241
|
klass.all.count
|
246
242
|
end
|
247
243
|
end
|
@@ -256,7 +252,7 @@ describe Mongoid::Clients::Options do
|
|
256
252
|
context 'when passing a persistence context' do
|
257
253
|
|
258
254
|
let(:instance) do
|
259
|
-
|
255
|
+
TestModel.new
|
260
256
|
end
|
261
257
|
|
262
258
|
let(:persistence_context) do
|
@@ -268,8 +264,8 @@ describe Mongoid::Clients::Options do
|
|
268
264
|
let(:options) { { database: 'other' } }
|
269
265
|
|
270
266
|
it 'sets the persistence context on the object' do
|
271
|
-
|
272
|
-
expect(
|
267
|
+
TestModel.new.with(persistence_context) do |model_instance|
|
268
|
+
expect(model_instance.persistence_context.options).to eq(persistence_context.options)
|
273
269
|
end
|
274
270
|
end
|
275
271
|
end
|
@@ -283,12 +279,12 @@ describe Mongoid::Clients::Options do
|
|
283
279
|
{ database: 'other' }
|
284
280
|
end
|
285
281
|
|
286
|
-
let(:
|
287
|
-
|
282
|
+
let(:test_model) do
|
283
|
+
TestModel.create
|
288
284
|
end
|
289
285
|
|
290
286
|
let(:persistence_context) do
|
291
|
-
|
287
|
+
test_model.with(options) do |object|
|
292
288
|
object.persistence_context
|
293
289
|
end
|
294
290
|
end
|
@@ -298,13 +294,13 @@ describe Mongoid::Clients::Options do
|
|
298
294
|
end
|
299
295
|
|
300
296
|
it 'does not set the options on instance level' do
|
301
|
-
expect(
|
297
|
+
expect(test_model.persistence_context.client.database.name).to eq('mongoid_test')
|
302
298
|
end
|
303
299
|
|
304
300
|
context 'when the options are not valid mongo client options' do
|
305
301
|
|
306
302
|
let(:persistence_context) do
|
307
|
-
|
303
|
+
test_model.with(invalid_options) do |object|
|
308
304
|
object.persistence_context
|
309
305
|
end
|
310
306
|
end
|
@@ -319,7 +315,7 @@ describe Mongoid::Clients::Options do
|
|
319
315
|
|
320
316
|
it 'clears the persistence context' do
|
321
317
|
begin; persistence_context; rescue Mongoid::Errors::InvalidPersistenceOption; end
|
322
|
-
expect(
|
318
|
+
expect(test_model.persistence_context).to eq(Mongoid::PersistenceContext.new(test_model))
|
323
319
|
end
|
324
320
|
end
|
325
321
|
|
@@ -337,7 +333,7 @@ describe Mongoid::Clients::Options do
|
|
337
333
|
end
|
338
334
|
|
339
335
|
let(:persistence_context) do
|
340
|
-
|
336
|
+
test_model.with(client: :secondary) do |object|
|
341
337
|
object.persistence_context
|
342
338
|
end
|
343
339
|
end
|
@@ -351,14 +347,14 @@ describe Mongoid::Clients::Options do
|
|
351
347
|
context 'when passing a block', if: testing_locally? do
|
352
348
|
|
353
349
|
let!(:connections_before) do
|
354
|
-
|
350
|
+
test_model.mongo_client.database.command(serverStatus: 1).first['connections']['current']
|
355
351
|
end
|
356
352
|
|
357
|
-
let(:connections_and_cluster_during) do
|
353
|
+
let!(:connections_and_cluster_during) do
|
358
354
|
connections = nil
|
359
|
-
cluster =
|
355
|
+
cluster = test_model.with(options) do |b|
|
360
356
|
b.reload
|
361
|
-
connections =
|
357
|
+
connections = test_model.mongo_client.database.command(serverStatus: 1).first['connections']['current']
|
362
358
|
b.persistence_context.cluster
|
363
359
|
end
|
364
360
|
[ connections, cluster ]
|
@@ -373,15 +369,15 @@ describe Mongoid::Clients::Options do
|
|
373
369
|
end
|
374
370
|
|
375
371
|
let(:connections_after) do
|
376
|
-
|
372
|
+
test_model.mongo_client.database.command(serverStatus: 1).first['connections']['current']
|
377
373
|
end
|
378
374
|
|
379
375
|
let!(:cluster_before) do
|
380
|
-
|
376
|
+
test_model.persistence_context.cluster
|
381
377
|
end
|
382
378
|
|
383
379
|
let(:cluster_after) do
|
384
|
-
|
380
|
+
test_model.persistence_context.cluster
|
385
381
|
end
|
386
382
|
|
387
383
|
context 'when the options create a new cluster' do
|
@@ -396,7 +392,7 @@ describe Mongoid::Clients::Options do
|
|
396
392
|
end
|
397
393
|
|
398
394
|
it 'disconnects the new cluster when the block exits' do
|
399
|
-
expect(
|
395
|
+
expect(connections_before).to eq(connections_after)
|
400
396
|
end
|
401
397
|
end
|
402
398
|
|
@@ -431,15 +427,15 @@ describe Mongoid::Clients::Options do
|
|
431
427
|
before do
|
432
428
|
threads = []
|
433
429
|
100.times do |i|
|
434
|
-
|
430
|
+
test_model = TestModel.create
|
435
431
|
threads << Thread.new do
|
436
432
|
if i % 2 == 0
|
437
|
-
|
433
|
+
test_model.with(collection: 'British') do |b|
|
438
434
|
b.name = 'realised'
|
439
435
|
b.upsert
|
440
436
|
end
|
441
437
|
else
|
442
|
-
|
438
|
+
test_model.with(collection: 'American') do |b|
|
443
439
|
b.name = 'realized'
|
444
440
|
b.upsert
|
445
441
|
end
|
@@ -450,13 +446,13 @@ describe Mongoid::Clients::Options do
|
|
450
446
|
end
|
451
447
|
|
452
448
|
let(:british_count) do
|
453
|
-
|
449
|
+
TestModel.with(collection: 'British') do |klass|
|
454
450
|
klass.all.count
|
455
451
|
end
|
456
452
|
end
|
457
453
|
|
458
454
|
let(:american_count) do
|
459
|
-
|
455
|
+
TestModel.with(collection: 'British') do |klass|
|
460
456
|
klass.all.count
|
461
457
|
end
|
462
458
|
end
|
@@ -471,7 +467,7 @@ describe Mongoid::Clients::Options do
|
|
471
467
|
context 'when passing a persistence context' do
|
472
468
|
|
473
469
|
let(:persistence_context) do
|
474
|
-
|
470
|
+
TestModel.with(options) do |klass|
|
475
471
|
klass.persistence_context
|
476
472
|
end
|
477
473
|
end
|
@@ -479,8 +475,8 @@ describe Mongoid::Clients::Options do
|
|
479
475
|
let(:options) { { database: 'other' } }
|
480
476
|
|
481
477
|
it 'sets the persistence context on the object' do
|
482
|
-
|
483
|
-
expect(
|
478
|
+
TestModel.with(persistence_context) do |test_model_class|
|
479
|
+
expect(test_model_class.persistence_context.options).to eq(persistence_context.options)
|
484
480
|
end
|
485
481
|
end
|
486
482
|
end
|
@@ -16,26 +16,17 @@ describe Mongoid::Clients::Sessions do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
let(:subscriber) do
|
19
|
-
|
20
|
-
monitoring = if client.respond_to?(:monitoring, true)
|
21
|
-
client.send(:monitoring)
|
22
|
-
else
|
23
|
-
# driver 2.5
|
24
|
-
client.instance_variable_get('@monitoring')
|
25
|
-
end
|
26
|
-
monitoring.subscribers['Command'].find do |s|
|
19
|
+
Mongoid::Clients.with_name(:other).instance_variable_get(:@monitoring).subscribers['Command'].find do |s|
|
27
20
|
s.is_a?(EventSubscriber)
|
28
21
|
end
|
29
22
|
end
|
30
23
|
|
31
24
|
let(:insert_events) do
|
32
|
-
|
33
|
-
subscriber.started_events.select { |event| event.command_name.to_s == 'insert' }
|
25
|
+
subscriber.started_events.select { |event| event.command_name == :insert }
|
34
26
|
end
|
35
27
|
|
36
28
|
let(:update_events) do
|
37
|
-
|
38
|
-
subscriber.started_events.select { |event| event.command_name.to_s == 'update' }
|
29
|
+
subscriber.started_events.select { |event| event.command_name == :update }
|
39
30
|
end
|
40
31
|
|
41
32
|
context 'when a session is used on a model class' do
|
@@ -123,7 +114,7 @@ describe Mongoid::Clients::Sessions do
|
|
123
114
|
Post.create
|
124
115
|
end
|
125
116
|
rescue => ex
|
126
|
-
|
117
|
+
e = ex
|
127
118
|
end
|
128
119
|
e
|
129
120
|
end
|
data/spec/mongoid/config_spec.rb
CHANGED
@@ -88,6 +88,30 @@ describe Mongoid::Config do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
context 'when background_indexing option' do
|
92
|
+
context 'is not set in the config' do
|
93
|
+
it 'sets the value to false by default' do
|
94
|
+
Mongoid::Config.reset
|
95
|
+
configuration = CONFIG.merge(options: {})
|
96
|
+
|
97
|
+
Mongoid.configure { |config| config.load_configuration(configuration) }
|
98
|
+
|
99
|
+
expect(Mongoid::Config.background_indexing).to be(false)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'is set in the config' do
|
104
|
+
it 'sets the value' do
|
105
|
+
Mongoid::Config.reset
|
106
|
+
configuration = CONFIG.merge(options: {background_indexing: true})
|
107
|
+
|
108
|
+
Mongoid.configure { |config| config.load_configuration(configuration) }
|
109
|
+
|
110
|
+
expect(Mongoid::Config.background_indexing).to be(true)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
91
115
|
context 'when the belongs_to_required_by_default option is not set in the config' do
|
92
116
|
|
93
117
|
before do
|
@@ -987,6 +987,25 @@ describe Mongoid::Contextual::Memory do
|
|
987
987
|
end
|
988
988
|
end
|
989
989
|
|
990
|
+
describe '#inc' do
|
991
|
+
|
992
|
+
let(:criteria) do
|
993
|
+
Address.all.tap do |crit|
|
994
|
+
crit.documents = [ Address.new(number: 1),
|
995
|
+
Address.new(number: 2),
|
996
|
+
Address.new(number: 3) ]
|
997
|
+
end
|
998
|
+
end
|
999
|
+
|
1000
|
+
let(:context) do
|
1001
|
+
described_class.new(criteria)
|
1002
|
+
end
|
1003
|
+
|
1004
|
+
it 'increases each member' do
|
1005
|
+
expect(context.inc(number: 10).collect(&:number)).to eql([11, 12, 13])
|
1006
|
+
end
|
1007
|
+
end
|
1008
|
+
|
990
1009
|
describe "#skip" do
|
991
1010
|
|
992
1011
|
let(:hobrecht) do
|