mongoid 7.1.1 → 7.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongoid/association/embedded/embeds_many.rb +2 -1
  5. data/lib/mongoid/association/embedded/embeds_one.rb +2 -1
  6. data/lib/mongoid/association/proxy.rb +1 -1
  7. data/lib/mongoid/atomic.rb +13 -3
  8. data/lib/mongoid/criteria.rb +7 -1
  9. data/lib/mongoid/criteria/modifiable.rb +2 -1
  10. data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
  11. data/lib/mongoid/criteria/queryable/extensions/regexp.rb +3 -3
  12. data/lib/mongoid/criteria/queryable/mergeable.rb +75 -8
  13. data/lib/mongoid/criteria/queryable/selectable.rb +28 -8
  14. data/lib/mongoid/extensions/hash.rb +4 -2
  15. data/lib/mongoid/extensions/regexp.rb +1 -1
  16. data/lib/mongoid/fields.rb +2 -1
  17. data/lib/mongoid/matchable/regexp.rb +2 -2
  18. data/lib/mongoid/persistable/pushable.rb +4 -1
  19. data/lib/mongoid/persistence_context.rb +6 -6
  20. data/lib/mongoid/query_cache.rb +2 -1
  21. data/lib/mongoid/validatable/uniqueness.rb +1 -1
  22. data/lib/mongoid/version.rb +1 -1
  23. data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
  24. data/spec/integration/app_spec.rb +192 -0
  25. data/spec/integration/associations/embedded_spec.rb +54 -0
  26. data/spec/integration/criteria/logical_spec.rb +13 -0
  27. data/spec/lite_spec_helper.rb +11 -4
  28. data/spec/mongoid/association/embedded/embeds_many_models.rb +19 -0
  29. data/spec/mongoid/association/embedded/embeds_many_spec.rb +10 -0
  30. data/spec/mongoid/association/embedded/embeds_one_spec.rb +0 -2
  31. data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +2 -1
  32. data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +2 -1
  33. data/spec/mongoid/clients/options_spec.rb +2 -2
  34. data/spec/mongoid/clients/sessions_spec.rb +8 -4
  35. data/spec/mongoid/clients/transactions_spec.rb +20 -8
  36. data/spec/mongoid/clients_spec.rb +2 -2
  37. data/spec/mongoid/contextual/atomic_spec.rb +22 -11
  38. data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
  39. data/spec/mongoid/contextual/mongo_spec.rb +76 -53
  40. data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
  41. data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +1 -1
  42. data/spec/mongoid/criteria/queryable/mergeable_spec.rb +45 -12
  43. data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +480 -198
  44. data/spec/mongoid/criteria_spec.rb +4 -2
  45. data/spec/mongoid/document_persistence_context_spec.rb +33 -0
  46. data/spec/mongoid/indexable_spec.rb +6 -4
  47. data/spec/mongoid/matchable/default_spec.rb +1 -1
  48. data/spec/mongoid/matchable/regexp_spec.rb +2 -2
  49. data/spec/mongoid/matchable_spec.rb +2 -2
  50. data/spec/mongoid/query_cache_spec.rb +2 -1
  51. data/spec/mongoid/relations/proxy_spec.rb +1 -1
  52. data/spec/mongoid/scopable_spec.rb +2 -1
  53. data/spec/mongoid/shardable_models.rb +1 -1
  54. data/spec/mongoid/shardable_spec.rb +2 -2
  55. data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
  56. data/spec/mongoid/tasks/database_spec.rb +1 -1
  57. data/spec/spec_helper.rb +0 -31
  58. data/spec/support/child_process_helper.rb +76 -0
  59. data/spec/support/cluster_config.rb +3 -3
  60. data/spec/support/constraints.rb +26 -10
  61. data/spec/support/spec_config.rb +12 -4
  62. metadata +8 -2
  63. metadata.gz.sig +0 -0
@@ -5,11 +5,11 @@ module Constraints
5
5
  RAILS_VERSION = ActiveSupport.version.to_s.split('.')[0..1].join('.').freeze
6
6
 
