mongoid 8.0.12 → 8.1.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/CHANGELOG.md +3 -3
- data/README.md +3 -3
- data/Rakefile +17 -66
- data/lib/config/locales/en.yml +46 -14
- data/lib/mongoid/association/accessors.rb +3 -7
- data/lib/mongoid/association/builders.rb +1 -1
- data/lib/mongoid/association/eager_loadable.rb +0 -3
- data/lib/mongoid/association/embedded/batchable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/buildable.rb +2 -2
- data/lib/mongoid/association/embedded/embedded_in/proxy.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_many/buildable.rb +3 -2
- data/lib/mongoid/association/embedded/embeds_many/proxy.rb +6 -6
- data/lib/mongoid/association/embedded/embeds_one/buildable.rb +1 -1
- data/lib/mongoid/association/embedded/embeds_one/proxy.rb +2 -2
- data/lib/mongoid/association/macros.rb +0 -6
- data/lib/mongoid/association/nested/one.rb +40 -2
- data/lib/mongoid/association/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/counter_cache.rb +2 -2
- data/lib/mongoid/association/referenced/has_and_belongs_to_many/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/has_many/enumerable.rb +6 -23
- data/lib/mongoid/association/referenced/has_many/proxy.rb +3 -3
- data/lib/mongoid/association/reflections.rb +2 -2
- data/lib/mongoid/atomic.rb +7 -16
- data/lib/mongoid/attributes/dynamic.rb +1 -1
- data/lib/mongoid/attributes/nested.rb +2 -2
- data/lib/mongoid/attributes/processing.rb +5 -29
- data/lib/mongoid/attributes/projector.rb +1 -1
- data/lib/mongoid/attributes/readonly.rb +1 -1
- data/lib/mongoid/attributes.rb +8 -2
- data/lib/mongoid/changeable.rb +107 -5
- data/lib/mongoid/clients/factory.rb +0 -4
- data/lib/mongoid/clients/storage_options.rb +2 -5
- data/lib/mongoid/clients/validators/storage.rb +1 -13
- data/lib/mongoid/collection_configurable.rb +58 -0
- data/lib/mongoid/composable.rb +2 -0
- data/lib/mongoid/config/defaults.rb +60 -0
- data/lib/mongoid/config/options.rb +0 -3
- data/lib/mongoid/config/validators/async_query_executor.rb +24 -0
- data/lib/mongoid/config/validators.rb +1 -0
- data/lib/mongoid/config.rb +88 -27
- data/lib/mongoid/contextual/atomic.rb +1 -1
- data/lib/mongoid/contextual/memory.rb +233 -33
- data/lib/mongoid/contextual/mongo/documents_loader.rb +177 -0
- data/lib/mongoid/contextual/mongo.rb +370 -133
- data/lib/mongoid/contextual/none.rb +162 -7
- data/lib/mongoid/contextual.rb +12 -0
- data/lib/mongoid/criteria/findable.rb +2 -2
- data/lib/mongoid/criteria/includable.rb +4 -3
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -15
- data/lib/mongoid/criteria/queryable/key.rb +1 -1
- data/lib/mongoid/criteria/queryable/mergeable.rb +1 -1
- data/lib/mongoid/criteria/queryable/optional.rb +8 -8
- data/lib/mongoid/criteria/queryable/selectable.rb +43 -12
- data/lib/mongoid/criteria/queryable/selector.rb +1 -1
- data/lib/mongoid/criteria/queryable/storable.rb +1 -1
- data/lib/mongoid/criteria.rb +6 -5
- data/lib/mongoid/deprecable.rb +1 -2
- data/lib/mongoid/deprecation.rb +3 -3
- data/lib/mongoid/document.rb +1 -8
- data/lib/mongoid/errors/create_collection_failure.rb +33 -0
- data/lib/mongoid/errors/drop_collection_failure.rb +27 -0
- data/lib/mongoid/errors/immutable_attribute.rb +26 -0
- data/lib/mongoid/errors/invalid_async_query_executor.rb +25 -0
- data/lib/mongoid/errors/invalid_global_executor_concurrency.rb +22 -0
- data/lib/mongoid/errors/invalid_storage_parent.rb +2 -0
- data/lib/mongoid/errors.rb +4 -1
- data/lib/mongoid/extensions/hash.rb +3 -51
- data/lib/mongoid/extensions/object.rb +2 -2
- data/lib/mongoid/extensions/time.rb +2 -0
- data/lib/mongoid/fields/localized.rb +10 -0
- data/lib/mongoid/fields/standard.rb +10 -0
- data/lib/mongoid/fields.rb +59 -35
- data/lib/mongoid/findable.rb +27 -3
- data/lib/mongoid/interceptable.rb +6 -116
- data/lib/mongoid/matcher/eq_impl.rb +1 -1
- data/lib/mongoid/matcher/type.rb +1 -1
- data/lib/mongoid/persistable/creatable.rb +1 -0
- data/lib/mongoid/persistable/deletable.rb +1 -1
- data/lib/mongoid/persistable/savable.rb +13 -1
- data/lib/mongoid/persistable/unsettable.rb +2 -2
- data/lib/mongoid/persistable/updatable.rb +51 -1
- data/lib/mongoid/persistable/upsertable.rb +20 -1
- data/lib/mongoid/persistable.rb +3 -0
- data/lib/mongoid/query_cache.rb +5 -1
- data/lib/mongoid/railties/database.rake +7 -2
- data/lib/mongoid/reloadable.rb +5 -3
- data/lib/mongoid/stateful.rb +22 -1
- data/lib/mongoid/tasks/database.rake +12 -0
- data/lib/mongoid/tasks/database.rb +20 -0
- data/lib/mongoid/timestamps/created.rb +1 -8
- data/lib/mongoid/traversable.rb +0 -12
- data/lib/mongoid/utils.rb +22 -0
- data/lib/mongoid/validatable/associated.rb +17 -98
- data/lib/mongoid/validatable/macros.rb +5 -20
- data/lib/mongoid/validatable.rb +4 -10
- data/lib/mongoid/version.rb +1 -5
- data/lib/mongoid/warnings.rb +17 -1
- data/lib/mongoid.rb +16 -3
- data/spec/integration/app_spec.rb +2 -12
- data/spec/integration/associations/embeds_one_spec.rb +5 -25
- data/spec/integration/associations/has_and_belongs_to_many_spec.rb +0 -40
- data/spec/integration/callbacks_spec.rb +99 -12
- data/spec/integration/discriminator_key_spec.rb +4 -5
- data/spec/integration/i18n_fallbacks_spec.rb +3 -2
- data/spec/mongoid/association/eager_spec.rb +2 -24
- data/spec/mongoid/association/embedded/embedded_in/proxy_spec.rb +27 -0
- data/spec/mongoid/association/embedded/embeds_many/proxy_spec.rb +20 -25
- data/spec/mongoid/association/embedded/embeds_many_models.rb +1 -0
- data/spec/mongoid/association/embedded/embeds_many_query_spec.rb +0 -4
- data/spec/mongoid/association/embedded/embeds_one/proxy_spec.rb +15 -2
- data/spec/mongoid/association/referenced/belongs_to_spec.rb +2 -18
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +42 -55
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +9 -50
- data/spec/mongoid/association/syncable_spec.rb +1 -1
- data/spec/mongoid/attributes_spec.rb +3 -33
- data/spec/mongoid/changeable_spec.rb +299 -24
- data/spec/mongoid/clients/factory_spec.rb +0 -30
- data/spec/mongoid/clients_spec.rb +122 -13
- data/spec/mongoid/collection_configurable_spec.rb +158 -0
- data/spec/mongoid/config/defaults_spec.rb +160 -0
- data/spec/mongoid/config_spec.rb +154 -27
- data/spec/mongoid/contextual/memory_spec.rb +332 -76
- data/spec/mongoid/contextual/mongo/documents_loader_spec.rb +187 -0
- data/spec/mongoid/contextual/mongo_spec.rb +1009 -125
- data/spec/mongoid/contextual/none_spec.rb +49 -2
- data/spec/mongoid/copyable_spec.rb +2 -10
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +4 -10
- data/spec/mongoid/criteria/queryable/options_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +419 -0
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/selector_spec.rb +3 -76
- data/spec/mongoid/criteria/queryable/storable_spec.rb +0 -72
- data/spec/mongoid/criteria_projection_spec.rb +1 -4
- data/spec/mongoid/criteria_spec.rb +5 -9
- data/spec/mongoid/document_spec.rb +0 -27
- data/spec/mongoid/errors/readonly_document_spec.rb +2 -2
- data/spec/mongoid/extensions/hash_spec.rb +3 -239
- data/spec/mongoid/extensions/time_spec.rb +8 -43
- data/spec/mongoid/extensions/time_with_zone_spec.rb +7 -52
- data/spec/mongoid/fields/localized_spec.rb +46 -28
- data/spec/mongoid/fields_spec.rb +136 -77
- data/spec/mongoid/findable_spec.rb +391 -34
- data/spec/mongoid/indexable_spec.rb +16 -10
- data/spec/mongoid/interceptable_spec.rb +153 -442
- data/spec/mongoid/interceptable_spec_models.rb +111 -51
- data/spec/mongoid/persistable/deletable_spec.rb +26 -6
- data/spec/mongoid/persistable/destroyable_spec.rb +26 -6
- data/spec/mongoid/persistable/incrementable_spec.rb +37 -0
- data/spec/mongoid/persistable/logical_spec.rb +37 -0
- data/spec/mongoid/persistable/poppable_spec.rb +36 -0
- data/spec/mongoid/persistable/pullable_spec.rb +72 -0
- data/spec/mongoid/persistable/pushable_spec.rb +72 -0
- data/spec/mongoid/persistable/renamable_spec.rb +36 -0
- data/spec/mongoid/persistable/savable_spec.rb +96 -0
- data/spec/mongoid/persistable/settable_spec.rb +37 -0
- data/spec/mongoid/persistable/unsettable_spec.rb +36 -0
- data/spec/mongoid/persistable/updatable_spec.rb +20 -28
- data/spec/mongoid/persistable/upsertable_spec.rb +80 -6
- data/spec/mongoid/persistence_context_spec.rb +7 -57
- data/spec/mongoid/query_cache_spec.rb +56 -61
- data/spec/mongoid/reloadable_spec.rb +24 -28
- data/spec/mongoid/scopable_spec.rb +70 -0
- data/spec/mongoid/serializable_spec.rb +23 -44
- data/spec/mongoid/stateful_spec.rb +122 -8
- data/spec/mongoid/tasks/database_rake_spec.rb +74 -0
- data/spec/mongoid/tasks/database_spec.rb +127 -0
- data/spec/mongoid/timestamps/created_spec.rb +0 -23
- data/spec/mongoid/timestamps_spec.rb +9 -11
- data/spec/mongoid/touchable_spec.rb +277 -5
- data/spec/mongoid/touchable_spec_models.rb +3 -1
- data/spec/mongoid/traversable_spec.rb +9 -24
- data/spec/mongoid/validatable/associated_spec.rb +34 -27
- data/spec/mongoid/validatable/numericality_spec.rb +0 -16
- data/spec/mongoid/validatable/uniqueness_spec.rb +2 -3
- data/spec/mongoid_spec.rb +36 -10
- data/spec/shared/lib/mrss/docker_runner.rb +1 -1
- data/spec/shared/lib/mrss/server_version_registry.rb +1 -1
- data/spec/shared/lib/mrss/spec_organizer.rb +3 -32
- data/spec/shared/share/Dockerfile.erb +85 -15
- data/spec/shared/shlib/distro.sh +0 -10
- data/spec/shared/shlib/server.sh +27 -34
- data/spec/shared/shlib/set_env.sh +68 -9
- data/spec/spec_helper.rb +5 -0
- data/spec/support/expectations.rb +17 -20
- data/spec/support/immutable_ids.rb +118 -0
- data/spec/support/macros.rb +47 -15
- data/spec/support/models/artist.rb +0 -1
- data/spec/support/models/band.rb +1 -0
- data/spec/support/models/building.rb +2 -0
- data/spec/support/models/name.rb +0 -10
- data/spec/support/models/person.rb +0 -1
- data/spec/support/models/product.rb +1 -0
- data.tar.gz.sig +0 -0
- metadata +715 -662
- metadata.gz.sig +2 -0
- data/lib/mongoid/validatable/numericality.rb +0 -19
- data/spec/mongoid/criteria/queryable/extensions/bignum_spec.rb +0 -61
- data/spec/mongoid/criteria/queryable/extensions/fixnum_spec.rb +0 -61
- data/spec/shared/CANDIDATE.md +0 -28
- data/spec/shared/lib/mrss/release/candidate.rb +0 -281
- data/spec/shared/lib/mrss/release/product_data.rb +0 -144
- data/spec/shared/lib/tasks/candidate.rake +0 -64
- data/spec/support/models/purse.rb +0 -9
|
@@ -531,9 +531,9 @@ describe Mongoid::Traversable do
|
|
|
531
531
|
end
|
|
532
532
|
|
|
533
533
|
context "before class creation" do
|
|
534
|
-
|
|
535
|
-
Mongoid.discriminator_key = "test"
|
|
534
|
+
config_override :discriminator_key, "test"
|
|
536
535
|
|
|
536
|
+
before do
|
|
537
537
|
class PreGlobalDiscriminatorParent
|
|
538
538
|
include Mongoid::Document
|
|
539
539
|
end
|
|
@@ -542,10 +542,6 @@ describe Mongoid::Traversable do
|
|
|
542
542
|
end
|
|
543
543
|
end
|
|
544
544
|
|
|
545
|
-
after do
|
|
546
|
-
Mongoid.discriminator_key = "_type"
|
|
547
|
-
end
|
|
548
|
-
|
|
549
545
|
it "creates a field with new discriminator key in the parent" do
|
|
550
546
|
expect(PreGlobalDiscriminatorParent.fields.keys).to include("test")
|
|
551
547
|
end
|
|
@@ -677,9 +673,9 @@ describe Mongoid::Traversable do
|
|
|
677
673
|
end
|
|
678
674
|
|
|
679
675
|
context "before class creation" do
|
|
680
|
-
|
|
681
|
-
Mongoid.discriminator_key = :test
|
|
676
|
+
config_override :discriminator_key, :test
|
|
682
677
|
|
|
678
|
+
before do
|
|
683
679
|
class PreGlobalSymDiscriminatorParent
|
|
684
680
|
include Mongoid::Document
|
|
685
681
|
end
|
|
@@ -688,10 +684,6 @@ describe Mongoid::Traversable do
|
|
|
688
684
|
end
|
|
689
685
|
end
|
|
690
686
|
|
|
691
|
-
after do
|
|
692
|
-
Mongoid.discriminator_key = "_type"
|
|
693
|
-
end
|
|
694
|
-
|
|
695
687
|
it "creates a field with new discriminator key as a string in the parent" do
|
|
696
688
|
expect(PreGlobalSymDiscriminatorParent.fields.keys).to include("test")
|
|
697
689
|
end
|
|
@@ -829,8 +821,9 @@ describe Mongoid::Traversable do
|
|
|
829
821
|
end
|
|
830
822
|
|
|
831
823
|
context "when setting a field equal to discriminator key and duplicate_fields_exception is true" do
|
|
824
|
+
config_override :duplicate_fields_exception, true
|
|
825
|
+
|
|
832
826
|
before do
|
|
833
|
-
Mongoid.duplicate_fields_exception = true
|
|
834
827
|
|
|
835
828
|
class DuplicateDiscriminatorKeyParent
|
|
836
829
|
include Mongoid::Document
|
|
@@ -841,10 +834,6 @@ describe Mongoid::Traversable do
|
|
|
841
834
|
end
|
|
842
835
|
end
|
|
843
836
|
|
|
844
|
-
after do
|
|
845
|
-
Mongoid.duplicate_fields_exception = false
|
|
846
|
-
end
|
|
847
|
-
|
|
848
837
|
it "does not raise an error" do
|
|
849
838
|
expect do
|
|
850
839
|
DuplicateDiscriminatorKeyParent.discriminator_key = "dkey"
|
|
@@ -871,9 +860,10 @@ describe Mongoid::Traversable do
|
|
|
871
860
|
end
|
|
872
861
|
|
|
873
862
|
context "when setting a field equal to global discriminator key and duplicate_fields_exception is true" do
|
|
863
|
+
config_override :duplicate_fields_exception, true
|
|
864
|
+
config_override :discriminator_key, "dkey"
|
|
865
|
+
|
|
874
866
|
before do
|
|
875
|
-
Mongoid.duplicate_fields_exception = true
|
|
876
|
-
Mongoid.discriminator_key = "dkey"
|
|
877
867
|
|
|
878
868
|
class GlobalDuplicateDiscriminatorKeyParent
|
|
879
869
|
include Mongoid::Document
|
|
@@ -883,11 +873,6 @@ describe Mongoid::Traversable do
|
|
|
883
873
|
end
|
|
884
874
|
end
|
|
885
875
|
|
|
886
|
-
after do
|
|
887
|
-
Mongoid.duplicate_fields_exception = false
|
|
888
|
-
Mongoid.discriminator_key = "_type"
|
|
889
|
-
end
|
|
890
|
-
|
|
891
876
|
it "raises an error" do
|
|
892
877
|
expect do
|
|
893
878
|
GlobalDuplicateDiscriminatorKeyParent.class_eval do
|
|
@@ -37,18 +37,12 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
37
37
|
User.new(name: "test")
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
let(:
|
|
41
|
-
Description.new
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
let(:description2) do
|
|
40
|
+
let(:description) do
|
|
45
41
|
Description.new
|
|
46
42
|
end
|
|
47
43
|
|
|
48
44
|
before do
|
|
49
|
-
user.descriptions <<
|
|
50
|
-
user.descriptions << description2
|
|
51
|
-
user.valid?
|
|
45
|
+
user.descriptions << description
|
|
52
46
|
end
|
|
53
47
|
|
|
54
48
|
it "only validates the parent once" do
|
|
@@ -56,16 +50,12 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
56
50
|
end
|
|
57
51
|
|
|
58
52
|
it "adds the errors from the relation" do
|
|
53
|
+
user.valid?
|
|
59
54
|
expect(user.errors[:descriptions]).to_not be_nil
|
|
60
55
|
end
|
|
61
56
|
|
|
62
|
-
it 'reports all failed validations' do
|
|
63
|
-
errors = user.descriptions.flat_map { |d| d.errors[:details] }
|
|
64
|
-
expect(errors.length).to be == 2
|
|
65
|
-
end
|
|
66
|
-
|
|
67
57
|
it "only validates the child once" do
|
|
68
|
-
expect(
|
|
58
|
+
expect(description).to_not be_valid
|
|
69
59
|
end
|
|
70
60
|
end
|
|
71
61
|
|
|
@@ -85,6 +75,7 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
85
75
|
end
|
|
86
76
|
|
|
87
77
|
it "does not run validation on them" do
|
|
78
|
+
expect(description).to receive(:valid?).never
|
|
88
79
|
expect(user).to be_valid
|
|
89
80
|
end
|
|
90
81
|
|
|
@@ -93,14 +84,14 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
93
84
|
end
|
|
94
85
|
end
|
|
95
86
|
|
|
96
|
-
describe "#
|
|
87
|
+
describe "#validate_each" do
|
|
97
88
|
|
|
98
89
|
let(:person) do
|
|
99
90
|
Person.new
|
|
100
91
|
end
|
|
101
92
|
|
|
102
93
|
let(:validator) do
|
|
103
|
-
described_class.new(attributes: person.
|
|
94
|
+
described_class.new(attributes: person.attributes)
|
|
104
95
|
end
|
|
105
96
|
|
|
106
97
|
context "when the association is a one to one" do
|
|
@@ -108,7 +99,7 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
108
99
|
context "when the association is nil" do
|
|
109
100
|
|
|
110
101
|
before do
|
|
111
|
-
validator.
|
|
102
|
+
validator.validate_each(person, :name, nil)
|
|
112
103
|
end
|
|
113
104
|
|
|
114
105
|
it "adds no errors" do
|
|
@@ -117,9 +108,14 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
117
108
|
end
|
|
118
109
|
|
|
119
110
|
context "when the association is valid" do
|
|
111
|
+
|
|
112
|
+
let(:associated) do
|
|
113
|
+
double(valid?: true, flagged_for_destroy?: false)
|
|
114
|
+
end
|
|
115
|
+
|
|
120
116
|
before do
|
|
121
|
-
|
|
122
|
-
validator.
|
|
117
|
+
expect(associated).to receive(:validated?).and_return(false)
|
|
118
|
+
validator.validate_each(person, :name, associated)
|
|
123
119
|
end
|
|
124
120
|
|
|
125
121
|
it "adds no errors" do
|
|
@@ -129,9 +125,13 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
129
125
|
|
|
130
126
|
context "when the association is invalid" do
|
|
131
127
|
|
|
128
|
+
let(:associated) do
|
|
129
|
+
double(valid?: false, flagged_for_destroy?: false)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
132
|
before do
|
|
133
|
-
|
|
134
|
-
validator.
|
|
133
|
+
expect(associated).to receive(:validated?).and_return(false)
|
|
134
|
+
validator.validate_each(person, :name, associated)
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "adds errors to the parent document" do
|
|
@@ -149,7 +149,7 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
149
149
|
context "when the association is empty" do
|
|
150
150
|
|
|
151
151
|
before do
|
|
152
|
-
validator.
|
|
152
|
+
validator.validate_each(person, :addresses, [])
|
|
153
153
|
end
|
|
154
154
|
|
|
155
155
|
it "adds no errors" do
|
|
@@ -159,9 +159,13 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
159
159
|
|
|
160
160
|
context "when the association has invalid documents" do
|
|
161
161
|
|
|
162
|
+
let(:associated) do
|
|
163
|
+
double(valid?: false, flagged_for_destroy?: false)
|
|
164
|
+
end
|
|
165
|
+
|
|
162
166
|
before do
|
|
163
|
-
|
|
164
|
-
validator.
|
|
167
|
+
expect(associated).to receive(:validated?).and_return(false)
|
|
168
|
+
validator.validate_each(person, :addresses, [ associated ])
|
|
165
169
|
end
|
|
166
170
|
|
|
167
171
|
it "adds errors to the parent document" do
|
|
@@ -171,10 +175,13 @@ describe Mongoid::Validatable::AssociatedValidator do
|
|
|
171
175
|
|
|
172
176
|
context "when the association has all valid documents" do
|
|
173
177
|
|
|
178
|
+
let(:associated) do
|
|
179
|
+
double(valid?: true, flagged_for_destroy?: false)
|
|
180
|
+
end
|
|
181
|
+
|
|
174
182
|
before do
|
|
175
|
-
|
|
176
|
-
person
|
|
177
|
-
validator.validate(person)
|
|
183
|
+
expect(associated).to receive(:validated?).and_return(false)
|
|
184
|
+
validator.validate_each(person, :addresses, [ associated ])
|
|
178
185
|
end
|
|
179
186
|
|
|
180
187
|
it "adds no errors" do
|
|
@@ -28,21 +28,5 @@ describe ActiveModel::Validations::NumericalityValidator do
|
|
|
28
28
|
expect(model).to_not be_valid
|
|
29
29
|
end
|
|
30
30
|
end
|
|
31
|
-
|
|
32
|
-
context 'when the value is numeric' do
|
|
33
|
-
let(:model) { TestModel.new(amount: '15.0') }
|
|
34
|
-
|
|
35
|
-
it 'returns true' do
|
|
36
|
-
expect(model).to be_valid
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
context 'when the value is a BSON::Decimal128' do
|
|
41
|
-
let(:model) { TestModel.new(amount: BSON::Decimal128.new('15.0')) }
|
|
42
|
-
|
|
43
|
-
it 'returns true' do
|
|
44
|
-
expect(model).to be_valid
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
31
|
end
|
|
48
32
|
end
|
|
@@ -2476,11 +2476,10 @@ describe Mongoid::Validatable::UniquenessValidator do
|
|
|
2476
2476
|
describe "i18n" do
|
|
2477
2477
|
|
|
2478
2478
|
context 'when using a different locale' do
|
|
2479
|
-
|
|
2480
|
-
I18n.with_locale(:fr) { example.run }
|
|
2481
|
-
end
|
|
2479
|
+
with_default_i18n_configs
|
|
2482
2480
|
|
|
2483
2481
|
before do
|
|
2482
|
+
I18n.locale = :fr
|
|
2484
2483
|
# Translation key location is as per rails-i18n gem.
|
|
2485
2484
|
# See: https://github.com/svenfuchs/rails-i18n/blob/master/rails/locale/en.yml
|
|
2486
2485
|
I18n.backend.store_translations(:fr, { errors: { messages: { taken: 'est déjà utilisé(e)' } } })
|
data/spec/mongoid_spec.rb
CHANGED
|
@@ -13,22 +13,46 @@ describe Mongoid do
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
context "when a block is
|
|
16
|
+
context "when a block is given" do
|
|
17
|
+
config_override :preload_models, false
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
context "with arity 0" do
|
|
20
|
+
|
|
21
|
+
before do
|
|
22
|
+
Mongoid.configure do
|
|
23
|
+
config.preload_models = true
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "sets the values on the config instance" do
|
|
28
|
+
expect(Mongoid.preload_models).to be true
|
|
21
29
|
end
|
|
22
30
|
end
|
|
23
31
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
context "with arity 1" do
|
|
33
|
+
|
|
34
|
+
before do
|
|
35
|
+
Mongoid.configure do |config|
|
|
36
|
+
config.preload_models = true
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "sets the values on the config instance" do
|
|
41
|
+
expect(Mongoid.preload_models).to be true
|
|
27
42
|
end
|
|
28
43
|
end
|
|
29
44
|
|
|
30
|
-
|
|
31
|
-
|
|
45
|
+
context "with arity 2" do
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
Mongoid.configure do |config, _other|
|
|
49
|
+
config.preload_models = true
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "sets the values on the config instance" do
|
|
54
|
+
expect(Mongoid.preload_models).to be true
|
|
55
|
+
end
|
|
32
56
|
end
|
|
33
57
|
end
|
|
34
58
|
end
|
|
@@ -51,8 +75,10 @@ describe Mongoid do
|
|
|
51
75
|
end
|
|
52
76
|
|
|
53
77
|
it "disconnects from all active clients" do
|
|
78
|
+
pending 'https://jira.mongodb.org/browse/MONGOID-5621'
|
|
79
|
+
|
|
54
80
|
clients.each do |client|
|
|
55
|
-
expect(client).to receive(:
|
|
81
|
+
expect(client.cluster).to receive(:disconnect!).and_call_original
|
|
56
82
|
end
|
|
57
83
|
Mongoid.disconnect_clients
|
|
58
84
|
end
|
|
@@ -25,19 +25,19 @@ module Mrss
|
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def initialize(root: nil, classifiers:, priority_order:,
|
|
28
|
-
spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil,
|
|
28
|
+
spec_root: nil, rspec_json_path: nil, rspec_all_json_path: nil,
|
|
29
|
+
randomize: false
|
|
29
30
|
)
|
|
30
31
|
@spec_root = spec_root || File.join(root, 'spec')
|
|
31
32
|
@classifiers = classifiers
|
|
32
33
|
@priority_order = priority_order
|
|
33
34
|
@rspec_json_path = rspec_json_path || File.join(root, 'tmp/rspec.json')
|
|
34
35
|
@rspec_all_json_path = rspec_all_json_path || File.join(root, 'tmp/rspec-all.json')
|
|
35
|
-
@rspec_xml_path = rspec_xml_path || File.join(root, 'tmp/rspec.xml')
|
|
36
36
|
@randomize = !!randomize
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
attr_reader :spec_root, :classifiers, :priority_order
|
|
40
|
-
attr_reader :rspec_json_path, :rspec_all_json_path
|
|
40
|
+
attr_reader :rspec_json_path, :rspec_all_json_path
|
|
41
41
|
|
|
42
42
|
def randomize?
|
|
43
43
|
@randomize
|
|
@@ -47,25 +47,6 @@ module Mrss
|
|
|
47
47
|
@seed ||= (rand * 100_000).to_i
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
# Remove all XML files from tmp directory before running tests
|
|
51
|
-
def cleanup_xml_files
|
|
52
|
-
xml_pattern = File.join(File.dirname(rspec_xml_path), '*.xml')
|
|
53
|
-
Dir.glob(xml_pattern).each do |xml_file|
|
|
54
|
-
FileUtils.rm_f(xml_file)
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# Move the XML file to a timestamped version for evergreen upload
|
|
59
|
-
def archive_xml_file(category)
|
|
60
|
-
return unless File.exist?(rspec_xml_path)
|
|
61
|
-
|
|
62
|
-
timestamp = Time.now.strftime('%Y%m%d_%H%M%S_%3N')
|
|
63
|
-
archived_path = rspec_xml_path.sub(/\.xml$/, "-#{category}-#{timestamp}.xml")
|
|
64
|
-
|
|
65
|
-
FileUtils.mv(rspec_xml_path, archived_path)
|
|
66
|
-
puts "Archived XML results to #{archived_path}"
|
|
67
|
-
end
|
|
68
|
-
|
|
69
50
|
def buckets
|
|
70
51
|
@buckets ||= {}.tap do |buckets|
|
|
71
52
|
Find.find(spec_root) do |path|
|
|
@@ -115,8 +96,6 @@ module Mrss
|
|
|
115
96
|
|
|
116
97
|
def run_buckets(*buckets)
|
|
117
98
|
FileUtils.rm_f(rspec_all_json_path)
|
|
118
|
-
# Clean up all XML files before starting test runs
|
|
119
|
-
cleanup_xml_files
|
|
120
99
|
|
|
121
100
|
buckets.each do |bucket|
|
|
122
101
|
if bucket && !self.buckets[bucket]
|
|
@@ -152,12 +131,7 @@ module Mrss
|
|
|
152
131
|
def run_files(category, paths)
|
|
153
132
|
puts "Running #{category.to_s.gsub('_', ' ')} tests"
|
|
154
133
|
FileUtils.rm_f(rspec_json_path)
|
|
155
|
-
FileUtils.rm_f(rspec_xml_path) # Clean up XML file before running this bucket
|
|
156
|
-
|
|
157
134
|
cmd = %w(rspec) + paths
|
|
158
|
-
# Add junit formatter for XML output
|
|
159
|
-
cmd += ['--format', 'Rfc::Riff', '--format', 'RspecJunitFormatter', '--out', rspec_xml_path]
|
|
160
|
-
|
|
161
135
|
if randomize?
|
|
162
136
|
cmd += %W(--order rand:#{seed})
|
|
163
137
|
end
|
|
@@ -173,9 +147,6 @@ module Mrss
|
|
|
173
147
|
FileUtils.cp(rspec_json_path, rspec_all_json_path)
|
|
174
148
|
end
|
|
175
149
|
end
|
|
176
|
-
|
|
177
|
-
# Archive XML file after running this bucket
|
|
178
|
-
archive_xml_file(category)
|
|
179
150
|
end
|
|
180
151
|
|
|
181
152
|
true
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
+
# Python toolchain as of this writing is available on rhel62, debian92 and
|
|
2
|
+
# ubuntu1604.
|
|
3
|
+
#
|
|
4
|
+
# To run rhel62 in docker, host system must be configured to emulate syscalls:
|
|
5
|
+
# https://github.com/CentOS/sig-cloud-instance-images/issues/103
|
|
6
|
+
|
|
1
7
|
<%
|
|
2
8
|
|
|
9
|
+
python_toolchain_url = "https://s3.amazonaws.com//mciuploads/mongo-python-driver-toolchain/#{distro}/ba92de2700c04ee2d4f82c3ffdfc33105140cb04/mongo_python_driver_toolchain_#{distro.gsub('-', '_')}_ba92de2700c04ee2d4f82c3ffdfc33105140cb04_19_11_14_15_33_33.tar.gz"
|
|
10
|
+
# server_version = '4.3.3'
|
|
11
|
+
server_url = "http://downloads.10gen.com/linux/mongodb-linux-x86_64-enterprise-#{distro}-#{server_version}.tgz"
|
|
12
|
+
server_archive_basename = File.basename(server_url)
|
|
13
|
+
server_extracted_dir = server_archive_basename.sub(/\.(tar\.gz|tgz)$/, '')
|
|
14
|
+
|
|
15
|
+
# When changing, also update the hash in shlib/set_env.sh.
|
|
16
|
+
TOOLCHAIN_VERSION='e8c60866f54bed7e336a37df3a97d6ae1b971b7d'
|
|
17
|
+
|
|
3
18
|
def ruby_toolchain_url(ruby)
|
|
4
|
-
"http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-
|
|
19
|
+
"http://boxes.10gen.com/build/toolchain-drivers/mongo-ruby-driver/#{TOOLCHAIN_VERSION}/#{distro}/#{ruby}.tar.xz"
|
|
5
20
|
end
|
|
6
21
|
|
|
22
|
+
#ruby_toolchain_url = "https://s3.amazonaws.com//mciuploads/mongo-ruby-toolchain/#{distro}/#{TOOLCHAIN_VERSION}/mongo_ruby_driver_toolchain_#{distro.gsub('-', '_')}_patch_#{TOOLCHAIN_VERSION}_#{toolchain_lower}.tar.gz"
|
|
23
|
+
|
|
7
24
|
%>
|
|
8
25
|
|
|
9
26
|
FROM <%= base_image %>
|
|
@@ -20,6 +37,18 @@ ENV DOCKER=1
|
|
|
20
37
|
|
|
21
38
|
<% end %>
|
|
22
39
|
|
|
40
|
+
<% if ruby_head? %>
|
|
41
|
+
|
|
42
|
+
# To use current versions of mlaunch, Python 3.7+ is required.
|
|
43
|
+
# Many distros ship with older Pythons, therefore we need to install
|
|
44
|
+
# a newer Python from somewhere. This section installs the Python
|
|
45
|
+
# toolchain which comes with recent Pythons.
|
|
46
|
+
|
|
47
|
+
#RUN curl --retry 3 -fL <%= python_toolchain_url %> -o python-toolchain.tar.gz
|
|
48
|
+
#RUN tar -xC /opt -zf python-toolchain.tar.gz
|
|
49
|
+
|
|
50
|
+
<% end %>
|
|
51
|
+
|
|
23
52
|
<% if debian? %>
|
|
24
53
|
|
|
25
54
|
# zsh is not required for any scripts but it is a better interactive shell
|
|
@@ -27,7 +56,7 @@ ENV DOCKER=1
|
|
|
27
56
|
# Ruby runtime dependencies: libyaml-0-2
|
|
28
57
|
# Compiling ruby libraries: gcc make
|
|
29
58
|
# Compiling python packages: python3-dev
|
|
30
|
-
# JRuby: openjdk-
|
|
59
|
+
# JRuby: openjdk-8-jdk-headless
|
|
31
60
|
# Server dependencies: libsnmp30 libcurl3/libcurl4
|
|
32
61
|
# Determining OS we are running on: lsb-release
|
|
33
62
|
# Load balancer testing: haproxy
|
|
@@ -49,11 +78,11 @@ ENV DOCKER=1
|
|
|
49
78
|
|
|
50
79
|
<% packages = %w(
|
|
51
80
|
procps lsb-release bzip2 curl wget gpg zsh
|
|
52
|
-
git make gcc
|
|
81
|
+
git make gcc libyaml-0-2 libgmp-dev zlib1g-dev libsnappy-dev
|
|
53
82
|
krb5-user krb5-kdc krb5-admin-server libsasl2-dev libsasl2-modules-gssapi-mit
|
|
54
|
-
haproxy
|
|
55
|
-
|
|
56
|
-
|
|
83
|
+
haproxy
|
|
84
|
+
python3-pip
|
|
85
|
+
tzdata shared-mime-info software-properties-common
|
|
57
86
|
) %>
|
|
58
87
|
|
|
59
88
|
<% if distro =~ /ubuntu2004/ %>
|
|
@@ -72,6 +101,26 @@ ENV DOCKER=1
|
|
|
72
101
|
<% packages << 'python3-venv' %>
|
|
73
102
|
<% end %>
|
|
74
103
|
|
|
104
|
+
<% if distro =~ /debian10|ubuntu2204|debian11/ %>
|
|
105
|
+
<% packages << 'openjdk-11-jdk-headless' %>
|
|
106
|
+
<% elsif distro =~ /ubuntu1404/ %>
|
|
107
|
+
# Ubuntu 14.04 only has openjdk 7, this is too old to be useful
|
|
108
|
+
<% else %>
|
|
109
|
+
<% packages << 'openjdk-8-jdk-headless' %>
|
|
110
|
+
<% end %>
|
|
111
|
+
|
|
112
|
+
# ubuntu1404, ubuntu1604: libcurl3
|
|
113
|
+
# ubuntu1804, ubuntu2004, debian10: libcurl4
|
|
114
|
+
<% if distro =~ /ubuntu1804|ubuntu2004|ubuntu2204|debian10|debian11/ %>
|
|
115
|
+
<% packages << 'libcurl4' %>
|
|
116
|
+
<% else %>
|
|
117
|
+
<% packages << 'libcurl3' %>
|
|
118
|
+
<% end %>
|
|
119
|
+
|
|
120
|
+
<% if distro =~ /ubuntu1804|ubuntu2004|ubuntu2204/ %>
|
|
121
|
+
<% packages << 'nodejs' %>
|
|
122
|
+
<% end %>
|
|
123
|
+
|
|
75
124
|
<% if distro =~ /ubuntu2004|ubuntu2204/ %>
|
|
76
125
|
<% packages += %w(ruby bundler) %>
|
|
77
126
|
<% end %>
|
|
@@ -82,11 +131,33 @@ ENV DOCKER=1
|
|
|
82
131
|
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
|
|
83
132
|
RUN echo "deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/kitware.list >/dev/null
|
|
84
133
|
<% end %>
|
|
85
|
-
RUN apt-
|
|
86
|
-
|
|
87
|
-
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
|
|
134
|
+
RUN apt-get update && apt-get install -y cmake
|
|
135
|
+
|
|
88
136
|
<% else %>
|
|
89
137
|
|
|
138
|
+
<% if distro =~ /rhel6/ %>
|
|
139
|
+
|
|
140
|
+
# CentOS 6 is dead - to use it retrieve the packages from vault:
|
|
141
|
+
# https://stackoverflow.com/questions/53562691/error-cannot-retrieve-repository-metadata-repomd-xml-for-repository-base-pl
|
|
142
|
+
|
|
143
|
+
<%
|
|
144
|
+
|
|
145
|
+
cfg = <<-CFG
|
|
146
|
+
[base]
|
|
147
|
+
name=CentOS-$releasever - Base
|
|
148
|
+
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
|
|
149
|
+
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
|
|
150
|
+
baseurl=http://vault.centos.org/6.10/os/x86_64/
|
|
151
|
+
gpgcheck=1
|
|
152
|
+
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
|
|
153
|
+
CFG
|
|
154
|
+
|
|
155
|
+
%>
|
|
156
|
+
|
|
157
|
+
RUN printf "<%= cfg.gsub("\n", "\\n") %>" >/etc/yum.repos.d/CentOS-Base.repo
|
|
158
|
+
|
|
159
|
+
<% end %>
|
|
160
|
+
|
|
90
161
|
# Enterprise server: net-snmp
|
|
91
162
|
# lsb_release: redhat-lsb-core
|
|
92
163
|
# our runner scripts: which
|
|
@@ -95,15 +166,15 @@ ENV DOCKER=1
|
|
|
95
166
|
# Kerberos tests: krb5-workstation + cyrus-sasl-devel to build the
|
|
96
167
|
# mongo_kerberos gem + cyrus-sasl-gssapi for authentication to work
|
|
97
168
|
# Local Kerberos server: krb5-server
|
|
98
|
-
# JRuby: java-
|
|
169
|
+
# JRuby: java-1.8.0-openjdk
|
|
99
170
|
#
|
|
100
171
|
# Note: lacking cyrus-sasl-gssapi produces a cryptic message
|
|
101
172
|
# "SASL(-4): no mechanism available: No worthy mechs found"
|
|
102
173
|
# https://github.com/farorm/python-ad/issues/10
|
|
103
174
|
|
|
104
|
-
RUN yum
|
|
105
|
-
krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-
|
|
106
|
-
net-snmp python38 python38-devel cmake nodejs
|
|
175
|
+
RUN yum install -y redhat-lsb-core which git gcc libyaml krb5-server \
|
|
176
|
+
krb5-workstation cyrus-sasl-devel cyrus-sasl-gssapi java-1.8.0-openjdk \
|
|
177
|
+
net-snmp python38 python38-devel cmake nodejs
|
|
107
178
|
|
|
108
179
|
<% end %>
|
|
109
180
|
|
|
@@ -177,6 +248,7 @@ ENV DOCKER=1
|
|
|
177
248
|
RUN curl --retry 3 -fL <%= ruby_toolchain_url(ruby) %> |tar -xC /opt -Jf -
|
|
178
249
|
ENV PATH=/opt/rubies/<%= ruby %>/bin:$PATH \
|
|
179
250
|
USE_OPT_TOOLCHAIN=1
|
|
251
|
+
#ENV PATH=/opt/rubies/python/3/bin:$PATH
|
|
180
252
|
|
|
181
253
|
<% end %>
|
|
182
254
|
|
|
@@ -219,8 +291,6 @@ WORKDIR /app
|
|
|
219
291
|
ENV DOCKER_PRELOAD=1
|
|
220
292
|
<% end %>
|
|
221
293
|
|
|
222
|
-
RUN npm install --global yarn
|
|
223
|
-
|
|
224
294
|
ENV MONGO_ORCHESTRATION_HOME=/tmpfs \
|
|
225
295
|
PROJECT_DIRECTORY=/app \
|
|
226
296
|
<%= @env.map { |k, v| %Q`#{k}="#{v.gsub('$', "\\$").gsub('"', "\\\"")}"` }.join(" \\\n ") %>
|
data/spec/shared/shlib/distro.sh
CHANGED
|
@@ -64,16 +64,6 @@ _detect_distro() {
|
|
|
64
64
|
release=`echo $release |sed -e s/7/70/ -e s/6/62/ -e s/8/80/`
|
|
65
65
|
distro=rhel$release
|
|
66
66
|
fi
|
|
67
|
-
elif test -f /etc/os-release; then
|
|
68
|
-
name=`grep -o '^NAME=.*' /etc/os-release | awk -F '"' '{ print $2 }'`
|
|
69
|
-
version=`grep -o '^VERSION=.*' /etc/os-release | awk -F '"' '{ print $2 }'`
|
|
70
|
-
if test "$name" = "Amazon Linux"; then
|
|
71
|
-
distro=amazon$version
|
|
72
|
-
else
|
|
73
|
-
cat /etc/os-release
|
|
74
|
-
echo 'Unknown distro' 1>&2
|
|
75
|
-
exit 1
|
|
76
|
-
fi
|
|
77
67
|
else
|
|
78
68
|
lsb_release -a
|
|
79
69
|
echo 'Unknown distro' 1>&2
|