mongoid-fixture_set 1.3.3 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/fixture_set/version.rb +1 -1
- data/lib/mongoid/fixture_set.rb +9 -0
- data/test/fixtures/users.yml +1 -0
- data/test/models/address.rb +2 -0
- data/test/mongoid/fixture_set_test.rb +1 -0
- data/test/test_helper.rb +2 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6fa5b7c0ce9518513b4baf37fa19df5de59fc0d2
|
4
|
+
data.tar.gz: a6aa891d1ea4fd80823446e0cacd23db001bae17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6f93d1093726d92e7dc71980c6c0c77a47cb9ace029c3fa55d4550ff0c651a27125aa7003a2be1b4636663f07783bb0d21ccecb41d8de3a113ad0b50e06d7a9
|
7
|
+
data.tar.gz: 96515b63d450e5783d7a0cd08daf48dd5347e1826c29518de3523018d20ac896b9b0ba36d2f9f0fbdf937e74d1ae12266cd320d1e4a11f0a034feb957c35ac77
|
data/lib/mongoid/fixture_set.rb
CHANGED
@@ -128,6 +128,15 @@ module Mongoid
|
|
128
128
|
embedded_document_set_default_values(embedded, document[name][i])
|
129
129
|
end
|
130
130
|
end
|
131
|
+
when :belongs_to
|
132
|
+
if is_new && document.attributes[name]
|
133
|
+
value = document.attributes.delete(name)
|
134
|
+
if value.is_a?(Hash)
|
135
|
+
raise Mongoid::FixtureSet::FixtureError.new "Unable to create nested document inside an embedded document"
|
136
|
+
end
|
137
|
+
doc = find_or_create_document(relation.class_name, value)
|
138
|
+
document.attributes[relation.foreign_key] = doc.id
|
139
|
+
end
|
131
140
|
end
|
132
141
|
end
|
133
142
|
end
|
data/test/fixtures/users.yml
CHANGED
data/test/models/address.rb
CHANGED
@@ -68,6 +68,7 @@ module Mongoid
|
|
68
68
|
test_nested_has_many_creation = Group.find_by(name: 'Test nested has_many creation')
|
69
69
|
User.find_by(firstname: 'Created in nested group')
|
70
70
|
|
71
|
+
assert_equal user1.address.organisation, orga1
|
71
72
|
assert_equal 1, user1.homes.count
|
72
73
|
assert_equal geoffroy, f_geoffroy.find
|
73
74
|
assert_equal 3, print.users.count
|
data/test/test_helper.rb
CHANGED
@@ -14,6 +14,8 @@ Mongoid.load!("#{File.dirname(__FILE__)}/mongoid.yml", "test")
|
|
14
14
|
|
15
15
|
Dir["#{File.dirname(__FILE__)}/models/*.rb"].each { |f| require f }
|
16
16
|
|
17
|
+
ActiveSupport::TestCase.test_order = :random
|
18
|
+
|
17
19
|
class BaseTest < ActiveSupport::TestCase
|
18
20
|
def teardown
|
19
21
|
Mongoid::Sessions.default.use('mongoid_fixture_set_test').drop
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-fixture_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Geoffroy Planquart
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,9 +77,9 @@ files:
|
|
77
77
|
- test/models/school.rb
|
78
78
|
- test/models/test.rb
|
79
79
|
- test/models/home.rb
|
80
|
-
- test/models/address.rb
|
81
80
|
- test/models/user.rb
|
82
81
|
- test/models/item.rb
|
82
|
+
- test/models/address.rb
|
83
83
|
- test/mongoid.yml
|
84
84
|
- test/fixtures/schools.yml
|
85
85
|
- test/fixtures/organisations.yml
|
@@ -87,9 +87,9 @@ files:
|
|
87
87
|
- test/fixtures/not_models.yml
|
88
88
|
- test/fixtures/groups.yml
|
89
89
|
- test/fixtures/users.yml
|
90
|
-
- test/test_helper.rb
|
91
90
|
- test/load_once_fixtures/tests.yml
|
92
91
|
- test/nested_polymorphic_relation_fixtures/groups.yml
|
92
|
+
- test/test_helper.rb
|
93
93
|
homepage: https://github.com/Aethelflaed/mongoid-fixture_set
|
94
94
|
licenses:
|
95
95
|
- MIT
|
@@ -123,9 +123,9 @@ test_files:
|
|
123
123
|
- test/models/school.rb
|
124
124
|
- test/models/test.rb
|
125
125
|
- test/models/home.rb
|
126
|
-
- test/models/address.rb
|
127
126
|
- test/models/user.rb
|
128
127
|
- test/models/item.rb
|
128
|
+
- test/models/address.rb
|
129
129
|
- test/mongoid.yml
|
130
130
|
- test/fixtures/schools.yml
|
131
131
|
- test/fixtures/organisations.yml
|
@@ -133,7 +133,7 @@ test_files:
|
|
133
133
|
- test/fixtures/not_models.yml
|
134
134
|
- test/fixtures/groups.yml
|
135
135
|
- test/fixtures/users.yml
|
136
|
-
- test/test_helper.rb
|
137
136
|
- test/load_once_fixtures/tests.yml
|
138
137
|
- test/nested_polymorphic_relation_fixtures/groups.yml
|
138
|
+
- test/test_helper.rb
|
139
139
|
has_rdoc:
|