7
7
  def min_rails_version(version)
8
- unless version =~ /^\d+\.\d+$/
8
+ unless version =~ /\A\d+\.\d+\z/
9
9
  raise ArgumentError, "Version can only be major.minor: #{version}"
10
10
  end
11
11
 
12
- before do
12
+ before(:all) do
13
13
  if version > RAILS_VERSION
14
14
  skip "Rails version #{version} or higher required, we have #{RAILS_VERSION}"
15
15
  end
@@ -17,11 +17,11 @@ module Constraints
17
17
  end
18
18
 
19
19
  def max_rails_version(version)
20
- unless version =~ /^\d+\.\d+$/
20
+ unless version =~ /\A\d+\.\d+\z/
21
21
  raise ArgumentError, "Version can only be major.minor: #{version}"
22
22
  end
23
23
 
24
- before do
24
+ before(:all) do
25
25
  if version < RAILS_VERSION
26
26
  skip "Rails version #{version} or lower required, we have #{RAILS_VERSION}"
27
27
  end
@@ -29,11 +29,11 @@ module Constraints
29
29
  end
30
30
 
31
31
  def min_server_version(version)
32
- unless version =~ /^\d+\.\d+$/
32
+ unless version =~ /\A\d+\.\d+\z/
33
33
  raise ArgumentError, "Version can only be major.minor: #{version}"
34
34
  end
35
35
 
36
- before do
36
+ before(:all) do
37
37
  if version > ClusterConfig.instance.server_version
38
38
  skip "Server version #{version} or higher required, we have #{ClusterConfig.instance.server_version}"
39
39
  end
@@ -41,11 +41,11 @@ module Constraints
41
41
  end
42
42
 
43
43
  def max_server_version(version)
44
- unless version =~ /^\d+\.\d+$/
44
+ unless version =~ /\A\d+\.\d+\z/
45
45
  raise ArgumentError, "Version can only be major.minor: #{version}"
46
46
  end
47
47
 
48
- before do
48
+ before(:all) do
49
49
  if version < ClusterConfig.instance.short_server_version
50
50
  skip "Server version #{version} or lower required, we have #{ClusterConfig.instance.server_version}"
51
51
  end
@@ -54,9 +54,11 @@ module Constraints
54
54
 
55
55
  def require_topology(*topologies)
56
56
  invalid_topologies = topologies - [:single, :replica_set, :sharded]
57
+
57
58
  unless invalid_topologies.empty?
58
59
  raise ArgumentError, "Invalid topologies requested: #{invalid_topologies.join(', ')}"
59
60
  end
61
+
60
62
  before(:all) do
61
63
  unless topologies.include?(topology = ClusterConfig.instance.topology)
62
64
  skip "Topology #{topologies.join(' or ')} required, we have #{topology}"
@@ -73,8 +75,22 @@ module Constraints
73
75
  end
74
76
 
75
77
  def require_transaction_support
76
- min_server_fcv '4.0'
77
- require_topology :replica_set
78
+ before(:all) do
79
+ case ClusterConfig.instance.topology
80
+ when :single
81
+ skip 'Transactions tests require a replica set (4.0+) or a sharded cluster (4.2+)'
82
+ when :replica_set
83
+ unless ClusterConfig.instance.server_version >= '4.0'
84
+ skip 'Transactions tests in a replica set topology require server 4.0+'
85
+ end
86
+ when :sharded
87
+ unless ClusterConfig.instance.server_version >= '4.2'
88
+ skip 'Transactions tests in a sharded cluster topology require server 4.2+'
89
+ end
90
+ else
91
+ raise NotImplementedError
92
+ end
93
+ end
78
94
  end
79
95
 
80
96
  def require_tls
@@ -8,13 +8,17 @@ class SpecConfig
8
8
 
9
9
  def initialize
10
10
  if ENV['MONGODB_URI']
11
- @mongodb_uri = Mongo::URI.new(ENV['MONGODB_URI'])
11
+ @uri_str = ENV['MONGODB_URI']
12
+ @uri = Mongo::URI.new(@uri_str)
12
13
  end
13
14
  end
