mongoid 7.1.0 → 7.1.6
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/CHANGELOG.md +6 -6
- data/README.md +1 -1
- data/Rakefile +14 -5
- data/lib/config/locales/en.yml +5 -5
- data/lib/mongoid/association/accessors.rb +37 -2
- data/lib/mongoid/association/embedded/embeds_many.rb +2 -1
- data/lib/mongoid/association/embedded/embeds_one.rb +2 -1
- data/lib/mongoid/association/proxy.rb +1 -1
- data/lib/mongoid/association/referenced/belongs_to/binding.rb +1 -1
- data/lib/mongoid/association/referenced/belongs_to/eager.rb +38 -2
- data/lib/mongoid/association/referenced/eager.rb +29 -9
- data/lib/mongoid/association/referenced/has_one/proxy.rb +6 -1
- data/lib/mongoid/atomic.rb +13 -3
- data/lib/mongoid/clients/factory.rb +2 -2
- data/lib/mongoid/clients/options.rb +8 -8
- data/lib/mongoid/clients/sessions.rb +20 -4
- data/lib/mongoid/clients/storage_options.rb +5 -5
- data/lib/mongoid/config.rb +39 -9
- data/lib/mongoid/criteria.rb +23 -4
- data/lib/mongoid/criteria/modifiable.rb +2 -1
- data/lib/mongoid/criteria/queryable/extensions/numeric.rb +1 -1
- data/lib/mongoid/criteria/queryable/extensions/regexp.rb +6 -6
- data/lib/mongoid/criteria/queryable/extensions/time_with_zone.rb +12 -0
- data/lib/mongoid/criteria/queryable/mergeable.rb +75 -8
- data/lib/mongoid/criteria/queryable/pipeline.rb +3 -2
- data/lib/mongoid/criteria/queryable/selectable.rb +120 -13
- data/lib/mongoid/criteria/queryable/storable.rb +104 -99
- data/lib/mongoid/errors/eager_load.rb +2 -0
- data/lib/mongoid/errors/no_client_config.rb +2 -2
- data/lib/mongoid/errors/no_default_client.rb +1 -1
- data/lib/mongoid/extensions/hash.rb +4 -2
- data/lib/mongoid/extensions/regexp.rb +1 -1
- data/lib/mongoid/fields.rb +2 -1
- data/lib/mongoid/fields/validators/macro.rb +4 -1
- data/lib/mongoid/matchable/regexp.rb +2 -2
- data/lib/mongoid/persistable/pushable.rb +11 -2
- data/lib/mongoid/persistence_context.rb +6 -6
- data/lib/mongoid/query_cache.rb +61 -18
- data/lib/mongoid/serializable.rb +9 -3
- data/lib/mongoid/tasks/database.rb +38 -3
- data/lib/mongoid/validatable/uniqueness.rb +1 -1
- data/lib/mongoid/version.rb +1 -1
- data/lib/rails/generators/mongoid/config/templates/mongoid.yml +32 -23
- data/lib/rails/generators/mongoid/model/templates/model.rb.tt +1 -1
- data/spec/app/models/coding.rb +4 -0
- data/spec/app/models/coding/pull_request.rb +12 -0
- data/spec/app/models/delegating_patient.rb +16 -0
- data/spec/app/models/passport.rb +1 -0
- data/spec/app/models/person.rb +2 -0
- data/spec/app/models/phone.rb +1 -0
- data/spec/app/models/publication.rb +5 -0
- data/spec/app/models/publication/encyclopedia.rb +12 -0
- data/spec/app/models/publication/review.rb +14 -0
- data/spec/app/models/series.rb +1 -0
- data/spec/app/models/wiki_page.rb +1 -0
- data/spec/integration/app_spec.rb +254 -0
- data/spec/integration/associations/embedded_spec.rb +54 -0
- 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 +76 -0
- data/spec/integration/associations/has_one_spec.rb +76 -0
- data/spec/integration/bson_regexp_raw_spec.rb +20 -0
- data/spec/integration/criteria/date_field_spec.rb +41 -0
- data/spec/integration/criteria/logical_spec.rb +13 -0
- data/spec/integration/document_spec.rb +22 -0
- data/spec/integration/shardable_spec.rb +20 -4
- data/spec/lite_spec_helper.rb +12 -4
- data/spec/mongoid/association/accessors_spec.rb +238 -63
- data/spec/mongoid/association/embedded/embeds_many_models.rb +19 -0
- data/spec/mongoid/association/embedded/embeds_many_spec.rb +10 -0
- data/spec/mongoid/association/embedded/embeds_one_spec.rb +0 -2
- data/spec/mongoid/association/referenced/belongs_to/eager_spec.rb +193 -10
- data/spec/mongoid/association/referenced/has_and_belongs_to_many/proxy_spec.rb +140 -1
- data/spec/mongoid/association/referenced/has_many/enumerable_spec.rb +105 -0
- data/spec/mongoid/association/referenced/has_many/proxy_spec.rb +2 -1
- data/spec/mongoid/clients/factory_spec.rb +8 -8
- data/spec/mongoid/clients/options_spec.rb +11 -11
- data/spec/mongoid/clients/sessions_spec.rb +8 -4
- data/spec/mongoid/clients/transactions_spec.rb +20 -8
- data/spec/mongoid/clients_spec.rb +2 -2
- data/spec/mongoid/contextual/atomic_spec.rb +22 -11
- data/spec/mongoid/contextual/geo_near_spec.rb +11 -2
- data/spec/mongoid/contextual/map_reduce_spec.rb +20 -5
- data/spec/mongoid/contextual/mongo_spec.rb +76 -53
- data/spec/mongoid/criteria/queryable/extensions/regexp_raw_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/extensions/regexp_spec.rb +7 -7
- data/spec/mongoid/criteria/queryable/extensions/string_spec.rb +1 -1
- data/spec/mongoid/criteria/queryable/extensions/time_spec.rb +19 -7
- data/spec/mongoid/criteria/queryable/extensions/time_with_zone_spec.rb +28 -1
- data/spec/mongoid/criteria/queryable/mergeable_spec.rb +45 -12
- data/spec/mongoid/criteria/queryable/selectable_logical_spec.rb +1051 -392
- data/spec/mongoid/criteria/queryable/selectable_spec.rb +52 -0
- data/spec/mongoid/criteria/queryable/storable_spec.rb +80 -2
- data/spec/mongoid/criteria_spec.rb +36 -2
- data/spec/mongoid/document_persistence_context_spec.rb +33 -0
- data/spec/mongoid/errors/no_client_config_spec.rb +2 -2
- data/spec/mongoid/errors/no_client_database_spec.rb +3 -3
- data/spec/mongoid/errors/no_client_hosts_spec.rb +3 -3
- data/spec/mongoid/fields_spec.rb +24 -1
- data/spec/mongoid/indexable_spec.rb +6 -4
- data/spec/mongoid/matchable/default_spec.rb +1 -1
- data/spec/mongoid/matchable/regexp_spec.rb +2 -2
- data/spec/mongoid/matchable_spec.rb +2 -2
- data/spec/mongoid/persistable/pushable_spec.rb +55 -1
- data/spec/mongoid/query_cache_spec.rb +77 -9
- data/spec/mongoid/relations/proxy_spec.rb +1 -1
- data/spec/mongoid/scopable_spec.rb +2 -1
- data/spec/mongoid/serializable_spec.rb +129 -18
- data/spec/mongoid/shardable_models.rb +1 -1
- data/spec/mongoid/shardable_spec.rb +2 -2
- data/spec/mongoid/tasks/database_rake_spec.rb +13 -13
- data/spec/mongoid/tasks/database_spec.rb +1 -1
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +211 -0
- data/spec/shared/lib/mrss/constraints.rb +312 -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 -31
- data/spec/support/child_process_helper.rb +76 -0
- data/spec/support/cluster_config.rb +3 -3
- data/spec/support/constraints.rb +26 -10
- data/spec/support/expectations.rb +3 -1
- data/spec/support/helpers.rb +11 -0
- data/spec/support/session_registry.rb +50 -0
- data/spec/support/spec_config.rb +12 -4
- metadata +520 -473
- metadata.gz.sig +0 -0
@@ -3,6 +3,7 @@
|
|
3
3
|
|
4
4
|
require 'spec_helper'
|
5
5
|
require_relative '../../mongoid/association/embedded/embeds_many_models'
|
6
|
+
require_relative '../../mongoid/association/embedded/embeds_one_models'
|
6
7
|
|
7
8
|
describe 'embedded associations' do
|
8
9
|
context 'without default order' do
|
@@ -118,4 +119,57 @@ describe 'embedded associations' do
|
|
118
119
|
it_behaves_like 'an embedded association'
|
119
120
|
end
|
120
121
|
end
|
122
|
+
|
123
|
+
describe 'parent association' do
|
124
|
+
let(:parent) do
|
125
|
+
parent_cls.new
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'embeds_one' do
|
129
|
+
|
130
|
+
shared_examples 'is set' do
|
131
|
+
it 'is set' do
|
132
|
+
parent.child = child_cls.new
|
133
|
+
parent.child.parent.should == parent
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context 'class_name set without leading ::' do
|
138
|
+
let(:parent_cls) { EomParent }
|
139
|
+
let(:child_cls) { EomChild }
|
140
|
+
|
141
|
+
it_behaves_like 'is set'
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'class_name set with leading ::' do
|
145
|
+
let(:parent_cls) { EomCcParent }
|
146
|
+
let(:child_cls) { EomCcChild }
|
147
|
+
|
148
|
+
it_behaves_like 'is set'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'embeds_many' do
|
153
|
+
|
154
|
+
let(:child) { parent.legislators.new }
|
155
|
+
|
156
|
+
shared_examples 'is set' do
|
157
|
+
it 'is set' do
|
158
|
+
child.congress.should == parent
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context 'class_name set without leading ::' do
|
163
|
+
let(:parent_cls) { EmmCongress }
|
164
|
+
|
165
|
+
it_behaves_like 'is set'
|
166
|
+
end
|
167
|
+
|
168
|
+
context 'class_name set with leading ::' do
|
169
|
+
let(:parent_cls) { EmmCcCongress }
|
170
|
+
|
171
|
+
it_behaves_like 'is set'
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
121
175
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe 'embeds_many associations' do
|
7
|
+
|
8
|
+
context 're-associating the same object' do
|
9
|
+
context 'with dependent: destroy' do
|
10
|
+
let(:canvas) do
|
11
|
+
Canvas.create!(shapes: [Shape.new])
|
12
|
+
end
|
13
|
+
|
14
|
+
let!(:shape) { canvas.shapes.first }
|
15
|
+
|
16
|
+
it 'does not destroy the dependent object' do
|
17
|
+
canvas.shapes = [shape]
|
18
|
+
canvas.save!
|
19
|
+
canvas.reload
|
20
|
+
canvas.shapes.should == [shape]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe 'embeds_one associations' do
|
7
|
+
|
8
|
+
context 're-associating the same object' do
|
9
|
+
context 'with dependent: destroy' do
|
10
|
+
let(:canvas) do
|
11
|
+
Canvas.create!(palette: Palette.new)
|
12
|
+
end
|
13
|
+
|
14
|
+
let!(:palette) { canvas.palette }
|
15
|
+
|
16
|
+
it 'does not destroy the dependent object' do
|
17
|
+
canvas.palette = canvas.palette
|
18
|
+
canvas.save!
|
19
|
+
canvas.reload
|
20
|
+
canvas.palette.should == palette
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe 'has_many associations' do
|
7
|
+
context 'destroying parent in transaction with dependent child' do
|
8
|
+
require_transaction_support
|
9
|
+
|
10
|
+
let(:artist) { Artist.create! }
|
11
|
+
let(:album) { Album.create!(artist: artist) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
Artist.delete_all
|
15
|
+
Album.delete_all
|
16
|
+
|
17
|
+
album
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'works' do
|
21
|
+
Artist.count.should == 1
|
22
|
+
Album.count.should == 1
|
23
|
+
|
24
|
+
artist.with_session do |session|
|
25
|
+
session.with_transaction do
|
26
|
+
artist.destroy
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Artist.count.should == 0
|
31
|
+
Album.count.should == 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 're-associating the same object' do
|
36
|
+
context 'with dependent: destroy' do
|
37
|
+
let(:wiki_page) do
|
38
|
+
WikiPage.create!
|
39
|
+
end
|
40
|
+
|
41
|
+
let!(:comment) do
|
42
|
+
Comment.create!(wiki_page: wiki_page, title: 'hi') do
|
43
|
+
wiki_page.reload
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not destroy the dependent object' do
|
48
|
+
wiki_page.comments.should == [comment]
|
49
|
+
wiki_page.comments = [comment]
|
50
|
+
wiki_page.save!
|
51
|
+
wiki_page.reload
|
52
|
+
wiki_page.comments.should == [comment]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'without dependent: destroy' do
|
57
|
+
let(:series) do
|
58
|
+
Series.create!
|
59
|
+
end
|
60
|
+
|
61
|
+
let!(:book) do
|
62
|
+
Book.create!(series: series).tap do
|
63
|
+
series.reload
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'does not destroy the dependent object' do
|
68
|
+
series.books.should == [book]
|
69
|
+
series.books = [book]
|
70
|
+
series.save!
|
71
|
+
series.reload
|
72
|
+
series.books.should == [book]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe 'has_one associations' do
|
7
|
+
context 'destroying parent in transaction with dependent child' do
|
8
|
+
require_transaction_support
|
9
|
+
|
10
|
+
let(:person) { Person.create! }
|
11
|
+
let(:game) { Game.create!(person: person) }
|
12
|
+
|
13
|
+
before do
|
14
|
+
Person.delete_all
|
15
|
+
Game.delete_all
|
16
|
+
|
17
|
+
game
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'works' do
|
21
|
+
Person.count.should == 1
|
22
|
+
Game.count.should == 1
|
23
|
+
|
24
|
+
Person.with_session do |session|
|
25
|
+
session.with_transaction do
|
26
|
+
person.destroy
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
Person.count.should == 0
|
31
|
+
Game.count.should == 0
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 're-associating the same object' do
|
36
|
+
context 'with dependent: destroy' do
|
37
|
+
let(:person) do
|
38
|
+
Person.create!
|
39
|
+
end
|
40
|
+
|
41
|
+
let!(:game) do
|
42
|
+
Game.create!(person: person) do
|
43
|
+
person.reload
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'does not destroy the dependent object' do
|
48
|
+
person.game.should == game
|
49
|
+
person.game = person.game
|
50
|
+
person.save!
|
51
|
+
person.reload
|
52
|
+
person.game.should == game
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'without dependent: destroy' do
|
57
|
+
let(:person) do
|
58
|
+
Person.create!
|
59
|
+
end
|
60
|
+
|
61
|
+
let!(:account) do
|
62
|
+
Account.create!(person: person, name: 'foo').tap do
|
63
|
+
person.reload
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'does not destroy the dependent object' do
|
68
|
+
person.account.should == account
|
69
|
+
person.account = person.account
|
70
|
+
person.save!
|
71
|
+
person.reload
|
72
|
+
person.account.should == account
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe BSON::Regexp::Raw do
|
7
|
+
context 'fully qualified name' do
|
8
|
+
it 'can be created' do
|
9
|
+
regexp = BSON::Regexp::Raw.new('foo')
|
10
|
+
regexp.pattern.should == 'foo'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'via ::Regexp' do
|
15
|
+
it 'can be created' do
|
16
|
+
regexp = Regexp::Raw.new('foo')
|
17
|
+
regexp.pattern.should == 'foo'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe 'Queries on Date fields' do
|
7
|
+
let(:query) do
|
8
|
+
Band.where(founded: arg)
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:selector) { query.selector }
|
12
|
+
|
13
|
+
shared_examples 'converts to beginning of day in UTC' do
|
14
|
+
it 'converts to beginning of day in UTC' do
|
15
|
+
selector['founded'].should == arg.dup.beginning_of_day.utc.beginning_of_day
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'using Time' do
|
20
|
+
let(:arg) do
|
21
|
+
Time.now.freeze
|
22
|
+
end
|
23
|
+
|
24
|
+
it_behaves_like 'converts to beginning of day in UTC'
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'using TimeWithZone' do
|
28
|
+
let(:time_zone_name) { 'Pacific Time (US & Canada)' }
|
29
|
+
let(:arg) { Time.now.in_time_zone(time_zone_name).freeze }
|
30
|
+
|
31
|
+
it_behaves_like 'converts to beginning of day in UTC'
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'using DateTime' do
|
35
|
+
let(:arg) do
|
36
|
+
DateTime.now.freeze
|
37
|
+
end
|
38
|
+
|
39
|
+
it_behaves_like 'converts to beginning of day in UTC'
|
40
|
+
end
|
41
|
+
end
|
@@ -47,6 +47,19 @@ describe 'Criteria logical operations' do
|
|
47
47
|
bands = Band.where(name: /jecti/).or(Band.where(name: /ush/))
|
48
48
|
expect(bands.order_by(name: 1).to_a).to eq([ap, im])
|
49
49
|
end
|
50
|
+
|
51
|
+
context 'when using a symbol operator' do
|
52
|
+
context 'when field has a serializer' do
|
53
|
+
let!(:doc) { Dokument.create! }
|
54
|
+
|
55
|
+
it 'works' do
|
56
|
+
scope = Dokument.or(:created_at.lte => DateTime.now).sort(id: 1)
|
57
|
+
# input was converted from DateTime to Time
|
58
|
+
scope.criteria.selector['$or'].first['created_at']['$lte'].should be_a(Time)
|
59
|
+
scope.to_a.should == [doc]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
50
63
|
end
|
51
64
|
|
52
65
|
describe 'not' do
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
|
6
|
+
describe Mongoid::Document do
|
7
|
+
context 'when including class uses delegate' do
|
8
|
+
let(:patient) do
|
9
|
+
DelegatingPatient.new(
|
10
|
+
email: Email.new(address: 'test@example.com'),
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'works for instance level delegation' do
|
15
|
+
patient.address.should == 'test@example.com'
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'works for class level delegation' do
|
19
|
+
DelegatingPatient.default_client.should be Mongoid.default_client
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -122,11 +122,27 @@ describe 'Sharding helpers' do
|
|
122
122
|
shard_collections.should == []
|
123
123
|
end
|
124
124
|
|
125
|
-
|
126
|
-
|
125
|
+
context 'pre-4.2' do
|
126
|
+
max_server_version '4.0'
|
127
127
|
|
128
|
-
|
129
|
-
|
128
|
+
it 'does not shards collection' do
|
129
|
+
shard_collections
|
130
|
+
|
131
|
+
lambda do
|
132
|
+
model_cls.collection.database.command(collStats: model_cls.collection.name).first
|
133
|
+
end.should raise_error(Mongo::Error::OperationFailure, /Collection.*not found/)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context '4.2+' do
|
138
|
+
min_server_version '4.2'
|
139
|
+
|
140
|
+
it 'does not shards collection' do
|
141
|
+
shard_collections
|
142
|
+
|
143
|
+
stats = model_cls.collection.database.command(collStats: model_cls.collection.name).first
|
144
|
+
stats[:sharded].should be false
|
145
|
+
end
|
130
146
|
end
|
131
147
|
end
|
132
148
|
end
|
data/spec/lite_spec_helper.rb
CHANGED
@@ -16,6 +16,7 @@ require 'pp'
|
|
16
16
|
|
17
17
|
require 'support/spec_config'
|
18
18
|
require 'support/lite_constraints'
|
19
|
+
require "support/session_registry"
|
19
20
|
|
20
21
|
unless SpecConfig.instance.ci?
|
21
22
|
begin
|
@@ -50,11 +51,18 @@ RSpec.configure do |config|
|
|
50
51
|
end
|
51
52
|
|
52
53
|
if SpecConfig.instance.ci?
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
timeout = if SpecConfig.instance.app_tests?
|
55
|
+
# Allow 5 minutes per test for the app tests, since they install
|
56
|
+
# gems for Rails applications which can take a long time.
|
57
|
+
300
|
58
|
+
else
|
59
|
+
# Allow a max of 30 seconds per test.
|
60
|
+
# Tests should take under 10 seconds ideally but it seems
|
61
|
+
# we have some that run for more than 10 seconds in CI.
|
62
|
+
30
|
63
|
+
end
|
56
64
|
config.around(:each) do |example|
|
57
|
-
TimeoutInterrupt.timeout(
|
65
|
+
TimeoutInterrupt.timeout(timeout) do
|
58
66
|
example.run
|
59
67
|
end
|
60
68
|
end
|
@@ -11,9 +11,9 @@ describe Mongoid::Association::Accessors do
|
|
11
11
|
Person.create
|
12
12
|
end
|
13
13
|
|
14
|
-
context "when the
|
14
|
+
context "when the association is a has one" do
|
15
15
|
|
16
|
-
context "when the
|
16
|
+
context "when the association exists" do
|
17
17
|
|
18
18
|
let!(:game) do
|
19
19
|
person.build_game
|
@@ -24,7 +24,7 @@ describe Mongoid::Association::Accessors do
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
context "when the
|
27
|
+
context "when the association does not exist" do
|
28
28
|
|
29
29
|
context "when not autobuilding" do
|
30
30
|
|
@@ -42,9 +42,9 @@ describe Mongoid::Association::Accessors do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
context "when the
|
45
|
+
context "when the association is a has many" do
|
46
46
|
|
47
|
-
context "when the
|
47
|
+
context "when the association has documents" do
|
48
48
|
|
49
49
|
let!(:post) do
|
50
50
|
person.posts.build
|
@@ -55,7 +55,7 @@ describe Mongoid::Association::Accessors do
|
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
|
-
context "when the
|
58
|
+
context "when the association does not have documents" do
|
59
59
|
|
60
60
|
it "returns false" do
|
61
61
|
expect(person).to_not have_posts
|
@@ -63,9 +63,9 @@ describe Mongoid::Association::Accessors do
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
context "when the
|
66
|
+
context "when the association is a has and belongs to many" do
|
67
67
|
|
68
|
-
context "when the
|
68
|
+
context "when the association has documents" do
|
69
69
|
|
70
70
|
let!(:preference) do
|
71
71
|
person.preferences.build
|
@@ -76,7 +76,7 @@ describe Mongoid::Association::Accessors do
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
context "when the
|
79
|
+
context "when the association does not have documents" do
|
80
80
|
|
81
81
|
it "returns false" do
|
82
82
|
expect(person).to_not have_preferences
|
@@ -84,9 +84,9 @@ describe Mongoid::Association::Accessors do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
-
context "when the
|
87
|
+
context "when the association is a belongs to" do
|
88
88
|
|
89
|
-
context "when the
|
89
|
+
context "when the association is named next" do
|
90
90
|
|
91
91
|
let(:user) do
|
92
92
|
User.create
|
@@ -97,7 +97,7 @@ describe Mongoid::Association::Accessors do
|
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
context "when the
|
100
|
+
context "when the association exists" do
|
101
101
|
|
102
102
|
let!(:game) do
|
103
103
|
person.build_game
|
@@ -108,9 +108,9 @@ describe Mongoid::Association::Accessors do
|
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
context "when the
|
111
|
+
context "when the association does not exist" do
|
112
112
|
|
113
|
-
context "when the
|
113
|
+
context "when the association does not autobuild" do
|
114
114
|
|
115
115
|
let(:game) do
|
116
116
|
Game.new
|
@@ -121,7 +121,7 @@ describe Mongoid::Association::Accessors do
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
context "when the
|
124
|
+
context "when the association autobuilds" do
|
125
125
|
|
126
126
|
let(:book) do
|
127
127
|
Book.new
|
@@ -134,9 +134,9 @@ describe Mongoid::Association::Accessors do
|
|
134
134
|
end
|
135
135
|
end
|
136
136
|
|
137
|
-
context "when the
|
137
|
+
context "when the association is an embeds one" do
|
138
138
|
|
139
|
-
context "when the
|
139
|
+
context "when the association exists" do
|
140
140
|
|
141
141
|
let!(:name) do
|
142
142
|
person.build_name
|
@@ -147,16 +147,16 @@ describe Mongoid::Association::Accessors do
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
-
context "when the
|
150
|
+
context "when the association does not exist" do
|
151
151
|
|
152
|
-
context "when the
|
152
|
+
context "when the association does not autobuild" do
|
153
153
|
|
154
154
|
it "returns false" do
|
155
155
|
expect(person).to_not have_name
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
-
context "when the
|
159
|
+
context "when the association autobuilds" do
|
160
160
|
|
161
161
|
let(:person) do
|
162
162
|
Person.new
|
@@ -169,9 +169,9 @@ describe Mongoid::Association::Accessors do
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
context "when the
|
172
|
+
context "when the association is an embeds many" do
|
173
173
|
|
174
|
-
context "when the
|
174
|
+
context "when the association has documents" do
|
175
175
|
|
176
176
|
let!(:address) do
|
177
177
|
person.addresses.build
|
@@ -182,7 +182,7 @@ describe Mongoid::Association::Accessors do
|
|
182
182
|
end
|
183
183
|
end
|
184
184
|
|
185
|
-
context "when the
|
185
|
+
context "when the association does not have documents" do
|
186
186
|
|
187
187
|
it "returns false" do
|
188
188
|
expect(person).to_not have_addresses
|
@@ -190,9 +190,9 @@ describe Mongoid::Association::Accessors do
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
-
context "when the
|
193
|
+
context "when the association is an embedded in" do
|
194
194
|
|
195
|
-
context "when the
|
195
|
+
context "when the association exists" do
|
196
196
|
|
197
197
|
let!(:name) do
|
198
198
|
person.build_name
|
@@ -203,9 +203,9 @@ describe Mongoid::Association::Accessors do
|
|
203
203
|
end
|
204
204
|
end
|
205
205
|
|
206
|
-
context "when the
|
206
|
+
context "when the association does not exist" do
|
207
207
|
|
208
|
-
context "when the
|
208
|
+
context "when the association does not autobuild" do
|
209
209
|
|
210
210
|
let(:name) do
|
211
211
|
Name.new
|
@@ -216,7 +216,7 @@ describe Mongoid::Association::Accessors do
|
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
context "when the
|
219
|
+
context "when the association autobuilds" do
|
220
220
|
|
221
221
|
let(:passport) do
|
222
222
|
Passport.new
|
@@ -236,11 +236,11 @@ describe Mongoid::Association::Accessors do
|
|
236
236
|
Person.new
|
237
237
|
end
|
238
238
|
|
239
|
-
context "when autobuilding the
|
239
|
+
context "when autobuilding the association" do
|
240
240
|
|
241
|
-
context "when the
|
241
|
+
context "when the association is an embeds one" do
|
242
242
|
|
243
|
-
context "when the
|
243
|
+
context "when the association does not exist" do
|
244
244
|
|
245
245
|
let!(:passport) do
|
246
246
|
person.passport
|
@@ -255,7 +255,7 @@ describe Mongoid::Association::Accessors do
|
|
255
255
|
end
|
256
256
|
end
|
257
257
|
|
258
|
-
context "when the
|
258
|
+
context "when the association exists" do
|
259
259
|
|
260
260
|
let!(:passport) do
|
261
261
|
person.build_passport(number: "123123321")
|
@@ -264,16 +264,17 @@ describe Mongoid::Association::Accessors do
|
|
264
264
|
it "does not build a new document" do
|
265
265
|
expect(person.passport).to eq(passport)
|
266
266
|
end
|
267
|
+
|
267
268
|
end
|
268
269
|
end
|
269
270
|
|
270
|
-
context "when the
|
271
|
+
context "when the association is an embedded in" do
|
271
272
|
|
272
273
|
let(:passport) do
|
273
274
|
Passport.new
|
274
275
|
end
|
275
276
|
|
276
|
-
context "when the
|
277
|
+
context "when the association does not exist" do
|
277
278
|
|
278
279
|
let(:person) do
|
279
280
|
passport.person
|
@@ -284,7 +285,7 @@ describe Mongoid::Association::Accessors do
|
|
284
285
|
end
|
285
286
|
end
|
286
287
|
|
287
|
-
context "when the
|
288
|
+
context "when the association exists" do
|
288
289
|
|
289
290
|
let!(:person) do
|
290
291
|
passport.build_person(title: "sir")
|
@@ -296,9 +297,9 @@ describe Mongoid::Association::Accessors do
|
|
296
297
|
end
|
297
298
|
end
|
298
299
|
|
299
|
-
context "when the
|
300
|
+
context "when the association is a has one" do
|
300
301
|
|
301
|
-
context "when the
|
302
|
+
context "when the association does not exist" do
|
302
303
|
|
303
304
|
let(:book) do
|
304
305
|
person.book
|
@@ -309,7 +310,7 @@ describe Mongoid::Association::Accessors do
|
|
309
310
|
end
|
310
311
|
end
|
311
312
|
|
312
|
-
context "when the
|
313
|
+
context "when the association exists" do
|
313
314
|
|
314
315
|
let!(:book) do
|
315
316
|
person.build_book(title: "art of war")
|
@@ -321,13 +322,13 @@ describe Mongoid::Association::Accessors do
|
|
321
322
|
end
|
322
323
|
end
|
323
324
|
|
324
|
-
context "when the
|
325
|
+
context "when the association is a belongs to" do
|
325
326
|
|
326
327
|
let(:book) do
|
327
328
|
Book.new
|
328
329
|
end
|
329
330
|
|
330
|
-
context "when the
|
331
|
+
context "when the association does not exist" do
|
331
332
|
|
332
333
|
let(:person) do
|
333
334
|
book.person
|
@@ -338,7 +339,7 @@ describe Mongoid::Association::Accessors do
|
|
338
339
|
end
|
339
340
|
end
|
340
341
|
|
341
|
-
context "when the
|
342
|
+
context "when the association exists" do
|
342
343
|
|
343
344
|
let!(:person) do
|
344
345
|
book.build_person(title: "sir")
|
@@ -351,13 +352,13 @@ describe Mongoid::Association::Accessors do
|
|
351
352
|
end
|
352
353
|
end
|
353
354
|
|
354
|
-
context "when the
|
355
|
+
context "when the association is not polymorphic" do
|
355
356
|
|
356
357
|
let(:person) do
|
357
358
|
Person.create
|
358
359
|
end
|
359
360
|
|
360
|
-
context "when the
|
361
|
+
context "when the association is a many to many" do
|
361
362
|
|
362
363
|
let!(:preference) do
|
363
364
|
Preference.create(name: "Setting")
|
@@ -367,7 +368,7 @@ describe Mongoid::Association::Accessors do
|
|
367
368
|
person.preferences << Preference.last
|
368
369
|
end
|
369
370
|
|
370
|
-
context "when reloading the
|
371
|
+
context "when reloading the association directly" do
|
371
372
|
|
372
373
|
let(:preferences) do
|
373
374
|
person.preferences(true)
|
@@ -409,7 +410,7 @@ describe Mongoid::Association::Accessors do
|
|
409
410
|
end
|
410
411
|
end
|
411
412
|
|
412
|
-
context "when the
|
413
|
+
context "when the association is a many to one" do
|
413
414
|
|
414
415
|
let!(:post) do
|
415
416
|
Post.create(title: "First!")
|
@@ -419,7 +420,7 @@ describe Mongoid::Association::Accessors do
|
|
419
420
|
person.posts << Post.last
|
420
421
|
end
|
421
422
|
|
422
|
-
context "when reloading the
|
423
|
+
context "when reloading the association directly" do
|
423
424
|
|
424
425
|
let(:posts) do
|
425
426
|
person.posts(true)
|
@@ -461,7 +462,7 @@ describe Mongoid::Association::Accessors do
|
|
461
462
|
end
|
462
463
|
end
|
463
464
|
|
464
|
-
context "when the
|
465
|
+
context "when the association is a references one" do
|
465
466
|
|
466
467
|
let!(:game) do
|
467
468
|
Game.create(name: "Centipeded")
|
@@ -471,7 +472,7 @@ describe Mongoid::Association::Accessors do
|
|
471
472
|
person.game = Game.last
|
472
473
|
end
|
473
474
|
|
474
|
-
context "when reloading the
|
475
|
+
context "when reloading the association directly" do
|
475
476
|
|
476
477
|
let(:reloaded_game) do
|
477
478
|
person.game(true)
|
@@ -514,7 +515,7 @@ describe Mongoid::Association::Accessors do
|
|
514
515
|
end
|
515
516
|
end
|
516
517
|
|
517
|
-
context "when the
|
518
|
+
context "when the association is polymorphic" do
|
518
519
|
|
519
520
|
context "when there's a single references many/one" do
|
520
521
|
|
@@ -568,9 +569,183 @@ describe Mongoid::Association::Accessors do
|
|
568
569
|
end
|
569
570
|
end
|
570
571
|
end
|
572
|
+
|
573
|
+
context 'when projecting' do
|
574
|
+
context 'embeds_one' do
|
575
|
+
|
576
|
+
let!(:person) do
|
577
|
+
Person.create!(passport: Passport.new(number: "123123321", country: "USA"))
|
578
|
+
end
|
579
|
+
|
580
|
+
context "when the record is queried with the embedded association projected" do
|
581
|
+
let(:persisted_person) { Person.only(:passport).first }
|
582
|
+
|
583
|
+
it 'creates an accessor for the projected embedded document' do
|
584
|
+
expect(persisted_person.passport.number).to eq("123123321")
|
585
|
+
expect(persisted_person.passport.country).to eq("USA")
|
586
|
+
end
|
587
|
+
end
|
588
|
+
|
589
|
+
context 'when the record is queried with a field on the embedded association projected' do
|
590
|
+
let(:persisted_person) { Person.only("pass.number").first }
|
591
|
+
|
592
|
+
it 'creates an accessor for the projected field on the embedded document' do
|
593
|
+
expect(persisted_person.passport.number).to eq("123123321")
|
594
|
+
end
|
595
|
+
|
596
|
+
it 'does not create an accessor for another field on the embedded document' do
|
597
|
+
expect do
|
598
|
+
persisted_person.passport.country
|
599
|
+
end.to raise_error(ActiveModel::MissingAttributeError)
|
600
|
+
end
|
601
|
+
end
|
602
|
+
|
603
|
+
context 'when projecting association and a field in association' do
|
604
|
+
shared_examples 'is prohibited on 4.4+ server' do
|
605
|
+
context '4.4 server and higher' do
|
606
|
+
min_server_version '4.4'
|
607
|
+
|
608
|
+
it 'is not allowed by server' do
|
609
|
+
lambda do
|
610
|
+
persisted_person
|
611
|
+
end.should raise_error(Mongo::Error::OperationFailure, /Path collision at pass/)
|
612
|
+
end
|
613
|
+
end
|
614
|
+
end
|
615
|
+
|
616
|
+
context 'association then field' do
|
617
|
+
let(:persisted_person) { Person.only(:pass, "pass.number").first }
|
618
|
+
|
619
|
+
context '4.2 server and lower' do
|
620
|
+
max_server_version '4.2'
|
621
|
+
|
622
|
+
it 'creates an accessor for the projected field on the embedded document' do
|
623
|
+
expect(persisted_person.passport.number).to eq("123123321")
|
624
|
+
end
|
625
|
+
|
626
|
+
it 'does not create an accessor for another field on the embedded document' do
|
627
|
+
expect do
|
628
|
+
persisted_person.passport.country
|
629
|
+
end.to raise_error(ActiveModel::MissingAttributeError)
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
include_examples 'is prohibited on 4.4+ server'
|
634
|
+
end
|
635
|
+
|
636
|
+
context 'field then association' do
|
637
|
+
let(:persisted_person) { Person.only('pass.number', :pass).first }
|
638
|
+
|
639
|
+
context '4.2 server and lower' do
|
640
|
+
max_server_version '4.2'
|
641
|
+
|
642
|
+
it 'creates an accessor for the projected field on the embedded document' do
|
643
|
+
expect(persisted_person.passport.number).to eq("123123321")
|
644
|
+
end
|
645
|
+
|
646
|
+
it 'retrieves other fields' do
|
647
|
+
persisted_person.passport.country.should == 'USA'
|
648
|
+
end
|
649
|
+
end
|
650
|
+
|
651
|
+
include_examples 'is prohibited on 4.4+ server'
|
652
|
+
end
|
653
|
+
end
|
654
|
+
end
|
655
|
+
|
656
|
+
context 'embeds_many' do
|
657
|
+
|
658
|
+
let!(:person) do
|
659
|
+
Person.create!(phone_numbers: [
|
660
|
+
Phone.new(number: '111-111-1111', landline: true),
|
661
|
+
])
|
662
|
+
end
|
663
|
+
|
664
|
+
context 'when the record is queried with the embedded association projected' do
|
665
|
+
let(:persisted_person) { Person.only(:phone_numbers).first }
|
666
|
+
|
667
|
+
it 'creates an accessor for the embedded document' do
|
668
|
+
expect(persisted_person.phone_numbers.first.number).to eq('111-111-1111')
|
669
|
+
expect(persisted_person.phone_numbers.first.landline).to be true
|
670
|
+
end
|
671
|
+
end
|
672
|
+
|
673
|
+
shared_examples 'allows access to field of projected association' do
|
674
|
+
it 'creates an accessor for the embedded document' do
|
675
|
+
expect(persisted_person.phone_numbers.first).to be_a_kind_of(Phone)
|
676
|
+
end
|
677
|
+
|
678
|
+
it 'creates an accessor for the projected field on the embedded document' do
|
679
|
+
expect(persisted_person.phone_numbers.first.number).to eq('111-111-1111')
|
680
|
+
end
|
681
|
+
end
|
682
|
+
|
683
|
+
context 'when the record is queried with a field on the embedded association projected' do
|
684
|
+
let(:persisted_person) { Person.only("phone_numbers.number").first }
|
685
|
+
|
686
|
+
include_examples 'allows access to field of projected association'
|
687
|
+
|
688
|
+
it 'does not create an accessor for another field on the embedded document' do
|
689
|
+
expect do
|
690
|
+
persisted_person.phone_numbers.first.landline
|
691
|
+
end.to raise_error(ActiveModel::MissingAttributeError)
|
692
|
+
end
|
693
|
+
end
|
694
|
+
|
695
|
+
context 'when projecting association and a field in association' do
|
696
|
+
|
697
|
+
shared_examples 'is prohibited on 4.4+ server' do
|
698
|
+
context '4.4 server and higher' do
|
699
|
+
min_server_version '4.4'
|
700
|
+
|
701
|
+
it 'is not allowed by server' do
|
702
|
+
lambda do
|
703
|
+
persisted_person
|
704
|
+
end.should raise_error(Mongo::Error::OperationFailure, /Path collision at phone_numbers/)
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|
708
|
+
|
709
|
+
context 'association then field' do
|
710
|
+
let(:persisted_person) { Person.only(:phone_numbers, 'phone_numbers.number').first }
|
711
|
+
|
712
|
+
context '4.2 server and lower' do
|
713
|
+
max_server_version '4.2'
|
714
|
+
|
715
|
+
include_examples 'allows access to field of projected association'
|
716
|
+
|
717
|
+
it 'does not create an accessor for another field on the embedded document' do
|
718
|
+
expect do
|
719
|
+
persisted_person.phone_numbers.first.landline
|
720
|
+
end.to raise_error(ActiveModel::MissingAttributeError)
|
721
|
+
end
|
722
|
+
|
723
|
+
end
|
724
|
+
|
725
|
+
include_examples 'is prohibited on 4.4+ server'
|
726
|
+
end
|
727
|
+
|
728
|
+
context 'field then association' do
|
729
|
+
let(:persisted_person) { Person.only('phone_numbers.number', :phone_numbers).first }
|
730
|
+
|
731
|
+
context '4.2 server and lower' do
|
732
|
+
max_server_version '4.2'
|
733
|
+
|
734
|
+
include_examples 'allows access to field of projected association'
|
735
|
+
|
736
|
+
it 'retrieves all fields of association' do
|
737
|
+
persisted_person.phone_numbers.first.landline.should be true
|
738
|
+
end
|
739
|
+
end
|
740
|
+
|
741
|
+
include_examples 'is prohibited on 4.4+ server'
|
742
|
+
end
|
743
|
+
end
|
744
|
+
end
|
745
|
+
end
|
571
746
|
end
|
572
747
|
|
573
|
-
context "when setting
|
748
|
+
context "when setting associations to empty values" do
|
574
749
|
|
575
750
|
context "when the document is a referenced in" do
|
576
751
|
|
@@ -578,7 +753,7 @@ describe Mongoid::Association::Accessors do
|
|
578
753
|
Post.new
|
579
754
|
end
|
580
755
|
|
581
|
-
context "when setting the
|
756
|
+
context "when setting the association directly" do
|
582
757
|
|
583
758
|
before do
|
584
759
|
post.person = ""
|
@@ -607,7 +782,7 @@ describe Mongoid::Association::Accessors do
|
|
607
782
|
Person.new
|
608
783
|
end
|
609
784
|
|
610
|
-
context "when setting the
|
785
|
+
context "when setting the association directly" do
|
611
786
|
|
612
787
|
before do
|
613
788
|
person.game = ""
|
@@ -743,7 +918,7 @@ describe Mongoid::Association::Accessors do
|
|
743
918
|
|
744
919
|
before do
|
745
920
|
game.person_id = ""
|
746
|
-
game.save
|
921
|
+
game.save!
|
747
922
|
end
|
748
923
|
|
749
924
|
it "sets the foreign key to empty" do
|
@@ -755,7 +930,7 @@ describe Mongoid::Association::Accessors do
|
|
755
930
|
|
756
931
|
before do
|
757
932
|
game.person_id = person.id.to_s
|
758
|
-
game.save
|
933
|
+
game.save!
|
759
934
|
end
|
760
935
|
|
761
936
|
it "sets the foreign key as ObjectID" do
|
@@ -767,7 +942,7 @@ describe Mongoid::Association::Accessors do
|
|
767
942
|
|
768
943
|
before do
|
769
944
|
game.person_id = person.id
|
770
|
-
game.save
|
945
|
+
game.save!
|
771
946
|
end
|
772
947
|
|
773
948
|
it "keeps the foreign key as ObjectID" do
|
@@ -775,30 +950,30 @@ describe Mongoid::Association::Accessors do
|
|
775
950
|
end
|
776
951
|
end
|
777
952
|
|
778
|
-
context "when setting ids multiple times on the
|
953
|
+
context "when setting ids multiple times on the association itself" do
|
779
954
|
|
780
955
|
before do
|
781
956
|
game.person = person.id
|
782
957
|
game.person = person.id
|
783
958
|
end
|
784
959
|
|
785
|
-
it "sets the
|
960
|
+
it "sets the association foreign key" do
|
786
961
|
expect(game.person_id).to eq(person.id)
|
787
962
|
end
|
788
963
|
|
789
|
-
it "sets the appropriate
|
964
|
+
it "sets the appropriate association" do
|
790
965
|
expect(game.person).to eq(person)
|
791
966
|
end
|
792
967
|
end
|
793
968
|
end
|
794
969
|
|
795
|
-
context 'when setting the
|
970
|
+
context 'when setting the association more than once' do
|
796
971
|
|
797
972
|
let(:person) do
|
798
973
|
Person.create
|
799
974
|
end
|
800
975
|
|
801
|
-
context 'when the
|
976
|
+
context 'when the association is a references one' do
|
802
977
|
|
803
978
|
let(:game) do
|
804
979
|
Game.create
|
@@ -814,7 +989,7 @@ describe Mongoid::Association::Accessors do
|
|
814
989
|
end
|
815
990
|
end
|
816
991
|
|
817
|
-
context 'when the
|
992
|
+
context 'when the association is a references many' do
|
818
993
|
|
819
994
|
let!(:preference) do
|
820
995
|
Preference.create(name: "Setting")
|
@@ -829,7 +1004,7 @@ describe Mongoid::Association::Accessors do
|
|
829
1004
|
end
|
830
1005
|
end
|
831
1006
|
|
832
|
-
context 'when the
|
1007
|
+
context 'when the association is an embeds one' do
|
833
1008
|
|
834
1009
|
let!(:name) do
|
835
1010
|
Name.new
|
@@ -845,7 +1020,7 @@ describe Mongoid::Association::Accessors do
|
|
845
1020
|
end
|
846
1021
|
end
|
847
1022
|
|
848
|
-
context 'when the
|
1023
|
+
context 'when the association is an embeds many' do
|
849
1024
|
|
850
1025
|
let!(:address) do
|
851
1026
|
Address.new
|