fix(Commentaire.sent_by?): &.email compared to nil could sent by true when nil==nil, avoid this one
This commit is contained in:
parent
b03dc6ad5d
commit
5b72bdec7e
2 changed files with 7 additions and 1 deletions
|
@ -75,7 +75,7 @@ class Commentaire < ApplicationRecord
|
|||
end
|
||||
|
||||
def sent_by?(someone)
|
||||
email == someone&.email
|
||||
someone.present? && email == someone&.email
|
||||
end
|
||||
|
||||
def file_url
|
||||
|
|
|
@ -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 }
|
||||
|
||||
|
|
Loading…
Reference in a new issue