2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2018-11-08 12:53:41 +00:00
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
RSpec.describe AddCountryAttributeToUsers, type: :db_migration do
|
|
|
|
context 'AddCountryAttributeToUsers migration' do
|
|
|
|
it 'preserves the existing country attribute' do
|
|
|
|
expect { migrate }
|
2019-04-15 01:41:17 +00:00
|
|
|
.not_to change { ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') }
|
2018-11-08 12:53:41 +00:00
|
|
|
end
|
|
|
|
|
2019-04-15 01:41:17 +00:00
|
|
|
context 'when country attribute is not present' do
|
|
|
|
before { ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country').delete }
|
|
|
|
|
|
|
|
it 'adds the country attribute when it is not present' do
|
|
|
|
expect { migrate }
|
|
|
|
.to change { ObjectManager::Attribute.exists?(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') }
|
|
|
|
.from(false).to(true)
|
|
|
|
end
|
2018-11-08 12:53:41 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|