[Fix #721] If an avis is created with uppercase email, downcase it before save

This commit is contained in:
Mathieu Magnin 2017-09-12 17:02:45 +02:00
parent 39a53ff9b9
commit 31995c270c
3 changed files with 30 additions and 1 deletions

View file

@ -117,4 +117,26 @@ RSpec.describe Avis, type: :model do
it { expect(avis.email).to eq(email) }
end
end
describe "#downcase_email" do
subject { Avis.create(claimant: claimant, email: email, dossier: create(:dossier), gestionnaire: create(:gestionnaire)) }
context "when there is no email" do
let(:email) { nil }
it { expect(subject.email).to be_nil }
end
context "when the email is in lowercase" do
let(:email) { "toto@tps.fr" }
it { expect(subject.email).to eq("toto@tps.fr") }
end
context "when the email is not in lowercase" do
let(:email) { "TOTO@tps.fr" }
it { expect(subject.email).to eq("toto@tps.fr") }
end
end
end