Commit d934d650 authored by micael.bergeron's avatar micael.bergeron

updated the ignore_column concern to support multiple columns

This method is an ActiveRecord extension and it should behave
like one. I expected this to work.
parent 5ab3ed7a
...@@ -21,8 +21,8 @@ module IgnorableColumn ...@@ -21,8 +21,8 @@ module IgnorableColumn
@ignored_columns ||= Set.new @ignored_columns ||= Set.new
end end
def ignore_column(name) def ignore_column(*names)
ignored_columns << name.to_s ignored_columns.merge(names.map(&:to_s))
end end
end end
end end
...@@ -5,7 +5,11 @@ describe IgnorableColumn do ...@@ -5,7 +5,11 @@ describe IgnorableColumn do
Class.new do Class.new do
def self.columns def self.columns
# This method does not have access to "double" # 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 end
end end
...@@ -18,7 +22,7 @@ describe IgnorableColumn do ...@@ -18,7 +22,7 @@ describe IgnorableColumn do
describe '.columns' do describe '.columns' do
it 'returns the columns, excluding the ignored ones' 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)) expect(model.columns.map(&:name)).to eq(%w(id))
end end
...@@ -30,9 +34,9 @@ describe IgnorableColumn do ...@@ -30,9 +34,9 @@ describe IgnorableColumn do
end end
it 'returns the names of the ignored columns' do 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 end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment