fixturex 0.1.2 → 0.1.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: 969e8e5573328295b3bd63b0ec6ec2bef3f3462a613009f44ac5f8dfc9ba5c7d
4
- data.tar.gz: 02c925a94649f82fb08c7d5c1b555b10a95546054db19a864216717239da213d
3
+ metadata.gz: 4ad838e7a474e177400e7dc181b273ec0ee88d3a785ad94e60348a8b6bb6e8d3
4
+ data.tar.gz: d5c896e40834be325036a219fe6955a672becfc7cc67283ae37be20457c2e1a4
5
5
  SHA512:
6
- metadata.gz: 6477664978fff4a5ee9ceee56decf5c96ceadacba17f02c81f15adde91e1678b72b4bf183b64ddfd3333396cf5a3691c1015f0095c9e93f69e9bc29fe051f53f
7
- data.tar.gz: d7f085be682df75a9dd849c7dd1473d97d56bea48090738def17095ec11f409fb23c43e32e33516f6c4158e546130de460ee3b332ebd83ee4db67045d8da9e71
6
+ metadata.gz: b5b4b7a1068f0e9b98e4780f6cdc21e93ca1544f7934103c87a528922d98374f9503b779561ea49fc3d2c18e028b7bccb61d6b361667ce6b8bc3607b5ed1e713
7
+ data.tar.gz: 72df98e71b21abfa80403ded5d8a5549a5fd134fc24b76ff80e18d8771c46e4aee23312113a94b55b9c53b2e214a090835e03d2d333b6995c48f9e4528e63767
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fixturex (0.1.2)
4
+ fixturex (0.1.3)
5
5
  rails (>= 6.0)
6
6
 
7
7
  GEM
@@ -67,10 +67,11 @@ module Fixturex
67
67
 
68
68
  private
69
69
 
70
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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, Metrics/MethodLength
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
- model_class.reflect_on_all_associations(:has_many) +
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.name.to_s
122
+ end&.name&.to_s
118
123
  end
119
124
  end
120
125
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Fixturex
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fixturex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - artemave