organization_spec.rb 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe Selector::Base, 'organization', searchindex: true do
  4. describe 'Basic tests' do
  5. let(:organization_1) { create(:organization) }
  6. let(:organization_2) { create(:organization) }
  7. let(:organization_3) { create(:organization) }
  8. before do
  9. organization_1 && organization_2 && organization_3
  10. searchindex_model_reload([Organization])
  11. end
  12. it 'does find organizations by name', :aggregate_failures do
  13. condition = {
  14. operator: 'OR',
  15. conditions: [
  16. {
  17. name: 'organization.name',
  18. operator: 'contains',
  19. value: organization_1.name,
  20. },
  21. {
  22. name: 'organization.name',
  23. operator: 'contains',
  24. value: organization_2.name,
  25. },
  26. {
  27. name: 'organization.name',
  28. operator: 'contains',
  29. value: organization_3.name,
  30. },
  31. ]
  32. }
  33. count, = Organization.selectors(condition)
  34. expect(count).to eq(3)
  35. result = SearchIndexBackend.selectors('Organization', condition)
  36. expect(result[:count]).to eq(3)
  37. end
  38. end
  39. end