2024-04-25 17:57:55 +02:00
|
|
|
RSpec.describe DossierIndexSearchTermsJob, type: :job do
|
2023-04-22 19:54:41 +02:00
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
|
2024-04-03 10:21:50 +02:00
|
|
|
subject(:perform_job) { described_class.perform_now(dossier.reload) }
|
2023-04-22 19:54:41 +02:00
|
|
|
|
2024-04-03 10:21:50 +02:00
|
|
|
before do
|
|
|
|
create(:champ_text, dossier:, value: "un nouveau champ")
|
|
|
|
create(:champ_text, dossier:, value: "private champ", private: true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "update search terms columns" do
|
|
|
|
perform_job
|
|
|
|
|
|
|
|
sql = "SELECT search_terms, private_search_terms FROM dossiers WHERE id = :id"
|
|
|
|
sanitized_sql = Dossier.sanitize_sql_array([sql, id: dossier.id])
|
|
|
|
result = Dossier.connection.execute(sanitized_sql).first
|
2023-04-22 19:54:41 +02:00
|
|
|
|
2024-04-03 10:21:50 +02:00
|
|
|
expect(result['search_terms']).to match(/un nouveau champ/)
|
|
|
|
expect(result['private_search_terms']).to match(/private champ/)
|
2023-04-22 19:54:41 +02:00
|
|
|
end
|
|
|
|
end
|