issue_2333_object_country_already_exists_spec.rb 806 B

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