strict_associations 0.1.4 → 0.1.5
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/CHANGELOG.md +2 -2
- data/lib/strict_associations/validator.rb +10 -1
- data/lib/strict_associations/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: d3f819414a8d4be6870c5852a87d82ea0aa73c7f0fed2f1495a04c82b2af73c4
|
|
4
|
+
data.tar.gz: a6033ed16295800065be0325cddae7ecfa5c6d231f4c04242e3c25eec45a7345
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 16b986565c7ab65b619b9c2ee2ef764ebffa4462d054d1ff692bd10138791466f502c59386a168ef4a5d4647fcdd4a6a02f1619ce21927822303ed566e1b0939
|
|
7
|
+
data.tar.gz: b9a04a6e00b0b0c07d3cf1a5f62e855bbb7c04b820357e506c38ebf857ccfa242251556f63e39172501932b25446b028678947f8ff7b34d74ef1603c27fb4732
|
data/CHANGELOG.md
CHANGED
|
@@ -82,11 +82,18 @@ module StrictAssociations
|
|
|
82
82
|
def check_belongs_to_inverses(model, violations)
|
|
83
83
|
refs = model.reflect_on_all_associations(:belongs_to)
|
|
84
84
|
refs.each do |ref|
|
|
85
|
-
next if
|
|
85
|
+
next if ref.options[:strict] == false
|
|
86
|
+
next if model.strict_association_skipped?(ref.name)
|
|
86
87
|
next if ref.options[:polymorphic]
|
|
87
88
|
|
|
88
89
|
target = resolve_target(ref)
|
|
89
90
|
next unless target
|
|
91
|
+
# Skip only when BOTH definer and target are third-party.
|
|
92
|
+
# When target is an app model, we want to verify it defines the inverse.
|
|
93
|
+
# e.g. if a 3rd party model belongs_to an app model, we should enforce that
|
|
94
|
+
# our app's models defines a has_many so we avoid our records being blocked
|
|
95
|
+
# from deletion due to fk constraints.
|
|
96
|
+
next if third_party?(ref.active_record) && third_party?(target)
|
|
90
97
|
|
|
91
98
|
unless inverse_exists?(model, ref, target)
|
|
92
99
|
fk = ref.foreign_key
|
|
@@ -117,6 +124,7 @@ module StrictAssociations
|
|
|
117
124
|
|
|
118
125
|
target = resolve_target(ref)
|
|
119
126
|
next unless target
|
|
127
|
+
next if third_party?(target)
|
|
120
128
|
|
|
121
129
|
unless belongs_to_exists?(model, ref, target)
|
|
122
130
|
violations << Violation.new(
|
|
@@ -230,6 +238,7 @@ module StrictAssociations
|
|
|
230
238
|
end
|
|
231
239
|
|
|
232
240
|
def check_orphaned_foreign_keys(model, violations)
|
|
241
|
+
return if third_party?(model)
|
|
233
242
|
return unless owns_table?(model)
|
|
234
243
|
|
|
235
244
|
indexed_fk_columns = indexed_foreign_key_columns(model)
|