diff options
-rw-r--r-- | app/models/concerns/ignorable_column.rb | 4 | ||||
-rw-r--r-- | spec/models/concerns/ignorable_column_spec.rb | 12 |
2 files changed, 10 insertions, 6 deletions
diff --git a/app/models/concerns/ignorable_column.rb b/app/models/concerns/ignorable_column.rb index eb9f3423e48..03793e8bcbb 100644 --- a/app/models/concerns/ignorable_column.rb +++ b/app/models/concerns/ignorable_column.rb @@ -21,8 +21,8 @@ module IgnorableColumn @ignored_columns ||= Set.new end - def ignore_column(name) - ignored_columns << name.to_s + def ignore_column(*names) + ignored_columns.merge(names.map(&:to_s)) end end end diff --git a/spec/models/concerns/ignorable_column_spec.rb b/spec/models/concerns/ignorable_column_spec.rb index dba9fe43327..b70f2331a0e 100644 --- a/spec/models/concerns/ignorable_column_spec.rb +++ b/spec/models/concerns/ignorable_column_spec.rb @@ -5,7 +5,11 @@ describe IgnorableColumn do Class.new do def self.columns # This method does not have access to "double" - [Struct.new(:name).new('id'), Struct.new(:name).new('title')] + [ + Struct.new(:name).new('id'), + Struct.new(:name).new('title'), + Struct.new(:name).new('date') + ] end end end @@ -18,7 +22,7 @@ describe IgnorableColumn do describe '.columns' do it 'returns the columns, excluding the ignored ones' do - model.ignore_column(:title) + model.ignore_column(:title, :date) expect(model.columns.map(&:name)).to eq(%w(id)) end @@ -30,9 +34,9 @@ describe IgnorableColumn do end it 'returns the names of the ignored columns' do - model.ignore_column(:title) + model.ignore_column(:title, :date) - expect(model.ignored_columns).to eq(Set.new(%w(title))) + expect(model.ignored_columns).to eq(Set.new(%w(title date))) end end end |