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')
|
|
|
|
user = create(:agent_user, organization: organization)
|
|
|
|
|
|
|
|
value = user.search_index_value_by_attribute('organization_id')
|
2020-03-02 14:25:33 +00:00
|
|
|
expect(value).to eq('Tomato42')
|
2020-02-18 14:49:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '.search_index_value' do
|
|
|
|
it 'returns correct value' do
|
|
|
|
organization = create(:organization, name: 'Tomato42', note: 'special recipe')
|
|
|
|
|
|
|
|
value = organization.search_index_value
|
2020-03-02 14:25:33 +00:00
|
|
|
expect(value).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
|