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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a4711e5c5ca0eaaebf6d44bfa7751f09e4ff1fc6b5969e4ed4af04d43469069
4
- data.tar.gz: 6ed3b3e4961f21fb4435d3b571b9ab04e78cf3c7cdfe9cce8dc7c9021e663ae0
3
+ metadata.gz: c681a08bddfef41bec83f8fc4693fc299f5b0f750d1904a652d2adac306aad51
4
+ data.tar.gz: b1a19637eab90fe234dc45eba360963a5342b1923f7085d75a19df4678829669
5
5
  SHA512:
6
- metadata.gz: 2ddd75078a5228b34a5d3034d339ddff5fefccc1f003595a96bbae9f97e7ae334c2833d29cb979e9cd890fb77c1b89d95f612fc0a55996bd2f9b22e218d528e8
7
- data.tar.gz: 7d53ed3b3617c6456fb515b17f6ce87361349c79ee370ee9cc42f2ae1d9f4a4fd383c45f5f4c6fee3434c485e3122d579a540e4c346ef62c1d2914564ba65093
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
- else
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)
@@ -1,3 +1,3 @@
1
1
  module FixtureFarm
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.6'
3
3
  end
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
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: 2022-09-09 00:00:00.000000000 Z
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.1.6
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: []