fixturex 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/fixturex/tree_builder.rb +10 -5
- data/lib/fixturex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ad838e7a474e177400e7dc181b273ec0ee88d3a785ad94e60348a8b6bb6e8d3
|
4
|
+
data.tar.gz: d5c896e40834be325036a219fe6955a672becfc7cc67283ae37be20457c2e1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5b4b7a1068f0e9b98e4780f6cdc21e93ca1544f7934103c87a528922d98374f9503b779561ea49fc3d2c18e028b7bccb61d6b361667ce6b8bc3607b5ed1e713
|
7
|
+
data.tar.gz: 72df98e71b21abfa80403ded5d8a5549a5fd134fc24b76ff80e18d8771c46e4aee23312113a94b55b9c53b2e214a090835e03d2d333b6995c48f9e4528e63767
|
data/Gemfile.lock
CHANGED
@@ -67,10 +67,11 @@ module Fixturex
|
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
|
-
# rubocop:disable Metrics/AbcSize
|
70
|
+
# rubocop:disable Metrics/AbcSize
|
71
71
|
def nested_fixtures_locations(parent_fixture_model_class, parent_fixture_name)
|
72
72
|
associations_for_nested_models(parent_fixture_model_class).each_with_object([]) do |association, acc|
|
73
|
-
belongs_to_attribute = belongs_to_attribute_for_association(association)
|
73
|
+
next unless (belongs_to_attribute = belongs_to_attribute_for_association(association))
|
74
|
+
|
74
75
|
child_model_class = association_model_class(association)
|
75
76
|
model_fixtures = self.class.cache[association.class_name] ||= ModelFixtures.load(child_model_class)
|
76
77
|
|
@@ -83,7 +84,7 @@ module Fixturex
|
|
83
84
|
end
|
84
85
|
end
|
85
86
|
end
|
86
|
-
# rubocop:enable Metrics/AbcSize
|
87
|
+
# rubocop:enable Metrics/AbcSize
|
87
88
|
|
88
89
|
def association_model_class(association)
|
89
90
|
class_name = association.class_name
|
@@ -103,8 +104,12 @@ module Fixturex
|
|
103
104
|
end
|
104
105
|
|
105
106
|
def associations_for_nested_models(model_class)
|
106
|
-
|
107
|
+
(
|
108
|
+
model_class.reflect_on_all_associations(:has_many) +
|
107
109
|
model_class.reflect_on_all_associations(:has_one)
|
110
|
+
).reject do |association|
|
111
|
+
association.is_a?(ActiveRecord::Reflection::ThroughReflection)
|
112
|
+
end
|
108
113
|
end
|
109
114
|
|
110
115
|
def belongs_to_attribute_for_association(association)
|
@@ -114,7 +119,7 @@ module Fixturex
|
|
114
119
|
child_model_class = association_model_class(association)
|
115
120
|
child_model_class.reflect_on_all_associations(:belongs_to).find do |belongs_to_association|
|
116
121
|
belongs_to_association.class_name == association.active_record.name
|
117
|
-
end
|
122
|
+
end&.name&.to_s
|
118
123
|
end
|
119
124
|
end
|
120
125
|
end
|
data/lib/fixturex/version.rb
CHANGED