database_consistency 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86e5667ae277f41bb7a4e1125b7058680e236bee30b10bd43a56ae3c1b608c2a
4
- data.tar.gz: b72491a32de3e10f9ac92f1b711ec5c412776be44bb8f54502420be21ed2299d
3
+ metadata.gz: 6474192e36ae6bcd25dc149e1294ff9c791d2716e2dab3d94191b8c47dd81aef
4
+ data.tar.gz: d523c7bf119274212cb9da1ead5c04814e970157529e06f03c27b2d7ad2463da
5
5
  SHA512:
6
- metadata.gz: 40cde48b836130ccfe120ea2826260a794bc35edcca1ec24622b2f92066597d679a6132dc64904311cc655e0756eab82bb1fd92f6c6f4e821a3f27c3d4185b7e
7
- data.tar.gz: 8ed3b4f6e41c29f9d37323b6c8ecc79dc7d34cfe6eaa5c80982ec51d9fb61b58e520c1a809a0e63c1ef3a13627b5ff8fd1c99f3d38f6625bf7b7d9fec9ac2caf
6
+ metadata.gz: 9e90c491f1f0ced39b6ce7b66079586f6f42b0405214392f110ec04d6ee41fbcdd01031ac88fc3dfe662669ae3640957941013981c5965a97b6032d36271f105
7
+ data.tar.gz: f405932ab3023150e3353b5bfe08e6bb56c79b3af0d55a45c2f449c9dee45d1d44ac255e83fecac8b70d8ff967a1b8fe9fe23016446c53b84a27a12bcb666024
@@ -21,5 +21,16 @@ module DatabaseConsistency
21
21
  def check_inclusion?(array, element)
22
22
  array.include?(element.to_s) || array.include?(element.to_sym)
23
23
  end
24
+
25
+ def first_level_associations(model)
26
+ associations = model.reflect_on_all_associations
27
+
28
+ while model != ActiveRecord::Base && model.respond_to?(:reflect_on_all_associations)
29
+ model = model.superclass
30
+ associations -= model.reflect_on_all_associations
31
+ end
32
+
33
+ associations
34
+ end
24
35
  end
25
36
  end
@@ -12,7 +12,7 @@ module DatabaseConsistency
12
12
 
13
13
  def check
14
14
  Helper.models.flat_map do |model|
15
- model.reflect_on_all_associations.flat_map do |association|
15
+ Helper.first_level_associations(model).flat_map do |association|
16
16
  enabled_checkers.map do |checker_class|
17
17
  checker = checker_class.new(model, association)
18
18
  checker.report_if_enabled?(configuration)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '0.6.4'
4
+ VERSION = '0.6.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_consistency
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-27 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord