提交 d934d650 编写于 作者: M 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.
上级 5ab3ed7a
......@@ -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
......@@ -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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册