Follow up - 444e48e377
- Obsolete ObjectManager::Attribute data_option missing :diff option fails migration.
This commit is contained in:
parent
969012584a
commit
153032e82f
2 changed files with 30 additions and 0 deletions
|
@ -6,6 +6,12 @@ class ObjectManagerAttributeDateRemoveFuturePast < ActiveRecord::Migration[5.1]
|
|||
|
||||
ObjectManager::Attribute.where(data_type: 'date').each do |attribute|
|
||||
attribute.data_option = attribute.data_option.except(:future, :past)
|
||||
|
||||
# some attributes from the early Zammad days don't have all
|
||||
# required data_option attributes because they were not properly migrated
|
||||
# so we need to fix them now
|
||||
attribute.data_option[:diff] ||= 24
|
||||
|
||||
attribute.save!
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,5 +21,29 @@ RSpec.describe ObjectManagerAttributeDateRemoveFuturePast, type: :db_migration d
|
|||
|
||||
expect(subject.data_option).to_not include(:past, :future)
|
||||
end
|
||||
|
||||
context 'when incomplete data_option is given' do
|
||||
|
||||
it 'adds missing :diff option' do
|
||||
subject = build(:object_manager_attribute_date)
|
||||
|
||||
# add data_options manually because the factory doesn't contain them anymore
|
||||
subject.data_option = subject.data_option.merge(
|
||||
future: false,
|
||||
past: false,
|
||||
)
|
||||
|
||||
# remove diff option as for some attributes
|
||||
# from older Zammad installations
|
||||
subject.data_option.delete(:diff)
|
||||
|
||||
# mock interfaces to save time
|
||||
# otherwise we would have to reseed the database
|
||||
expect(ObjectManager::Attribute).to receive(:where).and_return([subject])
|
||||
# expect(subject).to receive(:save!)
|
||||
|
||||
expect { migrate }.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue