mongoid 7.2.0.rc1 → 7.2.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.tar.gz.sig +0 -0
- data/Rakefile +30 -11
- data/lib/mongoid/association/referenced/has_one/buildable.rb +8 -0
- data/lib/mongoid/association/referenced/has_one/proxy.rb +6 -1
- data/lib/mongoid/copyable.rb +5 -1
- data/lib/mongoid/extensions.rb +1 -0
- data/lib/mongoid/fields.rb +3 -0
- data/lib/mongoid/stringified_symbol.rb +53 -0
- data/lib/mongoid/version.rb +1 -1
- data/spec/README.md +19 -4
- data/spec/integration/app_spec.rb +12 -12
- data/spec/integration/associations/embeds_many_spec.rb +24 -0
- data/spec/integration/associations/embeds_one_spec.rb +24 -0
- data/spec/integration/associations/has_many_spec.rb +60 -0
- data/spec/integration/associations/has_one_spec.rb +60 -0
- data/spec/integration/stringified_symbol_field_spec.rb +190 -0
- data/spec/lite_spec_helper.rb +4 -3
- data/spec/mongoid/association/referenced/has_many_models.rb +12 -0
- data/spec/mongoid/association/referenced/has_one_models.rb +12 -0
- data/spec/mongoid/association/referenced/has_one_spec.rb +1 -1
- data/spec/mongoid/copyable_spec.rb +44 -17
- data/spec/mongoid/copyable_spec_models.rb +14 -0
- data/spec/mongoid/equality_spec.rb +0 -1
- data/spec/mongoid/extensions/stringified_symbol_spec.rb +85 -0
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/constraints.rb +303 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +175 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +149 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/support/constraints.rb +0 -226
- data/spec/support/models/order.rb +11 -0
- data/spec/support/models/person.rb +2 -0
- data/spec/support/models/series.rb +1 -0
- data/spec/support/models/wiki_page.rb +1 -0
- metadata +512 -496
- metadata.gz.sig +0 -0
- data/spec/support/child_process_helper.rb +0 -79
- data/spec/support/lite_constraints.rb +0 -22
- data/spec/support/spec_organizer.rb +0 -130
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
gem 'childprocess'
|
5
|
-
require 'childprocess'
|
6
|
-
require 'tempfile'
|
7
|
-
|
8
|
-
module ChildProcessHelper
|
9
|
-
class SpawnError < StandardError; end
|
10
|
-
|
11
|
-
module_function def call(cmd, env: nil, cwd: nil)
|
12
|
-
process = ChildProcess.new(*cmd)
|
13
|
-
process.io.inherit!
|
14
|
-
if cwd
|
15
|
-
process.cwd = cwd
|
16
|
-
end
|
17
|
-
if env
|
18
|
-
env.each do |k, v|
|
19
|
-
process.environment[k.to_s] = v
|
20
|
-
end
|
21
|
-
end
|
22
|
-
process.start
|
23
|
-
process.wait
|
24
|
-
process
|
25
|
-
end
|
26
|
-
|
27
|
-
module_function def check_call(cmd, env: nil, cwd: nil)
|
28
|
-
process = call(cmd, env: env, cwd: cwd)
|
29
|
-
unless process.exit_code == 0
|
30
|
-
raise "Failed to execute: #{cmd}"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module_function def get_output(cmd, env: nil, cwd: nil)
|
35
|
-
process = ChildProcess.new(*cmd)
|
36
|
-
process.io.inherit!
|
37
|
-
if cwd
|
38
|
-
process.cwd = cwd
|
39
|
-
end
|
40
|
-
if env
|
41
|
-
env.each do |k, v|
|
42
|
-
process.environment[k.to_s] = v
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
output = ''
|
47
|
-
r, w = IO.pipe
|
48
|
-
|
49
|
-
begin
|
50
|
-
process.io.stdout = w
|
51
|
-
process.start
|
52
|
-
w.close
|
53
|
-
|
54
|
-
thread = Thread.new do
|
55
|
-
begin
|
56
|
-
loop do
|
57
|
-
output << r.readpartial(16384)
|
58
|
-
end
|
59
|
-
rescue EOFError
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
process.wait
|
64
|
-
thread.join
|
65
|
-
ensure
|
66
|
-
r.close
|
67
|
-
end
|
68
|
-
|
69
|
-
[process, output]
|
70
|
-
end
|
71
|
-
|
72
|
-
module_function def check_output(*args)
|
73
|
-
process, output = get_output(*args)
|
74
|
-
unless process.exit_code == 0
|
75
|
-
raise "Failed to execute: #{args}"
|
76
|
-
end
|
77
|
-
output
|
78
|
-
end
|
79
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module LiteConstraints
|
2
|
-
# Constrain tests that use TimeoutInterrupt to MRI (and Unix)
|
3
|
-
def only_mri
|
4
|
-
before do
|
5
|
-
unless SpecConfig.instance.mri?
|
6
|
-
skip "MRI required, we have #{SpecConfig.instance.platform}"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
# This is for marking tests that fail on jruby that should
|
12
|
-
# in principle work (as opposed to being fundamentally incompatible
|
13
|
-
# with jruby).
|
14
|
-
# Often times these failures happen only in Evergreen.
|
15
|
-
def fails_on_jruby
|
16
|
-
before do
|
17
|
-
unless SpecConfig.instance.mri?
|
18
|
-
skip "Fails on jruby"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,130 +0,0 @@
|
|
1
|
-
require 'support/child_process_helper'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
autoload :FileUtils, 'fileutils'
|
5
|
-
autoload :Find, 'find'
|
6
|
-
|
7
|
-
# Organizes and runs all of the tests in the test suite in batches.
|
8
|
-
#
|
9
|
-
# Organizing the tests in batches serves two purposes:
|
10
|
-
#
|
11
|
-
# 1. This allows running unit tests before integration tests, therefore
|
12
|
-
# in theory revealing failures quicker on average.
|
13
|
-
# 2. This allows running some tests that have high intermittent failure rate
|
14
|
-
# in their own test process.
|
15
|
-
#
|
16
|
-
# This class aggregates RSpec results after the test runs.
|
17
|
-
class SpecOrganizer
|
18
|
-
CLASSIFIERS = [
|
19
|
-
[%r,^mongoid/attribute,, :attributes],
|
20
|
-
[%r,^mongoid/association/[or],, :associations_referenced],
|
21
|
-
[%r,^mongoid/association,, :associations],
|
22
|
-
[%r,^mongoid,, :unit],
|
23
|
-
[%r,^integration,, :integration],
|
24
|
-
[%r,^rails,, :rails],
|
25
|
-
]
|
26
|
-
|
27
|
-
RUN_PRIORITY = %i(
|
28
|
-
unit attributes associations_referenced associations
|
29
|
-
integration rails
|
30
|
-
)
|
31
|
-
|
32
|
-
SPEC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
33
|
-
ROOT = File.expand_path(File.join(SPEC_ROOT, '..'))
|
34
|
-
RSPEC_JSON_PATH = File.join(ROOT, 'tmp/rspec.json')
|
35
|
-
RSPEC_ALL_JSON_PATH = File.join(ROOT, 'tmp/rspec-all.json')
|
36
|
-
|
37
|
-
def run
|
38
|
-
FileUtils.rm_f(RSPEC_ALL_JSON_PATH)
|
39
|
-
|
40
|
-
buckets = {}
|
41
|
-
Find.find(SPEC_ROOT) do |path|
|
42
|
-
next unless File.file?(path)
|
43
|
-
next unless path =~ /_spec\.rb\z/
|
44
|
-
rel_path = path[(SPEC_ROOT.length + 1)..path.length]
|
45
|
-
|
46
|
-
found = false
|
47
|
-
CLASSIFIERS.each do |(regexp, category)|
|
48
|
-
if regexp =~ rel_path
|
49
|
-
buckets[category] ||= []
|
50
|
-
buckets[category] << rel_path
|
51
|
-
found = true
|
52
|
-
break
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
unless found
|
57
|
-
buckets[nil] ||= []
|
58
|
-
buckets[nil] << rel_path
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
failed = []
|
63
|
-
|
64
|
-
RUN_PRIORITY.each do |category|
|
65
|
-
if files = buckets.delete(category)
|
66
|
-
unless run_files(category, files)
|
67
|
-
failed << category
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
if files = buckets.delete(nil)
|
72
|
-
unless run_files('remaining', files)
|
73
|
-
failed << 'remaining'
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
unless buckets.empty?
|
78
|
-
raise "Some buckets were not executed: #{buckets.keys.map(&:to_s).join(', ')}"
|
79
|
-
end
|
80
|
-
|
81
|
-
if failed.any?
|
82
|
-
raise "The following buckets failed: #{failed.map(&:to_s).join(', ')}"
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def run_files(category, paths)
|
87
|
-
paths = paths.map do |path|
|
88
|
-
File.join('spec', path)
|
89
|
-
end
|
90
|
-
|
91
|
-
puts "Running #{category.to_s.gsub('_', ' ')} tests"
|
92
|
-
FileUtils.rm_f(RSPEC_JSON_PATH)
|
93
|
-
cmd = %w(rspec) + paths
|
94
|
-
|
95
|
-
begin
|
96
|
-
ChildProcessHelper.check_call(cmd)
|
97
|
-
ensure
|
98
|
-
if File.exist?(RSPEC_JSON_PATH)
|
99
|
-
if File.exist?(RSPEC_ALL_JSON_PATH)
|
100
|
-
merge_rspec_results
|
101
|
-
else
|
102
|
-
FileUtils.cp(RSPEC_JSON_PATH, RSPEC_ALL_JSON_PATH)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
true
|
108
|
-
rescue ChildProcessHelper::SpawnError
|
109
|
-
false
|
110
|
-
end
|
111
|
-
|
112
|
-
def merge_rspec_results
|
113
|
-
all = JSON.parse(File.read(RSPEC_ALL_JSON_PATH))
|
114
|
-
new = JSON.parse(File.read(RSPEC_JSON_PATH))
|
115
|
-
all['examples'] += new.delete('examples')
|
116
|
-
new.delete('summary').each do |k, v|
|
117
|
-
all['summary'][k] += v
|
118
|
-
end
|
119
|
-
new.delete('version')
|
120
|
-
new.delete('summary_line')
|
121
|
-
unless new.empty?
|
122
|
-
raise "Unhandled rspec results keys: #{new.keys.join(', ')}"
|
123
|
-
end
|
124
|
-
# We do not merge summary lines, delete them from aggregated results
|
125
|
-
all.delete('summary_line')
|
126
|
-
File.open(RSPEC_ALL_JSON_PATH, 'w') do |f|
|
127
|
-
f << JSON.dump(all)
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|