has_object_manager_attributes_examples.rb 917 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'HasObjectManagerAttributes' do
  3. it 'validates ObjectManager::Attributes' do
  4. expect(described_class.validators.map(&:class)).to include(Validations::ObjectManager::AttributeValidator)
  5. end
  6. context "when object attribute with name 'type' is used", db_strategy: :reset do
  7. before do
  8. skip('Skip context if a special type handling exists') if subject.try(:type_id)
  9. if !ObjectManager::Attribute.exists?(object_lookup: ObjectLookup.find_by(name: described_class.name), name: 'type')
  10. create(:object_manager_attribute_text, name: 'type', object_name: described_class.name)
  11. ObjectManager::Attribute.migration_execute
  12. end
  13. end
  14. it "check that the 'type' column can be updated" do
  15. expect { subject.reload.update(type: 'Example') }.not_to raise_error
  16. end
  17. end
  18. end