Skip to content

Commit

Permalink
Merge pull request #233 from hitobito/feature/2936/quicksearch-indexing
Browse files Browse the repository at this point in the history
Remove inclusion of PgSearchable
  • Loading branch information
kronn authored Nov 8, 2024
2 parents fd70795 + 03f02f9 commit 92961b7
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
3 changes: 1 addition & 2 deletions app/models/die_mitte/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ module DieMitte::Person
Person::PUBLIC_ATTRS << :title << :website << :correspondence_language <<
:civil_status << :salutation

include PgSearchable
SEARCHABLE_ATTRS = [{roles: {translations: [:label]}}] # rubocop:disable Lint/ConstantDefinitionInBlock
Person::SEARCHABLE_ATTRS.find { |element| element.is_a?(Hash) }[:role_translations] = [:label]

i18n_enum :correspondence_language, Settings.application
.correspondence_languages
Expand Down
48 changes: 48 additions & 0 deletions spec/domain/search_strategies/person_search_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

# Copyright (c) 2021, Die Mitte. This file is part of
# hitobito_die_mitte and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito_die_mitte.

require "spec_helper"

describe SearchStrategies::PersonSearch do
describe "#search_fulltext" do
let(:user) { people(:admin) }

it "finds accessible person by title" do
result = search_class(people(:admin).title.to_s).search_fulltext

expect(result).to include(people(:admin))
end

it "finds accessible person by website" do
result = search_class(people(:admin).website.to_s).search_fulltext

expect(result).to include(people(:admin))
end

it "finds accessible person by correspondence_language" do
result = search_class(people(:admin).correspondence_language.to_s).search_fulltext

expect(result).to include(people(:admin))
end

it "finds accessible person by civil_status" do
result = search_class(people(:admin).civil_status.to_s).search_fulltext

expect(result).to include(people(:admin))
end

it "finds accessible person by salutation" do
result = search_class(people(:admin).salutation.to_s).search_fulltext

expect(result).to include(people(:admin))
end
end

def search_class(term = nil, page = nil)
described_class.new(user, term, page)
end
end

0 comments on commit 92961b7

Please sign in to comment.