fix(Commentaire.sent_by?): &.email compared to nil could sent by true when nil==nil, avoid this one

This commit is contained in:
Martin 2021-11-15 12:01:56 +01:00
parent b03dc6ad5d
commit 5b72bdec7e
2 changed files with 7 additions and 1 deletions

View file

@ -75,7 +75,7 @@ class Commentaire < ApplicationRecord
end
def sent_by?(someone)
email == someone&.email
someone.present? && email == someone&.email
end
def file_url

View file

@ -40,6 +40,12 @@ describe Commentaire do
end
end
describe "sent_by?" do
let(:commentaire) { build(:commentaire, instructeur: build(:instructeur)) }
subject { commentaire.sent_by?(nil) }
it { is_expected.to be_falsy }
end
describe "#redacted_email" do
subject { commentaire.redacted_email }