fix(dossier): update search terms when etablissement or individual changed

This commit is contained in:
Colin Darie 2024-04-25 17:44:28 +02:00
parent ee465b38ff
commit 4408824882
No known key found for this signature in database
GPG key ID: 4FB865FDBCA4BCC4
4 changed files with 34 additions and 12 deletions

View file

@ -7,41 +7,49 @@ describe Individual do
describe "#save" do
let(:individual) { build(:individual) }
subject { individual.save }
subject do
individual.save
individual
end
context "with birthdate" do
before do
individual.birthdate = birthdate_from_user
subject
end
context "and the format is dd/mm/yyy " do
let(:birthdate_from_user) { "12/11/1980" }
it { expect(individual.birthdate).to eq(Date.new(1980, 11, 12)) }
it { expect(subject.birthdate).to eq(Date.new(1980, 11, 12)) }
end
context "and the format is ISO" do
let(:birthdate_from_user) { "1980-11-12" }
it { expect(individual.birthdate).to eq(Date.new(1980, 11, 12)) }
it { expect(subject.birthdate).to eq(Date.new(1980, 11, 12)) }
end
context "and the format is WTF" do
let(:birthdate_from_user) { "1980 1 12" }
it { expect(individual.birthdate).to be_nil }
it { expect(subject.birthdate).to be_nil }
end
end
context 'when an individual has an invalid notification_method' do
let(:invalid_individual) { build(:individual, notification_method: 'invalid_method') }
it 'raises an ArgumentError' do
expect {
invalid_individual.valid?
}.to raise_error(ArgumentError, "'invalid_method' is not a valid notification_method")
it "schedule update search terms" do
assert_enqueued_jobs(1, only: DossierUpdateSearchTermsJob) do
subject
end
end
end
context 'when an individual has an invalid notification_method' do
let(:invalid_individual) { build(:individual, notification_method: 'invalid_method') }
it 'raises an ArgumentError' do
expect {
invalid_individual.valid?
}.to raise_error(ArgumentError, "'invalid_method' is not a valid notification_method")
end
end
end