fixture_record 0.1.0.pre.rc → 0.1.1.pre.rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f064d7bf54652f52a22d8cd269857e20a5b1478d62e56bfc9caf8b49b9835bfe
4
- data.tar.gz: 169cec159195200f218601686768081c1f8097f2a29bb84ccc39a69d08fb93a1
3
+ metadata.gz: 6720df231526a9d9119a2146337d2c029e5c1479eaea6f88b17df9ce8e1222fc
4
+ data.tar.gz: '0579da7648101dbdf1f3ca02add8ac87a23192fb2ba635ac6749f87e394d062e'
5
5
  SHA512:
6
- metadata.gz: 5829f715c8d443a626cb5752b5f269ef6d8effbc2e8f34af7dcdcb847d9aac419876a282610802d8fb8ed9b25b4a63d3264bb8dbf717ee5c03451692663d6dfd
7
- data.tar.gz: 85fa9ff11cf929a973ad4aa1b575003e2832d1bf1cbe49676eafee9753d05c86664907d1733b914caefd9ef7dc76ae2282b348036301be541fe5c6076a8da831
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
@@ -1,3 +1,3 @@
1
1
  module FixtureRecord
2
- VERSION = "0.1.0-rc"
2
+ VERSION = "0.1.1-rc"
3
3
  end
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.0.pre.rc
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-24 00:00:00.000000000 Z
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails