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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 954c1649aade85a048af51c936b5243633c71bb1
4
- data.tar.gz: a91c7e1f646481b7da07d0e11dcced34e1ab9bad
3
+ metadata.gz: 6fa5b7c0ce9518513b4baf37fa19df5de59fc0d2
4
+ data.tar.gz: a6aa891d1ea4fd80823446e0cacd23db001bae17
5
5
  SHA512:
6
- metadata.gz: 025d7524855339e96cdf1228fbc0e2019c5ca38c992c346a746944715c1f9b90c063e476a9439636bd0f3045afe74cce8aa96d8680e06ba98ce7294c9ea35b09
7
- data.tar.gz: 4ab38d9670943e6b4bd08c5ce6200a225a0b375122e171e2890dafb0ab9c771007a6654a14fb99845b31ca8f0eae7973060188c86f5ba4eea237af37b156a94d
6
+ metadata.gz: f6f93d1093726d92e7dc71980c6c0c77a47cb9ace029c3fa55d4550ff0c651a27125aa7003a2be1b4636663f07783bb0d21ccecb41d8de3a113ad0b50e06d7a9
7
+ data.tar.gz: 96515b63d450e5783d7a0cd08daf48dd5347e1826c29518de3523018d20ac896b9b0ba36d2f9f0fbdf937e74d1ae12266cd320d1e4a11f0a034feb957c35ac77
@@ -1,6 +1,6 @@
1
1
  module Mongoid
2
2
  class FixtureSet
3
- VERSION = '1.3.3'
3
+ VERSION = '1.4.0'
4
4
  end
5
5
  end
6
6
 
@@ -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
@@ -22,6 +22,7 @@ user1:
22
22
  lastname: Last
23
23
  address:
24
24
  city: Strasbourg
25
+ organisation: orga1
25
26
  homes:
26
27
  - name: Home
27
28
  address:
@@ -5,5 +5,7 @@ class Address
5
5
 
6
6
  field :city
7
7
  field :real, type: Boolean, default: true
8
+
9
+ belongs_to :organisation
8
10
  end
9
11
 
@@ -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.3.3
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-06 00:00:00.000000000 Z
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: '4.0'
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: '4.0'
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: