can_lookup_search_index_attributes_examples.rb 953 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec.shared_examples 'CanLookupSearchIndexAttributes' do
  3. describe '.search_index_value_by_attribute' do
  4. it 'returns search index value for attribute' do
  5. organization = create(:organization, name: 'Tomato42', note: 'special recipe')
  6. user = create(:agent, organization: organization)
  7. value = user.search_index_value_by_attribute('organization_id')
  8. expect(value['name']).to eq('Tomato42')
  9. end
  10. end
  11. describe '.search_index_attribute_ref_name' do
  12. it 'returns correct value' do
  13. attribute_ref_name = User.search_index_attribute_ref_name('organization_id')
  14. expect(attribute_ref_name).to eq('organization')
  15. end
  16. end
  17. describe '.search_index_attribute_ignored?' do
  18. it 'returns correct value' do
  19. ignored = User.search_index_attribute_ignored?('password')
  20. expect(ignored).to be true
  21. end
  22. end
  23. end