fixture_farm 0.2.1 → 0.2.3
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c38b9ab62c74bb939508d55c18a39a6ba64a879531a8c2784ed5ad7b67f5945
|
4
|
+
data.tar.gz: 2a0984353f13d7601f7aa51bb00bcdb7260a773ff5e96aa944d6f5627182ad50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6bf3e7eddd7aa146c9eb536888f085ec77e63f976f09eae9cf353ded3f6345cc44471d74e00f425398efd16cee2147e99e9799c0e176dd0562474df2288eef3
|
7
|
+
data.tar.gz: 8db0f16307c09a07c669980cfa3156d765945ba201a658deb3744c8dc5163555129658e1ed83b6ef2f76fff616fef0432649ad19ca87fb794988a6699161b338
|
@@ -7,7 +7,7 @@ module FixtureFarm
|
|
7
7
|
|
8
8
|
return nil unless File.exist?(fixtures_file_path)
|
9
9
|
|
10
|
-
fixtures = YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess])
|
10
|
+
fixtures = YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) || {}
|
11
11
|
fixtures.keys.find do |key|
|
12
12
|
ActiveRecord::FixtureSet.identify(key) == id
|
13
13
|
end
|
@@ -157,7 +157,11 @@ module FixtureFarm
|
|
157
157
|
|
158
158
|
fixtures_file_path = model_instance.fixtures_file_path
|
159
159
|
|
160
|
-
fixtures = File.exist?(fixtures_file_path)
|
160
|
+
fixtures = if File.exist?(fixtures_file_path)
|
161
|
+
YAML.load_file(fixtures_file_path, permitted_classes: [ActiveSupport::HashWithIndifferentAccess]) || {}
|
162
|
+
else
|
163
|
+
{}
|
164
|
+
end
|
161
165
|
fixtures[new_fixture_name] = yaml_attributes
|
162
166
|
|
163
167
|
FileUtils.mkdir_p(fixtures_file_path.dirname)
|
@@ -173,13 +177,14 @@ module FixtureFarm
|
|
173
177
|
# This, in particular, turns off ActsAsTenant, that otherwise
|
174
178
|
# might return no record if the tenant has changed by this point.
|
175
179
|
def find_associated_model_instance(model_instance, association)
|
180
|
+
id = model_instance.public_send(association.foreign_key) or return
|
181
|
+
|
176
182
|
associated_model_class = if association.polymorphic?
|
177
183
|
model_instance.public_send(association.foreign_type).safe_constantize
|
178
184
|
else
|
179
185
|
association.klass
|
180
186
|
end
|
181
187
|
|
182
|
-
id = model_instance.public_send(association.foreign_key)
|
183
188
|
associated_model_class.unscoped.find(id)
|
184
189
|
rescue ActiveRecord::RecordNotFound
|
185
190
|
# In case of `belongs_to optional: true`, the associated record
|
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.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- artemave
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|