14
15
 
16
+ attr_reader :uri_str
17
+ attr_reader :uri
18
+
15
19
  def addresses
16
- if @mongodb_uri
17
- @mongodb_uri.servers
20
+ if @uri
21
+ @uri.servers
18
22
  else
19
23
  ['127.0.0.1']
20
24
  end
@@ -33,7 +37,11 @@ class SpecConfig
33
37
  end
34
38
 
35
39
  def client_debug?
36
- %w(1 true yes).include?((ENV['CLIENT_DEBUG'] || '').downcase)
40
+ %w(1 true yes).include?(ENV['CLIENT_DEBUG']&.downcase)
41
+ end
42
+
43
+ def app_tests?
44
+ %w(1 true yes).include?(ENV['APP_TESTS']&.downcase)
37
45
  end
38
46
 
39
47
  def ci?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
@@ -29,7 +29,7 @@ cert_chain:
29
29
  gpvfPNWMwyBDlHaNS3GfO6cRRxBOvEG05GUCsvtTY4Bpe8yjE64wg1ymb47LMOnv
30
30
  Qb1lGORmf/opg45mluKUYl7pQNZHD0d3
31
31
  -----END CERTIFICATE-----
32
- date: 2020-04-30 00:00:00.000000000 Z
32
+ date: 2020-06-03 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: activemodel
@@ -616,6 +616,7 @@ files:
616
616
  - spec/app/models/word_origin.rb
617
617
  - spec/app/models/writer.rb
618
618
  - spec/config/mongoid.yml
619
+ - spec/integration/app_spec.rb
619
620
  - spec/integration/associations/belongs_to_spec.rb
620
621
  - spec/integration/associations/embedded_spec.rb
621
622
  - spec/integration/associations/foreign_key_spec.rb
@@ -767,6 +768,7 @@ files:
767
768
  - spec/mongoid/criteria/scopable_spec.rb
768
769
  - spec/mongoid/criteria_spec.rb
769
770
  - spec/mongoid/document_fields_spec.rb
771
+ - spec/mongoid/document_persistence_context_spec.rb
770
772
  - spec/mongoid/document_query_spec.rb
771
773
  - spec/mongoid/document_spec.rb
772
774
  - spec/mongoid/equality_spec.rb
@@ -916,6 +918,7 @@ files:
916
918
  - spec/rails/mongoid_spec.rb
917
919
  - spec/spec_helper.rb
918
920
  - spec/support/authorization.rb
921
+ - spec/support/child_process_helper.rb
919
922
  - spec/support/cluster_config.rb
920
923
  - spec/support/constraints.rb
921
924
  - spec/support/expectations.rb
@@ -1437,6 +1440,7 @@ test_files:
1437
1440
  - spec/mongoid/loggable_spec.rb
1438
1441
  - spec/mongoid/document_query_spec.rb
1439
1442
  - spec/mongoid/traversable_spec.rb
1443
+ - spec/mongoid/document_persistence_context_spec.rb
1440
1444
  - spec/mongoid/criteria_spec.rb
1441
1445
  - spec/mongoid/query_cache_spec.rb
1442
1446
  - spec/mongoid/matchable_spec.rb
@@ -1467,11 +1471,13 @@ test_files:
1467
1471
  - spec/support/lite_constraints.rb
1468
1472
  - spec/support/constraints.rb
1469
1473
  - spec/support/spec_config.rb
1474
+ - spec/support/child_process_helper.rb
1470
1475
  - spec/mongoid_spec.rb
1471
1476
  - spec/config/mongoid.yml
1472
1477
  - spec/rails/controller_extension/controller_runtime_spec.rb
1473
1478
  - spec/rails/mongoid_spec.rb
1474
1479
  - spec/spec_helper.rb
1480
+ - spec/integration/app_spec.rb
1475
1481
  - spec/integration/i18n_fallbacks_spec.rb
1476
1482
  - spec/integration/associations/foreign_key_spec_models.rb
1477
1483
  - spec/integration/associations/foreign_key_spec.rb
metadata.gz.sig CHANGED
Binary file