mongoid 4.0.2 → 5.0.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
- data/CHANGELOG.md +66 -1
- data/README.md +11 -19
- data/lib/config/locales/en.yml +33 -30
- data/lib/mongoid/atomic.rb +2 -4
- data/lib/mongoid/attributes/processing.rb +4 -1
- data/lib/mongoid/attributes/readonly.rb +2 -2
- data/lib/mongoid/attributes.rb +7 -7
- data/lib/mongoid/changeable.rb +4 -6
- data/lib/mongoid/clients/factory.rb +78 -0
- data/lib/mongoid/{sessions → clients}/options.rb +30 -19
- data/lib/mongoid/{sessions → clients}/storage_options.rb +27 -13
- data/lib/mongoid/{sessions → clients}/thread_options.rb +6 -3
- data/lib/mongoid/{sessions → clients}/validators/storage.rb +5 -2
- data/lib/mongoid/clients/validators.rb +2 -0
- data/lib/mongoid/clients.rb +141 -0
- data/lib/mongoid/composable.rb +3 -3
- data/lib/mongoid/config/environment.rb +1 -1
- data/lib/mongoid/config/options.rb +1 -1
- data/lib/mongoid/config/validators/{session.rb → client.rb} +31 -28
- data/lib/mongoid/config/validators/option.rb +1 -1
- data/lib/mongoid/config/validators.rb +1 -1
- data/lib/mongoid/config.rb +39 -41
- data/lib/mongoid/contextual/aggregable/mongo.rb +1 -1
- data/lib/mongoid/contextual/atomic.rb +11 -11
- data/lib/mongoid/contextual/command.rb +9 -6
- data/lib/mongoid/contextual/geo_near.rb +17 -1
- data/lib/mongoid/contextual/map_reduce.rb +12 -11
- data/lib/mongoid/contextual/memory.rb +2 -5
- data/lib/mongoid/contextual/mongo.rb +92 -82
- data/lib/mongoid/contextual/none.rb +13 -0
- data/lib/mongoid/copyable.rb +6 -1
- data/lib/mongoid/criteria.rb +37 -4
- data/lib/mongoid/document.rb +3 -4
- data/lib/mongoid/errors/{mixed_session_configuration.rb → mixed_client_configuration.rb} +5 -5
- data/lib/mongoid/errors/mongoid_error.rb +15 -9
- data/lib/mongoid/errors/no_client_config.rb +22 -0
- data/lib/mongoid/errors/{no_session_database.rb → no_client_database.rb} +4 -4
- data/lib/mongoid/errors/{no_session_hosts.rb → no_client_hosts.rb} +4 -4
- data/lib/mongoid/errors/{no_sessions_config.rb → no_clients_config.rb} +4 -4
- data/lib/mongoid/errors/no_default_client.rb +23 -0
- data/lib/mongoid/errors.rb +6 -6
- data/lib/mongoid/extensions/hash.rb +5 -1
- data/lib/mongoid/extensions/object.rb +3 -2
- data/lib/mongoid/extensions/set.rb +5 -5
- data/lib/mongoid/factory.rb +4 -2
- data/lib/mongoid/fields.rb +7 -2
- data/lib/mongoid/findable.rb +4 -1
- data/lib/mongoid/indexable.rb +15 -9
- data/lib/mongoid/persistable/creatable.rb +2 -2
- data/lib/mongoid/persistable/deletable.rb +3 -3
- data/lib/mongoid/persistable/incrementable.rb +1 -1
- data/lib/mongoid/persistable/logical.rb +1 -1
- data/lib/mongoid/persistable/poppable.rb +1 -1
- data/lib/mongoid/persistable/pullable.rb +2 -2
- data/lib/mongoid/persistable/pushable.rb +2 -2
- data/lib/mongoid/persistable/renamable.rb +1 -1
- data/lib/mongoid/persistable/settable.rb +1 -1
- data/lib/mongoid/persistable/unsettable.rb +1 -1
- data/lib/mongoid/persistable/updatable.rb +2 -2
- data/lib/mongoid/persistable/upsertable.rb +1 -1
- data/lib/mongoid/persistable.rb +1 -2
- data/lib/mongoid/query_cache.rb +98 -104
- data/lib/mongoid/railtie.rb +4 -25
- data/lib/mongoid/railties/database.rake +1 -1
- data/lib/mongoid/relations/bindings/referenced/many_to_many.rb +3 -2
- data/lib/mongoid/relations/builders.rb +3 -1
- data/lib/mongoid/relations/counter_cache.rb +1 -1
- data/lib/mongoid/relations/embedded/batchable.rb +3 -10
- data/lib/mongoid/relations/embedded/many.rb +4 -2
- data/lib/mongoid/relations/embedded/one.rb +1 -0
- data/lib/mongoid/relations/many.rb +1 -0
- data/lib/mongoid/relations/metadata.rb +14 -0
- data/lib/mongoid/relations/proxy.rb +6 -6
- data/lib/mongoid/relations/referenced/many.rb +2 -1
- data/lib/mongoid/relations/targets/enumerable.rb +11 -11
- data/lib/mongoid/relations/touchable.rb +1 -1
- data/lib/mongoid/reloadable.rb +2 -2
- data/lib/mongoid/scopable.rb +6 -17
- data/lib/mongoid/selectable.rb +1 -36
- data/lib/mongoid/serializable.rb +2 -2
- data/lib/mongoid/stateful.rb +0 -1
- data/lib/mongoid/tasks/database.rake +2 -2
- data/lib/mongoid/tasks/database.rb +24 -17
- data/lib/mongoid/threaded/lifecycle.rb +21 -16
- data/lib/mongoid/threaded.rb +54 -33
- data/lib/mongoid/traversable.rb +17 -1
- data/lib/mongoid/validatable/queryable.rb +1 -1
- data/lib/mongoid/validatable/uniqueness.rb +3 -20
- data/lib/mongoid/validatable.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/mongoid.rb +28 -21
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +91 -57
- data/lib/rails/mongoid.rb +2 -2
- data/spec/app/models/audio.rb +1 -1
- data/spec/app/models/band.rb +1 -0
- data/spec/app/models/code.rb +6 -0
- data/spec/app/models/company.rb +5 -0
- data/spec/app/models/label.rb +7 -0
- data/spec/app/models/pub.rb +6 -0
- data/spec/app/models/staff.rb +7 -0
- data/spec/app/models/store_as_dup_test1.rb +5 -0
- data/spec/app/models/store_as_dup_test2.rb +5 -0
- data/spec/config/mongoid.yml +7 -25
- data/spec/mongoid/atomic/paths_spec.rb +3 -11
- data/spec/mongoid/attributes/nested_spec.rb +16 -16
- data/spec/mongoid/attributes/readonly_spec.rb +80 -18
- data/spec/mongoid/attributes_spec.rb +3 -3
- data/spec/mongoid/changeable_spec.rb +156 -0
- data/spec/mongoid/clients/factory_spec.rb +284 -0
- data/spec/mongoid/{sessions → clients}/options_spec.rb +4 -6
- data/spec/mongoid/clients_spec.rb +754 -0
- data/spec/mongoid/config/environment_spec.rb +14 -11
- data/spec/mongoid/config_spec.rb +33 -48
- data/spec/mongoid/contextual/atomic_spec.rb +1 -17
- data/spec/mongoid/contextual/geo_near_spec.rb +35 -0
- data/spec/mongoid/contextual/mongo_spec.rb +26 -83
- data/spec/mongoid/contextual/none_spec.rb +15 -0
- data/spec/mongoid/copyable_spec.rb +35 -1
- data/spec/mongoid/criteria/findable_spec.rb +197 -0
- data/spec/mongoid/criteria/modifiable_spec.rb +7 -29
- data/spec/mongoid/criteria_spec.rb +74 -91
- data/spec/mongoid/document_spec.rb +1 -1
- data/spec/mongoid/errors/{mixed_session_configuration_spec.rb → mixed_client_configuration_spec.rb} +1 -1
- data/spec/mongoid/errors/mongoid_error_spec.rb +19 -3
- data/spec/mongoid/errors/{no_session_config_spec.rb → no_client_config_spec.rb} +4 -4
- data/spec/mongoid/errors/{no_session_database_spec.rb → no_client_database_spec.rb} +4 -4
- data/spec/mongoid/errors/{no_session_hosts_spec.rb → no_client_hosts_spec.rb} +3 -3
- data/spec/mongoid/errors/{no_sessions_config_spec.rb → no_clients_config_spec.rb} +2 -2
- data/spec/mongoid/fields/localized_spec.rb +1 -0
- data/spec/mongoid/fields_spec.rb +1 -0
- data/spec/mongoid/findable_spec.rb +2 -23
- data/spec/mongoid/indexable_spec.rb +12 -8
- data/spec/mongoid/interceptable_spec.rb +15 -0
- data/spec/mongoid/persistable/settable_spec.rb +16 -0
- data/spec/mongoid/persistable/updatable_spec.rb +3 -2
- data/spec/mongoid/persistable_spec.rb +4 -4
- data/spec/mongoid/query_cache_spec.rb +13 -8
- data/spec/mongoid/relations/auto_save_spec.rb +1 -1
- data/spec/mongoid/relations/counter_cache_spec.rb +34 -0
- data/spec/mongoid/relations/eager/belongs_to_spec.rb +9 -0
- data/spec/mongoid/relations/eager/has_and_belongs_to_many_spec.rb +3 -3
- data/spec/mongoid/relations/embedded/many_spec.rb +123 -1
- data/spec/mongoid/relations/embedded/one_spec.rb +3 -3
- data/spec/mongoid/relations/proxy_spec.rb +28 -0
- data/spec/mongoid/relations/referenced/in_spec.rb +1 -1
- data/spec/mongoid/relations/referenced/many_spec.rb +47 -23
- data/spec/mongoid/relations/referenced/many_to_many_spec.rb +1 -1
- data/spec/mongoid/relations/referenced/one_spec.rb +1 -1
- data/spec/mongoid/relations/targets/enumerable_spec.rb +9 -2
- data/spec/mongoid/reloadable_spec.rb +6 -6
- data/spec/mongoid/scopable_spec.rb +41 -28
- data/spec/mongoid/selectable_spec.rb +6 -16
- data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
- data/spec/mongoid/tasks/database_spec.rb +2 -2
- data/spec/mongoid/threaded_spec.rb +0 -7
- data/spec/mongoid/traversable_spec.rb +2 -2
- data/spec/mongoid/validatable/uniqueness_spec.rb +30 -1
- data/spec/mongoid_spec.rb +13 -15
- data/spec/rails/mongoid_spec.rb +13 -4
- data/spec/spec_helper.rb +44 -27
- data/spec/support/authorization.rb +12 -0
- data/spec/support/expectations.rb +14 -0
- metadata +50 -57
- data/lib/mongoid/contextual/find_and_modify.rb +0 -69
- data/lib/mongoid/contextual/text_search.rb +0 -178
- data/lib/mongoid/criteria/#findable.rb# +0 -141
- data/lib/mongoid/errors/no_default_session.rb +0 -23
- data/lib/mongoid/errors/no_session_config.rb +0 -22
- data/lib/mongoid/log_subscriber.rb +0 -55
- data/lib/mongoid/positional.rb +0 -71
- data/lib/mongoid/sessions/factory.rb +0 -131
- data/lib/mongoid/sessions/mongo_uri.rb +0 -93
- data/lib/mongoid/sessions/validators.rb +0 -2
- data/lib/mongoid/sessions.rb +0 -125
- data/lib/mongoid/support/query_counter.rb +0 -23
- data/spec/helpers.rb +0 -18
- data/spec/mongoid/#atomic_spec.rb# +0 -365
- data/spec/mongoid/contextual/find_and_modify_spec.rb +0 -220
- data/spec/mongoid/contextual/text_search_spec.rb +0 -209
- data/spec/mongoid/log_subscriber_spec.rb +0 -75
- data/spec/mongoid/positional_spec.rb +0 -222
- data/spec/mongoid/sessions/factory_spec.rb +0 -333
- data/spec/mongoid/sessions/mongo_uri_spec.rb +0 -103
- data/spec/mongoid/sessions_spec.rb +0 -1252
|
@@ -1,62 +1,101 @@
|
|
|
1
1
|
development:
|
|
2
|
-
# Configure available database
|
|
3
|
-
|
|
4
|
-
# Defines the default
|
|
2
|
+
# Configure available database clients. (required)
|
|
3
|
+
clients:
|
|
4
|
+
# Defines the default client. (required)
|
|
5
5
|
default:
|
|
6
6
|
# Defines the name of the default database that Mongoid can connect to.
|
|
7
7
|
# (required).
|
|
8
8
|
database: <%= database_name || app_name %>_development
|
|
9
|
-
# Provides the hosts the default
|
|
9
|
+
# Provides the hosts the default client can connect to. Must be an array
|
|
10
10
|
# of host:port pairs. (required)
|
|
11
11
|
hosts:
|
|
12
12
|
- localhost:27017
|
|
13
13
|
options:
|
|
14
14
|
# Change the default write concern. (default = { w: 1 })
|
|
15
15
|
# write:
|
|
16
|
-
#
|
|
17
|
-
|
|
18
|
-
# Change the default
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
# read:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
# The
|
|
28
|
-
#
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
#
|
|
38
|
-
|
|
39
|
-
# (default:
|
|
40
|
-
#
|
|
41
|
-
|
|
42
|
-
#
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
#
|
|
48
|
-
#
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# (default:
|
|
52
|
-
#
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
#
|
|
56
|
-
|
|
57
|
-
#
|
|
58
|
-
#
|
|
59
|
-
|
|
16
|
+
# w: 1
|
|
17
|
+
|
|
18
|
+
# Change the default read preference. Valid options for mode are: :secondary,
|
|
19
|
+
# :secondary_preferred, :primary, :primary_preferred, :nearest
|
|
20
|
+
# (default: primary)
|
|
21
|
+
# read:
|
|
22
|
+
# mode: :secondary_preferred
|
|
23
|
+
|
|
24
|
+
# The name of the user for authentication.
|
|
25
|
+
# user: 'user'
|
|
26
|
+
|
|
27
|
+
# The password of the user for authentication.
|
|
28
|
+
# password: 'password'
|
|
29
|
+
|
|
30
|
+
# The user's database roles.
|
|
31
|
+
# roles:
|
|
32
|
+
# - 'dbOwner'
|
|
33
|
+
|
|
34
|
+
# Change the default authentication mechanism. Valid options are: :scram,
|
|
35
|
+
# :mongodb_cr, :mongodb_x509, and :plain. (default on 3.0 is :scram, default
|
|
36
|
+
# on 2.4 and 2.6 is :plain)
|
|
37
|
+
# auth_mech: :scram
|
|
38
|
+
|
|
39
|
+
# The database or source to authenticate the user against. (default: admin)
|
|
40
|
+
# auth_source: admin
|
|
41
|
+
|
|
42
|
+
# Force a the driver cluster to behave in a certain manner instead of auto-
|
|
43
|
+
# discovering. Can be one of: :direct, :replica_set, :sharded. Set to :direct
|
|
44
|
+
# when connecting to hidden members of a replica set.
|
|
45
|
+
# connect: :direct
|
|
46
|
+
|
|
47
|
+
# Changes the default time in seconds the server monitors refresh their status
|
|
48
|
+
# via ismaster commands. (default: 10)
|
|
49
|
+
# heartbeat_frequency: 10
|
|
50
|
+
|
|
51
|
+
# The time in seconds for selecting servers for a near read preference. (default: 5)
|
|
52
|
+
# local_threshold: 5
|
|
53
|
+
|
|
54
|
+
# The timeout in seconds for selecting a server for an operation. (default: 30)
|
|
55
|
+
# server_selection_timeout: 30
|
|
56
|
+
|
|
57
|
+
# The maximum number of connections in the connection pool. (default: 5)
|
|
58
|
+
# max_pool_size: 5
|
|
59
|
+
|
|
60
|
+
# The minimum number of connections in the connection pool. (default: 1)
|
|
61
|
+
# min_pool_size: 1
|
|
62
|
+
|
|
63
|
+
# The time to wait, in seconds, in the connection pool for a connection
|
|
64
|
+
# to be checked in before timing out. (default: 5)
|
|
65
|
+
# wait_queue_timeout: 5
|
|
66
|
+
|
|
67
|
+
# The time to wait to establish a connection before timing out, in seconds.
|
|
68
|
+
# (default: 5)
|
|
69
|
+
# connect_timeout: 5
|
|
70
|
+
|
|
71
|
+
# The timeout to wait to execute operations on a socket before raising an error.
|
|
72
|
+
# (default: 5)
|
|
73
|
+
# socket_timeout: 5
|
|
74
|
+
|
|
75
|
+
# The name of the replica set to connect to. Servers provided as seeds that do
|
|
76
|
+
# not belong to this replica set will be ignored.
|
|
77
|
+
# replica_set: name
|
|
78
|
+
|
|
79
|
+
# Whether to connect to the servers via ssl. (default: false)
|
|
80
|
+
# ssl: true
|
|
81
|
+
|
|
82
|
+
# The certificate file used to identify the connection against MongoDB.
|
|
83
|
+
# ssl_cert: /path/to/my.cert
|
|
84
|
+
|
|
85
|
+
# The private keyfile used to identify the connection against MongoDB.
|
|
86
|
+
# Note that even if the key is stored in the same file as the certificate,
|
|
87
|
+
# both need to be explicitly specified.
|
|
88
|
+
# ssl_key: /path/to/my.key
|
|
89
|
+
|
|
90
|
+
# A passphrase for the private key.
|
|
91
|
+
# ssl_key_pass_phrase: password
|
|
92
|
+
|
|
93
|
+
# Whether or not to do peer certification validation. (default: false)
|
|
94
|
+
# ssl_verify: true
|
|
95
|
+
|
|
96
|
+
# The file containing a set of concatenated certification authority certifications
|
|
97
|
+
# used to validate certs passed from the other end of the connection.
|
|
98
|
+
# ssl_ca_cert: /path/to/ca.cert
|
|
60
99
|
|
|
61
100
|
|
|
62
101
|
# Configure Mongoid specific options. (optional)
|
|
@@ -71,9 +110,6 @@ development:
|
|
|
71
110
|
# inheritance. (default: false)
|
|
72
111
|
# preload_models: false
|
|
73
112
|
|
|
74
|
-
# Protect id and type from mass assignment. (default: true)
|
|
75
|
-
# protect_sensitive_fields: true
|
|
76
|
-
|
|
77
113
|
# Raise an error when performing a #find and the document is not found.
|
|
78
114
|
# (default: true)
|
|
79
115
|
# raise_not_found_error: true
|
|
@@ -88,14 +124,12 @@ development:
|
|
|
88
124
|
# Ensure all times are UTC in the app side. (default: false)
|
|
89
125
|
# use_utc: false
|
|
90
126
|
test:
|
|
91
|
-
|
|
127
|
+
clients:
|
|
92
128
|
default:
|
|
93
129
|
database: <%= database_name || app_name %>_test
|
|
94
130
|
hosts:
|
|
95
131
|
- localhost:27017
|
|
96
132
|
options:
|
|
97
|
-
read:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
max_retries: 1
|
|
101
|
-
retry_interval: 0
|
|
133
|
+
read:
|
|
134
|
+
mode: primary
|
|
135
|
+
max_pool_size: 1
|
data/lib/rails/mongoid.rb
CHANGED
|
@@ -12,10 +12,10 @@ module Rails
|
|
|
12
12
|
#
|
|
13
13
|
# @param [ Application ] app The rails application.
|
|
14
14
|
def load_models(app)
|
|
15
|
-
app.config.paths["app/models"].each do |path|
|
|
15
|
+
app.config.paths["app/models"].expanded.each do |path|
|
|
16
16
|
preload = ::Mongoid.preload_models
|
|
17
17
|
if preload.resizable?
|
|
18
|
-
files = preload.map { |model| "#{path}/#{model}.rb" }
|
|
18
|
+
files = preload.map { |model| "#{path}/#{model.underscore}.rb" }
|
|
19
19
|
else
|
|
20
20
|
files = Dir.glob("#{path}/**/*.rb")
|
|
21
21
|
end
|
data/spec/app/models/audio.rb
CHANGED
data/spec/app/models/band.rb
CHANGED
|
@@ -15,6 +15,7 @@ class Band
|
|
|
15
15
|
field :sales, type: BigDecimal
|
|
16
16
|
field :y, as: :years, type: Integer
|
|
17
17
|
field :founded, type: Date
|
|
18
|
+
field :deleted, type: Boolean
|
|
18
19
|
|
|
19
20
|
embeds_many :records, cascade_callbacks: true
|
|
20
21
|
embeds_many :notes, as: :noteable, cascade_callbacks: true, validate: false
|
data/spec/app/models/code.rb
CHANGED
data/spec/app/models/label.rb
CHANGED
|
@@ -8,15 +8,22 @@ class Label
|
|
|
8
8
|
field :after_update_called, type: Mongoid::Boolean, default: false
|
|
9
9
|
field :after_validation_called, type: Mongoid::Boolean, default: false
|
|
10
10
|
|
|
11
|
+
field :before_save_count, type: Integer, default: 0
|
|
12
|
+
|
|
11
13
|
embedded_in :artist
|
|
12
14
|
embedded_in :band
|
|
13
15
|
|
|
16
|
+
before_save :before_save_stub
|
|
14
17
|
after_create :after_create_stub
|
|
15
18
|
after_save :after_save_stub
|
|
16
19
|
after_update :after_update_stub
|
|
17
20
|
after_validation :after_validation_stub
|
|
18
21
|
before_validation :cleanup
|
|
19
22
|
|
|
23
|
+
def before_save_stub
|
|
24
|
+
self.before_save_count += 1
|
|
25
|
+
end
|
|
26
|
+
|
|
20
27
|
def after_create_stub
|
|
21
28
|
self.after_create_called = true
|
|
22
29
|
end
|
data/spec/config/mongoid.yml
CHANGED
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
test:
|
|
2
|
-
|
|
2
|
+
clients:
|
|
3
3
|
default:
|
|
4
4
|
database: mongoid_test
|
|
5
5
|
hosts:
|
|
6
6
|
- <%=ENV["MONGOID_SPEC_HOST"]%>:<%=ENV["MONGOID_SPEC_PORT"]%>
|
|
7
7
|
options:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
- <%=ENV["MONGOHQ_SINGLE_URL"]%>
|
|
15
|
-
options:
|
|
16
|
-
write:
|
|
17
|
-
w: 1
|
|
18
|
-
read: primary
|
|
19
|
-
mongohq_repl:
|
|
20
|
-
database: <%=ENV["MONGOHQ_REPL_NAME"]%>
|
|
21
|
-
username: <%=ENV["MONGOHQ_REPL_USER"]%>
|
|
22
|
-
password: <%=ENV["MONGOHQ_REPL_PASS"]%>
|
|
23
|
-
hosts:
|
|
24
|
-
- <%=ENV["MONGOHQ_REPL_1_URL"]%>
|
|
25
|
-
- <%=ENV["MONGOHQ_REPL_2_URL"]%>
|
|
26
|
-
options:
|
|
27
|
-
read: primary
|
|
28
|
-
write:
|
|
29
|
-
w: majority
|
|
30
|
-
mongohq_repl_uri:
|
|
31
|
-
uri: <%= ENV["MONGOHQ_REPL_URI"]%>
|
|
8
|
+
user: "mongoid-user"
|
|
9
|
+
password: "password"
|
|
10
|
+
auth_source: "admin"
|
|
11
|
+
read:
|
|
12
|
+
mode: :primary
|
|
13
|
+
max_pool_size: 1
|
|
32
14
|
options:
|
|
33
15
|
include_root_in_json: false
|
|
34
16
|
include_type_for_serialization: false
|
|
@@ -111,9 +111,7 @@ describe Mongoid::Atomic::Paths do
|
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
it "returns the association with id.atomic_selector" do
|
|
114
|
-
expect(address.atomic_selector).to eq(
|
|
115
|
-
{ "_id" => person.id, "addresses._id" => address.id }
|
|
116
|
-
)
|
|
114
|
+
expect(address.atomic_selector).to eq({ "_id" => person.id })
|
|
117
115
|
end
|
|
118
116
|
end
|
|
119
117
|
|
|
@@ -124,14 +122,8 @@ describe Mongoid::Atomic::Paths do
|
|
|
124
122
|
person.addresses << address
|
|
125
123
|
end
|
|
126
124
|
|
|
127
|
-
it "returns the JSON notation to the document with
|
|
128
|
-
expect(location.atomic_selector).to eq(
|
|
129
|
-
{
|
|
130
|
-
"_id" => person.id,
|
|
131
|
-
"addresses._id" => address.id,
|
|
132
|
-
"addresses.locations._id" => location.id
|
|
133
|
-
}
|
|
134
|
-
)
|
|
125
|
+
it "returns the JSON notation to the document with id" do
|
|
126
|
+
expect(location.atomic_selector).to eq({ "_id" => person.id })
|
|
135
127
|
end
|
|
136
128
|
end
|
|
137
129
|
end
|
|
@@ -2936,11 +2936,11 @@ describe Mongoid::Attributes::Nested do
|
|
|
2936
2936
|
context "when reloading the document" do
|
|
2937
2937
|
|
|
2938
2938
|
it "updates the first existing document" do
|
|
2939
|
-
expect(person.posts(true).
|
|
2939
|
+
expect(person.posts(true)[0].title).to eq("First")
|
|
2940
2940
|
end
|
|
2941
2941
|
|
|
2942
2942
|
it "updates the second existing document" do
|
|
2943
|
-
expect(person.posts(true).
|
|
2943
|
+
expect(person.posts(true)[1].title).to eq("Second")
|
|
2944
2944
|
end
|
|
2945
2945
|
|
|
2946
2946
|
it "does not add new documents" do
|
|
@@ -3094,11 +3094,11 @@ describe Mongoid::Attributes::Nested do
|
|
|
3094
3094
|
context "when reloading the document" do
|
|
3095
3095
|
|
|
3096
3096
|
it "does not ignore the marked document" do
|
|
3097
|
-
expect(person.posts(true).
|
|
3097
|
+
expect(person.posts(true)[0].title).to eq("Another Title")
|
|
3098
3098
|
end
|
|
3099
3099
|
|
|
3100
3100
|
it "does not delete the unmarked document" do
|
|
3101
|
-
expect(person.posts(true).
|
|
3101
|
+
expect(person.posts(true)[1].title).to eq("New Title")
|
|
3102
3102
|
end
|
|
3103
3103
|
|
|
3104
3104
|
it "does not add additional documents" do
|
|
@@ -3127,7 +3127,7 @@ describe Mongoid::Attributes::Nested do
|
|
|
3127
3127
|
end
|
|
3128
3128
|
|
|
3129
3129
|
it "does not delete the unmarked document" do
|
|
3130
|
-
expect(person.posts(true).
|
|
3130
|
+
expect(person.posts(true)[1].title).to eq("New Title")
|
|
3131
3131
|
end
|
|
3132
3132
|
end
|
|
3133
3133
|
end
|
|
@@ -3198,7 +3198,7 @@ describe Mongoid::Attributes::Nested do
|
|
|
3198
3198
|
end
|
|
3199
3199
|
|
|
3200
3200
|
it "does not delete the unmarked document" do
|
|
3201
|
-
expect(person.posts(true).
|
|
3201
|
+
expect(person.posts(true)[1].title).to eq("New Title")
|
|
3202
3202
|
end
|
|
3203
3203
|
end
|
|
3204
3204
|
end
|
|
@@ -3224,15 +3224,15 @@ describe Mongoid::Attributes::Nested do
|
|
|
3224
3224
|
end
|
|
3225
3225
|
|
|
3226
3226
|
it "builds a new first document" do
|
|
3227
|
-
expect(person.posts.
|
|
3227
|
+
expect(person.posts[0].title).to eq("First")
|
|
3228
3228
|
end
|
|
3229
3229
|
|
|
3230
3230
|
it "builds a new second document" do
|
|
3231
|
-
expect(person.posts.
|
|
3231
|
+
expect(person.posts[1].title).to eq("Second")
|
|
3232
3232
|
end
|
|
3233
3233
|
|
|
3234
3234
|
it "builds a new third document" do
|
|
3235
|
-
expect(person.posts.
|
|
3235
|
+
expect(person.posts[2].title).to eq("Third")
|
|
3236
3236
|
end
|
|
3237
3237
|
|
|
3238
3238
|
it "does not add extra documents" do
|
|
@@ -3776,7 +3776,7 @@ describe Mongoid::Attributes::Nested do
|
|
|
3776
3776
|
end
|
|
3777
3777
|
|
|
3778
3778
|
it "does not delete the unmarked document" do
|
|
3779
|
-
expect(person.preferences(true).
|
|
3779
|
+
expect(person.preferences(true)[1].name).to eq("My Blog")
|
|
3780
3780
|
end
|
|
3781
3781
|
end
|
|
3782
3782
|
end
|
|
@@ -3811,11 +3811,11 @@ describe Mongoid::Attributes::Nested do
|
|
|
3811
3811
|
context "when reloading the document" do
|
|
3812
3812
|
|
|
3813
3813
|
it "does not ignore the marked document" do
|
|
3814
|
-
expect(person.preferences(true).
|
|
3814
|
+
expect(person.preferences(true)[0].name).to eq("Another Title")
|
|
3815
3815
|
end
|
|
3816
3816
|
|
|
3817
3817
|
it "does not delete the unmarked document" do
|
|
3818
|
-
expect(person.preferences(true).
|
|
3818
|
+
expect(person.preferences(true)[1].name).to eq("New Title")
|
|
3819
3819
|
end
|
|
3820
3820
|
|
|
3821
3821
|
it "does not add additional documents" do
|
|
@@ -3844,7 +3844,7 @@ describe Mongoid::Attributes::Nested do
|
|
|
3844
3844
|
end
|
|
3845
3845
|
|
|
3846
3846
|
it "does not delete the unmarked document" do
|
|
3847
|
-
expect(person.preferences(true).
|
|
3847
|
+
expect(person.preferences(true)[1].name).to eq("New Title")
|
|
3848
3848
|
end
|
|
3849
3849
|
end
|
|
3850
3850
|
end
|
|
@@ -3874,11 +3874,11 @@ describe Mongoid::Attributes::Nested do
|
|
|
3874
3874
|
context "when reloading" do
|
|
3875
3875
|
|
|
3876
3876
|
it "does not ignore the marked document" do
|
|
3877
|
-
expect(person.preferences(true).
|
|
3877
|
+
expect(person.preferences(true)[0].name).to eq("Another Title")
|
|
3878
3878
|
end
|
|
3879
3879
|
|
|
3880
3880
|
it "does not delete the unmarked document" do
|
|
3881
|
-
expect(person.preferences(true).
|
|
3881
|
+
expect(person.preferences(true)[1].name).to eq("New Title")
|
|
3882
3882
|
end
|
|
3883
3883
|
|
|
3884
3884
|
it "does not add additional documents" do
|
|
@@ -3907,7 +3907,7 @@ describe Mongoid::Attributes::Nested do
|
|
|
3907
3907
|
end
|
|
3908
3908
|
|
|
3909
3909
|
it "does not delete the unmarked document" do
|
|
3910
|
-
expect(person.preferences(true).
|
|
3910
|
+
expect(person.preferences(true)[1].name).to eq("New Title")
|
|
3911
3911
|
end
|
|
3912
3912
|
end
|
|
3913
3913
|
end
|