database_consistency 0.7.8 → 0.7.9

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: d3b93b80d81b10da730dbaf8cc523325150103fcae0f18ea4092baa03d8fb8ba
4
- data.tar.gz: 67a8a38c922d359f11699b703a340489a866e573b8714f1848bfee7900ecb280
3
+ metadata.gz: 2d2fdde533c08cebcdc19ded3a2e2b94587304aef759b6a8bee72bddc2ec0ece
4
+ data.tar.gz: 5df7c33b8a2cd32686dd3835514bab577eae10cb340709779bca20f942d6de76
5
5
  SHA512:
6
- metadata.gz: 187968d380947ce829f765bac635720b959346c53b3ef81a99eadb1555395767d457fcbb5fd325010656b418867d1b916170cf0bc5cf265e69c9228e61d1a01e
7
- data.tar.gz: 724d34742874b0b1f6e864dabe98624702409a26d39467292d64490d0757e4e4f7bfe428d0b6e9bf629ccac99abaaf1ba623cf674e1fd00215df5f39c200a512
6
+ metadata.gz: c9de96885025f37decdaf6d8fc566dc9f35da9c9a91500c11504c0202b6e28f9d8fbcd5f8a742fc841b42419dbf7ccdd841066eb144391910948a5fbf637fc22
7
+ data.tar.gz: 49088e8975bd3b2795ed97f00802ece5204c11b108bbbfa3eff10f52b1b176762094b8cb6fb414fca7dd1616e384974ca2adc847dee39b1902849bb8ee46c24e
@@ -25,7 +25,8 @@ module DatabaseConsistency
25
25
  # | provided | ok |
26
26
  # | missing | fail |
27
27
  #
28
- # We consider PresenceValidation, InclusionValidation or BelongsTo association using this column
28
+ # We consider PresenceValidation, InclusionValidation, ExclusionValidation with nil,
29
+ # or BelongsTo association using this column
29
30
  def check
30
31
  if valid?
31
32
  report_template(:ok)
@@ -37,6 +38,7 @@ module DatabaseConsistency
37
38
  def valid?
38
39
  validator?(ActiveModel::Validations::PresenceValidator) ||
39
40
  validator?(ActiveModel::Validations::InclusionValidator) ||
41
+ nil_exclusion_validator? ||
40
42
  belongs_to_association?
41
43
  end
42
44
 
@@ -48,6 +50,13 @@ module DatabaseConsistency
48
50
  model.record_timestamps? && %w[created_at updated_at].include?(column.name)
49
51
  end
50
52
 
53
+ def nil_exclusion_validator?
54
+ model.validators.grep(ActiveModel::Validations::ExclusionValidator).any? do |validator|
55
+ Helper.check_inclusion?(validator.attributes, column.name) &&
56
+ validator.options[:in].include?(nil)
57
+ end
58
+ end
59
+
51
60
  def validator?(validator_class)
52
61
  model.validators.grep(validator_class).any? do |validator|
53
62
  Helper.check_inclusion?(validator.attributes, column.name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DatabaseConsistency
4
- VERSION = '0.7.8'
4
+ VERSION = '0.7.9'
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.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evgeniy Demin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-02 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord