mongoid 9.0.2 → 9.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/attributes/readonly.rb +8 -3
- data/lib/mongoid/clients/options.rb +14 -1
- data/lib/mongoid/clients/sessions.rb +1 -0
- data/lib/mongoid/criteria/queryable/selectable.rb +1 -1
- data/lib/mongoid/equality.rb +1 -0
- data/lib/mongoid/loadable.rb +72 -8
- data/lib/mongoid/matcher.rb +15 -1
- data/lib/mongoid/persistence_context.rb +14 -9
- data/lib/mongoid/railties/controller_runtime.rb +2 -2
- data/lib/mongoid/serializable.rb +7 -7
- data/lib/mongoid/threaded.rb +96 -28
- data/lib/mongoid/timestamps/timeless.rb +4 -1
- data/lib/mongoid/touchable.rb +1 -1
- data/lib/mongoid/traversable.rb +25 -2
- data/lib/mongoid/validatable/associated.rb +5 -2
- data/lib/mongoid/version.rb +1 -1
- data/spec/integration/active_job_spec.rb +24 -20
- data/spec/integration/app_spec.rb +9 -1
- data/spec/mongoid/association/referenced/belongs_to/proxy_spec.rb +4 -0
- data/spec/mongoid/attributes/readonly_spec.rb +19 -0
- data/spec/mongoid/clients/options_spec.rb +127 -2
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +29 -0
- data/spec/mongoid/equality_spec.rb +6 -0
- data/spec/mongoid/interceptable_spec.rb +12 -0
- data/spec/mongoid/interceptable_spec_models.rb +12 -0
- data/spec/mongoid/loadable_spec.rb +86 -0
- data/spec/mongoid/persistence_context_spec.rb +39 -0
- data/spec/mongoid/railties/bson_object_id_serializer_spec.rb +18 -12
- data/spec/mongoid/threaded_spec.rb +24 -5
- data/spec/mongoid/validatable/associated_spec.rb +14 -4
- data/spec/rails/controller_extension/controller_runtime_spec.rb +14 -14
- metadata +7 -8
@@ -38,12 +38,18 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
38
38
|
User.new(name: "test")
|
39
39
|
end
|
40
40
|
|
41
|
-
let(:
|
41
|
+
let(:description1) do
|
42
|
+
Description.new
|
43
|
+
end
|
44
|
+
|
45
|
+
let(:description2) do
|
42
46
|
Description.new
|
43
47
|
end
|
44
48
|
|
45
49
|
before do
|
46
|
-
user.descriptions <<
|
50
|
+
user.descriptions << description1
|
51
|
+
user.descriptions << description2
|
52
|
+
user.valid?
|
47
53
|
end
|
48
54
|
|
49
55
|
it "only validates the parent once" do
|
@@ -51,12 +57,16 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
51
57
|
end
|
52
58
|
|
53
59
|
it "adds the errors from the relation" do
|
54
|
-
user.valid?
|
55
60
|
expect(user.errors[:descriptions]).to_not be_nil
|
56
61
|
end
|
57
62
|
|
63
|
+
it 'reports all failed validations' do
|
64
|
+
errors = user.descriptions.flat_map { |d| d.errors[:details] }
|
65
|
+
expect(errors.length).to be == 2
|
66
|
+
end
|
67
|
+
|
58
68
|
it "only validates the child once" do
|
59
|
-
expect(
|
69
|
+
expect(description1).to_not be_valid
|
60
70
|
end
|
61
71
|
end
|
62
72
|
|
@@ -5,11 +5,11 @@ require "spec_helper"
|
|
5
5
|
require "mongoid/railties/controller_runtime"
|
6
6
|
|
7
7
|
describe "Mongoid::Railties::ControllerRuntime" do
|
8
|
-
|
9
|
-
|
8
|
+
CONTROLLER_RUNTIME = Mongoid::Railties::ControllerRuntime
|
9
|
+
COLLECTOR = CONTROLLER_RUNTIME::Collector
|
10
10
|
|
11
|
-
def set_metric
|
12
|
-
|
11
|
+
def set_metric(value)
|
12
|
+
Mongoid::Threaded.set(COLLECTOR::VARIABLE_NAME, value)
|
13
13
|
end
|
14
14
|
|
15
15
|
def clear_metric!
|
@@ -20,30 +20,30 @@ describe "Mongoid::Railties::ControllerRuntime" do
|
|
20
20
|
|
21
21
|
it "stores the metric in thread-safe manner" do
|
22
22
|
clear_metric!
|
23
|
-
expect(
|
23
|
+
expect(COLLECTOR.runtime).to eq(0)
|
24
24
|
set_metric 42
|
25
|
-
expect(
|
25
|
+
expect(COLLECTOR.runtime).to eq(42)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "sets metric on both succeeded and failed" do
|
29
|
-
instance =
|
29
|
+
instance = COLLECTOR.new
|
30
30
|
event_payload = OpenStruct.new duration: 42
|
31
31
|
|
32
32
|
clear_metric!
|
33
33
|
instance.succeeded event_payload
|
34
|
-
expect(
|
34
|
+
expect(COLLECTOR.runtime).to eq(42000)
|
35
35
|
|
36
36
|
clear_metric!
|
37
37
|
instance.failed event_payload
|
38
|
-
expect(
|
38
|
+
expect(COLLECTOR.runtime).to eq(42000)
|
39
39
|
end
|
40
40
|
|
41
41
|
it "resets the metric and returns the value" do
|
42
42
|
clear_metric!
|
43
|
-
expect(
|
43
|
+
expect(COLLECTOR.reset_runtime).to eq(0)
|
44
44
|
set_metric 42
|
45
|
-
expect(
|
46
|
-
expect(
|
45
|
+
expect(COLLECTOR.reset_runtime).to eq(42)
|
46
|
+
expect(COLLECTOR.runtime).to eq(0)
|
47
47
|
end
|
48
48
|
|
49
49
|
end
|
@@ -67,7 +67,7 @@ describe "Mongoid::Railties::ControllerRuntime" do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
controller_class = Class.new reference_controller_class do
|
70
|
-
include
|
70
|
+
include CONTROLLER_RUNTIME::ControllerExtension
|
71
71
|
end
|
72
72
|
|
73
73
|
let(:controller){ controller_class.new }
|
@@ -75,7 +75,7 @@ describe "Mongoid::Railties::ControllerRuntime" do
|
|
75
75
|
it "resets the metric before each action" do
|
76
76
|
set_metric 42
|
77
77
|
controller.send(:process_action, 'foo')
|
78
|
-
expect(
|
78
|
+
expect(COLLECTOR.runtime).to be(0)
|
79
79
|
expect(controller.instance_variable_get "@process_action").to be(true)
|
80
80
|
end
|
81
81
|
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 9.0.
|
4
|
+
version: 9.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The MongoDB Ruby Team
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-08 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: activemodel
|
@@ -19,7 +18,7 @@ dependencies:
|
|
19
18
|
version: '5.1'
|
20
19
|
- - "<"
|
21
20
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
21
|
+
version: '8.1'
|
23
22
|
- - "!="
|
24
23
|
- !ruby/object:Gem::Version
|
25
24
|
version: 7.0.0
|
@@ -32,7 +31,7 @@ dependencies:
|
|
32
31
|
version: '5.1'
|
33
32
|
- - "<"
|
34
33
|
- !ruby/object:Gem::Version
|
35
|
-
version: '
|
34
|
+
version: '8.1'
|
36
35
|
- - "!="
|
37
36
|
- !ruby/object:Gem::Version
|
38
37
|
version: 7.0.0
|
@@ -830,6 +829,7 @@ files:
|
|
830
829
|
- spec/mongoid/inspectable_spec.rb
|
831
830
|
- spec/mongoid/interceptable_spec.rb
|
832
831
|
- spec/mongoid/interceptable_spec_models.rb
|
832
|
+
- spec/mongoid/loadable_spec.rb
|
833
833
|
- spec/mongoid/loading_spec.rb
|
834
834
|
- spec/mongoid/loggable_spec.rb
|
835
835
|
- spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
|
@@ -1188,7 +1188,6 @@ metadata:
|
|
1188
1188
|
documentation_uri: https://www.mongodb.com/docs/mongoid/
|
1189
1189
|
homepage_uri: https://mongoid.org/
|
1190
1190
|
source_code_uri: https://github.com/mongodb/mongoid
|
1191
|
-
post_install_message:
|
1192
1191
|
rdoc_options: []
|
1193
1192
|
require_paths:
|
1194
1193
|
- lib
|
@@ -1203,8 +1202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1203
1202
|
- !ruby/object:Gem::Version
|
1204
1203
|
version: 1.3.6
|
1205
1204
|
requirements: []
|
1206
|
-
rubygems_version: 3.
|
1207
|
-
signing_key:
|
1205
|
+
rubygems_version: 3.6.2
|
1208
1206
|
specification_version: 4
|
1209
1207
|
summary: Elegant Persistence in Ruby for MongoDB.
|
1210
1208
|
test_files:
|
@@ -1552,6 +1550,7 @@ test_files:
|
|
1552
1550
|
- spec/mongoid/inspectable_spec.rb
|
1553
1551
|
- spec/mongoid/interceptable_spec.rb
|
1554
1552
|
- spec/mongoid/interceptable_spec_models.rb
|
1553
|
+
- spec/mongoid/loadable_spec.rb
|
1555
1554
|
- spec/mongoid/loading_spec.rb
|
1556
1555
|
- spec/mongoid/loggable_spec.rb
|
1557
1556
|
- spec/mongoid/matcher/extract_attribute_data/numeric_keys.yml
|