2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
2020-02-18 14:49:52 +00:00
|
|
|
RSpec.shared_examples 'CanLookupSearchIndexAttributes' do
|
|
|
|
describe '.search_index_value_by_attribute' do
|
2020-03-02 14:25:33 +00:00
|
|
|
it 'returns search index value for attribute' do
|
2020-02-18 14:49:52 +00:00
|
|
|
organization = create(:organization, name: 'Tomato42', note: 'special recipe')
|
2020-06-19 09:17:18 +00:00
|
|
|
user = create(:agent, organization: organization)
|
2020-02-18 14:49:52 +00:00
|
|
|
|
|
|
|
value = user.search_index_value_by_attribute('organization_id')
|
2021-01-27 09:58:35 +00:00
|
|
|
expect(value['name']).to eq('Tomato42')
|
2020-02-18 14:49:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.search_index_attribute_ref_name' do
|
|
|
|
it 'returns correct value' do
|
|
|
|
attribute_ref_name = User.search_index_attribute_ref_name('organization_id')
|
|
|
|
expect(attribute_ref_name).to eq('organization')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.search_index_attribute_ignored?' do
|
|
|
|
it 'returns correct value' do
|
|
|
|
ignored = User.search_index_attribute_ignored?('password')
|
|
|
|
expect(ignored).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|