Skip to content

Commit eb16cde

Browse files
authored
missing_presence_validator: fix regex ignores
1 parent 9a8158a commit eb16cde

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/active_record_doctor/detectors/missing_presence_validation.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def detect
5656
(config(:ignore_columns_with_default) && (column.default || column.default_function)) ||
5757

5858
# Explicitly ignored columns should be skipped.
59-
config(:ignore_attributes).include?("#{model.name}.#{column.name}")
59+
ignored?("#{model.name}.#{column.name}", config(:ignore_attributes))
6060
end
6161

6262
# At this point the only columns that are left are those that DO

test/active_record_doctor/detectors/missing_presence_validation_test.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,21 @@ def test_config_ignore_attributes
345345
refute_problems
346346
end
347347

348+
def test_config_ignore_attributes_regexp
349+
Context.create_table(:users) do |t|
350+
t.string :name, null: false
351+
end.define_model
352+
353+
config_file(<<-CONFIG)
354+
ActiveRecordDoctor.configure do |config|
355+
config.detector :missing_presence_validation,
356+
ignore_attributes: [/name/]
357+
end
358+
CONFIG
359+
360+
refute_problems
361+
end
362+
348363
def test_config_ignore_polymorphic_associations_via_relationship_name
349364
Context.create_table(:comments) do |t|
350365
t.references :commentable, null: false, polymorphic: true

0 commit comments

Comments
 (0)