2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2021-08-17 16:37:16 +00:00
|
|
|
RSpec.shared_examples 'HasObjectManagerAttributes' do
|
2019-03-13 23:51:22 +00:00
|
|
|
it 'validates ObjectManager::Attributes' do
|
|
|
|
expect(described_class.validators.map(&:class)).to include(ObjectManager::Attribute::Validation)
|
|
|
|
end
|
2021-07-12 08:31:37 +00:00
|
|
|
|
|
|
|
context "when object attribute with name 'type' is used", db_strategy: :reset do
|
|
|
|
before do
|
|
|
|
skip('Skip context if a special type handling exists') if subject.try(:type_id)
|
|
|
|
|
|
|
|
if !ObjectManager::Attribute.exists?(object_lookup: ObjectLookup.find_by(name: described_class.name), name: 'type')
|
|
|
|
create(:object_manager_attribute_text, name: 'type', object_name: described_class.name)
|
|
|
|
ObjectManager::Attribute.migration_execute
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it "check that the 'type' column can be updated" do
|
|
|
|
expect { subject.reload.update(type: 'Example') }.not_to raise_error
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2019-03-13 23:51:22 +00:00
|
|
|
end
|