fixture_farm 0.1.4 → 0.1.6
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 +4 -4
- data/lib/fixture_farm/fixture_recorder.rb +9 -2
- data/lib/fixture_farm/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c681a08bddfef41bec83f8fc4693fc299f5b0f750d1904a652d2adac306aad51
|
4
|
+
data.tar.gz: b1a19637eab90fe234dc45eba360963a5342b1923f7085d75a19df4678829669
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 194b052b53935e3e74c7f16818b83f8536c836ac09d3911a966f50591b0931348d75a4448fafcfaa657295855c016902df0bed068a798e90ff478d841f0a5427
|
7
|
+
data.tar.gz: d1da130e48e0fa0802edb690600482b897985fa8928be6189b5c13c3b74401df67d5963e9c183387e6dd309826e1fc20b989b7b8c4348ec3cf0394b3e9beb075
|
@@ -115,15 +115,17 @@ module FixtureFarm
|
|
115
115
|
if belongs_to_association
|
116
116
|
associated_model_instance = find_assiciated_model_instance(model_instance, belongs_to_association)
|
117
117
|
|
118
|
+
next unless associated_model_instance
|
119
|
+
|
118
120
|
associated_fixture_name = named_new_fixtures.find do |_, fixture_model|
|
119
121
|
fixture_model.id == associated_model_instance.id
|
120
122
|
end&.first || associated_model_instance.fixture_name
|
121
123
|
|
122
124
|
[belongs_to_association.name.to_s, associated_fixture_name]
|
123
|
-
|
125
|
+
elsif model_instance.column_for_attribute(k).type
|
124
126
|
[k, serialize_attributes(v)]
|
125
127
|
end
|
126
|
-
end.to_h
|
128
|
+
end.compact.to_h
|
127
129
|
|
128
130
|
yaml_attributes.delete('created_at') if yaml_attributes['created_at'] == '<%= Time.zone.now %>'
|
129
131
|
yaml_attributes.delete('updated_at') if yaml_attributes['updated_at'] == '<%= Time.zone.now %>'
|
@@ -154,6 +156,11 @@ module FixtureFarm
|
|
154
156
|
|
155
157
|
id = model_instance.public_send(association.foreign_key)
|
156
158
|
associated_model_class.unscoped.find(id)
|
159
|
+
rescue ActiveRecord::RecordNotFound
|
160
|
+
# In case of `belongs_to optional: true`, the associated record
|
161
|
+
# may have already been deleted by the time we record fixtures.
|
162
|
+
# We don't want to fail in this case.
|
163
|
+
nil
|
157
164
|
end
|
158
165
|
|
159
166
|
def serialize_attributes(value)
|
data/lib/fixture_farm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fixture_farm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- artemave
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '6.2'
|
27
|
-
description:
|
27
|
+
description:
|
28
28
|
email:
|
29
29
|
- mr@artem.rocks
|
30
30
|
executables:
|
@@ -52,7 +52,7 @@ licenses:
|
|
52
52
|
metadata:
|
53
53
|
homepage_uri: https://github.com/featurist/fixture_farm
|
54
54
|
source_code_uri: https://github.com/featurist/fixture_farm.git
|
55
|
-
post_install_message:
|
55
|
+
post_install_message:
|
56
56
|
rdoc_options: []
|
57
57
|
require_paths:
|
58
58
|
- lib
|
@@ -67,8 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
71
|
-
signing_key:
|
70
|
+
rubygems_version: 3.4.10
|
71
|
+
signing_key:
|
72
72
|
specification_version: 4
|
73
73
|
summary: Generate rails fixutures while browsing
|
74
74
|
test_files: []
|