fixture_record 0.1.0.pre.rc → 0.1.1.pre.rc
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/lib/fixture_record/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6720df231526a9d9119a2146337d2c029e5c1479eaea6f88b17df9ce8e1222fc
|
4
|
+
data.tar.gz: '0579da7648101dbdf1f3ca02add8ac87a23192fb2ba635ac6749f87e394d062e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1de630e483468ae70fb9e41351f5607fee4516ffea36f9008860a801c7a95c2347d608bf2c6d50c559d302eac7eb0deb2d606cd71e4914e8c8728e09d3bb60d1
|
7
|
+
data.tar.gz: 6d21e6b3cd38b97122fdf567df30b9d657df3a7787e481ed79343dd691edfd48882b353f96fb3edc2693b7336b67e5c2448ec75bd324dd61c0453708ad5ea7e4
|
data/README.md
CHANGED
@@ -86,6 +86,25 @@ post_12:
|
|
86
86
|
author_id: 49
|
87
87
|
```
|
88
88
|
|
89
|
+
### Through Associations
|
90
|
+
`FixtureRecord` will automatically attempt to infill any missing associations when an association utilizes a `through` option. Taking the blog example, consider a `User` class:
|
91
|
+
```ruby
|
92
|
+
class User
|
93
|
+
has_many :posts
|
94
|
+
has_many :post_comments, through: :posts, source: :comments
|
95
|
+
has_many :commenting_users, through: :post_comments, source: :user
|
96
|
+
end
|
97
|
+
```
|
98
|
+
Because of through association infilling the following 3 lines will produce identical results:
|
99
|
+
```ruby
|
100
|
+
user.to_test_fixture(posts: [comments: :users])
|
101
|
+
|
102
|
+
user.to_test_fixture(:posts, :post_comments, :commenting_users)
|
103
|
+
|
104
|
+
user.to_test_fixutre(:commenting_users)
|
105
|
+
```
|
106
|
+
The reason the third example will infill the other associations is because those associations are required to create a clear path between the originating record and the final records. Without those intermediary associations, the `:commenting_users` would be orphaned from the `user` record.
|
107
|
+
|
89
108
|
### FixtureRecord::Naming
|
90
109
|
There might be instances where a record was used for a particular test fixture and you want to use this same record again for a different test case but want to keep the data isolated. `FixtureRecord::Naming` (automatically included with FixtureRecord) provides`fixture_record_prefix` and `fixture_record_suffix`. These values are propagated to the associated records when calling `to_test_fixture`.
|
91
110
|
```ruby
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixture_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1.pre.rc
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brad Schrag
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|