Remove the link between commentaire and user
This commit is contained in:
parent
a640ec1d43
commit
c20ad5ca17
7 changed files with 45 additions and 25 deletions
|
@ -63,7 +63,7 @@ describe Commentaire do
|
|||
end
|
||||
|
||||
context 'with a commentaire created by a user' do
|
||||
let(:commentaire) { build :commentaire, user: user }
|
||||
let(:commentaire) { build :commentaire, email: user.email }
|
||||
let(:user) { build :user, email: 'some_user@exemple.fr' }
|
||||
|
||||
it { is_expected.to eq 'some_user@exemple.fr' }
|
||||
|
@ -73,26 +73,34 @@ describe Commentaire do
|
|||
describe "#notify" do
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:expert) { create(:expert) }
|
||||
let(:assign_to) { create(:assign_to, instructeur: instructeur, procedure: procedure) }
|
||||
let(:user) { create(:user) }
|
||||
let(:dossier) { create(:dossier, :en_construction, procedure: procedure, user: user) }
|
||||
let(:commentaire) { Commentaire.new(dossier: dossier, body: "Mon commentaire") }
|
||||
|
||||
context "with a commentaire created by a instructeur" do
|
||||
let(:commentaire) { CommentaireService.build(instructeur, dossier, body: "Mon commentaire") }
|
||||
|
||||
it "calls notify_user" do
|
||||
expect(commentaire).to receive(:notify_user)
|
||||
commentaire.save
|
||||
end
|
||||
end
|
||||
|
||||
commentaire.email = instructeur.email
|
||||
context "with a commentaire created by an expert" do
|
||||
let(:commentaire) { CommentaireService.build(expert, dossier, body: "Mon commentaire") }
|
||||
|
||||
it "calls notify_user" do
|
||||
expect(commentaire).to receive(:notify_user)
|
||||
commentaire.save
|
||||
end
|
||||
end
|
||||
|
||||
context "with a commentaire automatically created (notification)" do
|
||||
it "does not call notify_user or notify_instructeurs" do
|
||||
expect(commentaire).not_to receive(:notify_user)
|
||||
expect(commentaire).not_to receive(:notify_instructeurs)
|
||||
let(:commentaire) { CommentaireService.build_with_email(CONTACT_EMAIL, dossier, body: "Mon commentaire") }
|
||||
|
||||
commentaire.email = CONTACT_EMAIL
|
||||
it "does not call notify_user" do
|
||||
expect(commentaire).not_to receive(:notify_user)
|
||||
commentaire.save
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue