Commit 761a8599 authored by Andreas Brandl's avatar Andreas Brandl

Store removal information

parent b3fd1440
...@@ -11,8 +11,18 @@ module IgnorableColumns ...@@ -11,8 +11,18 @@ module IgnorableColumns
raise ArgumentError, 'Please indicate when we can stop ignoring columns with remove_after, example: ignore_columns(:name, remove_after: \'2019-12-01\', remove_with: \'12.6\')' unless remove_after && remove_with raise ArgumentError, 'Please indicate when we can stop ignoring columns with remove_after, example: ignore_columns(:name, remove_after: \'2019-12-01\', remove_with: \'12.6\')' unless remove_after && remove_with
self.ignored_columns += columns.flatten self.ignored_columns += columns.flatten
@ignored_columns_details ||= {}
columns.flatten.each do |column|
@ignored_columns_details[column] = { remove_after: remove_after, remove_with: remove_with }
end
end end
alias_method :ignore_column, :ignore_columns alias_method :ignore_column, :ignore_columns
def ignored_columns_details
@ignored_columns_details || {}
end
end end
end end
...@@ -31,4 +31,22 @@ describe IgnorableColumns do ...@@ -31,4 +31,22 @@ describe IgnorableColumns do
expect { subject.ignore_columns(:name, remove_after: '2019-12-01', remove_with: nil) }.to raise_error(ArgumentError, /Please indicate/) expect { subject.ignore_columns(:name, remove_after: '2019-12-01', remove_with: nil) }.to raise_error(ArgumentError, /Please indicate/)
end end
describe '.ignored_columns_details' do
it 'stores removal information' do
subject.ignore_column(:name, remove_after: '2019-12-01', remove_with: '12.6')
expect(subject.ignored_columns_details[:name]).to eq(remove_after: '2019-12-01', remove_with: '12.6')
end
it 'stores removal information (array version)' do
subject.ignore_column(%i[name created_at], remove_after: '2019-12-01', remove_with: '12.6')
expect(subject.ignored_columns_details[:name]).to eq(remove_after: '2019-12-01', remove_with: '12.6')
expect(subject.ignored_columns_details[:created_at]).to eq(remove_after: '2019-12-01', remove_with: '12.6')
end
it 'defaults to empty Hash' do
expect(subject.ignored_columns_details).to eq({})
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