tests
This commit is contained in:
parent
1646448629
commit
b2bcc34cfd
2 changed files with 49 additions and 2 deletions
|
@ -95,8 +95,8 @@ describe Commentaire do
|
|||
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).with(no_args)
|
||||
it "calls notify_user with delay so expert can destroy his comment in case of failure" do
|
||||
expect(commentaire).to receive(:notify_user).with(wait: 5.minutes)
|
||||
commentaire.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -86,4 +86,51 @@ describe 'shared/dossiers/messages/message.html.haml', type: :view do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an expert message' do
|
||||
describe 'delete message button for expert' do
|
||||
let(:expert) { create(:expert) }
|
||||
let(:procedure) { create(:procedure) }
|
||||
let(:dossier) { create(:dossier, :en_construction, commentaires: [commentaire], procedure: procedure) }
|
||||
let(:experts_procedure) { create(:experts_procedure, procedure: procedure, expert: expert) }
|
||||
let!(:avis) { create(:avis, email: nil, experts_procedure: experts_procedure) }
|
||||
subject { render 'shared/dossiers/messages/message.html.haml', commentaire: commentaire, messagerie_seen_at: seen_at, connected_user: expert, show_reply_button: true }
|
||||
let(:form_url) { delete_commentaire_expert_avis_path(avis.procedure, avis, commentaire: commentaire) }
|
||||
|
||||
before do
|
||||
assign(:avis, avis)
|
||||
end
|
||||
|
||||
context 'on a procedure where commentaire had been written by connected expert' do
|
||||
let(:commentaire) { create(:commentaire, expert: expert, body: 'Second message') }
|
||||
|
||||
it { is_expected.to have_selector("form[action=\"#{form_url}\"]") }
|
||||
end
|
||||
|
||||
context 'on a procedure where commentaire had been written by connected expert and discarded' do
|
||||
let(:commentaire) { create(:commentaire, expert: expert, body: 'Second message', discarded_at: 2.days.ago) }
|
||||
|
||||
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||
it { is_expected.not_to have_selector(".rich-text", text: I18n.t(t('views.shared.commentaires.destroy.deleted_body'))) }
|
||||
end
|
||||
|
||||
context 'on a procedure where commentaire had been written by connected an user' do
|
||||
let(:commentaire) { create(:commentaire, email: create(:user).email, body: 'Second message') }
|
||||
|
||||
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||
end
|
||||
|
||||
context 'on a procedure where commentaire had been written by connected an instructeur' do
|
||||
let(:commentaire) { create(:commentaire, instructeur: create(:instructeur), body: 'Second message') }
|
||||
|
||||
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||
end
|
||||
|
||||
context 'on a procedure where commentaire had been written another expert' do
|
||||
let(:commentaire) { create(:commentaire, expert: create(:expert), body: 'Second message') }
|
||||
|
||||
it { is_expected.not_to have_selector("form[action=\"#{form_url}\"]") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue