Skip to content

Commit

Permalink
implement spec for person search
Browse files Browse the repository at this point in the history
  • Loading branch information
Vakmeth committed Aug 21, 2024
1 parent 7a986d7 commit 6b1827e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
10 changes: 0 additions & 10 deletions app/indices/person_index.rb

This file was deleted.

3 changes: 3 additions & 0 deletions app/models/youth/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ module Youth::Person
NATIONALITIES_J_S = %w[CH FL ANDERE].freeze

included do
Person::SEARCHABLE_ATTRS << :ahv_number << :j_s_number
include PgSearchable

has_many :people_managers, foreign_key: :managed_id,
dependent: :destroy
has_many :people_manageds, class_name: "PeopleManager",
Expand Down
27 changes: 27 additions & 0 deletions spec/domain/search_strategies/person_search_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "spec_helper"

describe SearchStrategies::PersonSearch do
before do
people(:bottom_leader).update!(j_s_number: 12345, ahv_number: "756.9217.0769.85")
end

describe "#search_fulltext" do
let(:user) { people(:top_leader) }

it "finds accessible person by j_s number" do
result = search_class(people(:bottom_leader).j_s_number.to_s).search_fulltext

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

it "finds accessible person by ahv number" do
result = search_class(people(:bottom_leader).ahv_number.to_s).search_fulltext

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

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

0 comments on commit 6b1827e

Please sign in to comment.