has_object_manager_attributes_validation_examples.rb 840 B

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