2015-09-22 15:00:59 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Backoffice::CommentairesController, type: :controller do
|
2016-01-18 17:18:04 +01:00
|
|
|
let(:dossier) { create(:dossier) }
|
2015-09-22 15:00:59 +02:00
|
|
|
let(:dossier_id) { dossier.id }
|
|
|
|
let(:email_commentaire) { 'test@test.com' }
|
|
|
|
let(:texte_commentaire) { 'Commentaire de test' }
|
|
|
|
|
|
|
|
describe '#POST create' do
|
|
|
|
before do
|
|
|
|
sign_in create(:gestionnaire)
|
|
|
|
end
|
|
|
|
context "création correct d'un commentaire" do
|
|
|
|
it 'depuis la page admin' do
|
|
|
|
post :create, dossier_id: dossier_id, email_commentaire: email_commentaire, texte_commentaire: texte_commentaire
|
|
|
|
expect(response).to redirect_to("/backoffice/dossiers/#{dossier_id}")
|
|
|
|
end
|
|
|
|
end
|
2015-09-25 10:46:09 +02:00
|
|
|
|
|
|
|
describe 'change dossier state after post a comment' do
|
|
|
|
context 'gestionnaire is connected' do
|
|
|
|
context 'when dossier is at state updated' do
|
|
|
|
before do
|
|
|
|
sign_in create(:gestionnaire)
|
|
|
|
dossier.updated!
|
|
|
|
|
|
|
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
|
|
|
dossier.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { dossier.state }
|
|
|
|
|
2015-11-02 11:33:00 +01:00
|
|
|
it {is_expected.to eq('replied')}
|
2015-12-15 15:33:21 +01:00
|
|
|
|
|
|
|
it 'Notification email is send' do
|
|
|
|
expect(NotificationMailer).to receive(:new_answer).and_return(NotificationMailer)
|
|
|
|
expect(NotificationMailer).to receive(:deliver_now!)
|
|
|
|
|
|
|
|
post :create, dossier_id: dossier_id, texte_commentaire: texte_commentaire
|
|
|
|
end
|
2015-09-25 10:46:09 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2015-09-22 15:00:59 +02:00
|
|
|
end
|
|
|
|
end
|