issue_2333_object_country_already_exists_spec.rb 883 B

12345678910111213141516171819202122
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe AddCountryAttributeToUsers, type: :db_migration do
  4. context 'AddCountryAttributeToUsers migration' do
  5. it 'preserves the existing country attribute' do
  6. expect { migrate }
  7. .not_to change { ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') }
  8. end
  9. context 'when country attribute is not present' do
  10. before { ObjectManager::Attribute.find_by(object_lookup_id: ObjectLookup.by_name('User'), name: 'country').delete }
  11. it 'adds the country attribute when it is not present' do
  12. expect { migrate }
  13. .to change { ObjectManager::Attribute.exists?(object_lookup_id: ObjectLookup.by_name('User'), name: 'country') }
  14. .from(false).to(true)
  15. end
  16. end
  17. end
  18. end