performs_geo_lookup_examples.rb 625 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'UserPerformsGeoLookup' do
  3. it 'can only be loaded for User' do
  4. expect(described_class).to eq User
  5. end
  6. it 'performs geo lookup' do
  7. # Mock the geo lookup as it requires an API key.
  8. allow(Service::GeoLocation).to receive(:geocode).with('Marienstraße 18, 10117, Berlin, Germany').and_return([10.0, 20.0])
  9. user = create(described_class.name.underscore, street: 'Marienstraße 18', zip: '10117', city: 'Berlin', country: 'Germany')
  10. expect(user.preferences).to include(lat: 10.0, lng: 20.0)
  11. end
  12. end